vectara-agentic 0.3.3__py3-none-any.whl → 0.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of vectara-agentic might be problematic. Click here for more details.

Files changed (53) hide show
  1. tests/__init__.py +7 -0
  2. tests/conftest.py +312 -0
  3. tests/endpoint.py +54 -17
  4. tests/run_tests.py +111 -0
  5. tests/test_agent.py +10 -5
  6. tests/test_agent_type.py +82 -143
  7. tests/test_api_endpoint.py +4 -0
  8. tests/test_bedrock.py +4 -0
  9. tests/test_fallback.py +4 -0
  10. tests/test_gemini.py +28 -45
  11. tests/test_groq.py +4 -0
  12. tests/test_private_llm.py +11 -2
  13. tests/test_return_direct.py +6 -2
  14. tests/test_serialization.py +4 -0
  15. tests/test_streaming.py +88 -0
  16. tests/test_tools.py +10 -82
  17. tests/test_vectara_llms.py +4 -0
  18. tests/test_vhc.py +66 -0
  19. tests/test_workflow.py +4 -0
  20. vectara_agentic/__init__.py +27 -4
  21. vectara_agentic/_callback.py +65 -67
  22. vectara_agentic/_observability.py +30 -30
  23. vectara_agentic/_version.py +1 -1
  24. vectara_agentic/agent.py +375 -848
  25. vectara_agentic/agent_config.py +15 -14
  26. vectara_agentic/agent_core/__init__.py +22 -0
  27. vectara_agentic/agent_core/factory.py +501 -0
  28. vectara_agentic/{_prompts.py → agent_core/prompts.py} +3 -35
  29. vectara_agentic/agent_core/serialization.py +345 -0
  30. vectara_agentic/agent_core/streaming.py +495 -0
  31. vectara_agentic/agent_core/utils/__init__.py +34 -0
  32. vectara_agentic/agent_core/utils/hallucination.py +202 -0
  33. vectara_agentic/agent_core/utils/logging.py +52 -0
  34. vectara_agentic/agent_core/utils/prompt_formatting.py +56 -0
  35. vectara_agentic/agent_core/utils/schemas.py +87 -0
  36. vectara_agentic/agent_core/utils/tools.py +125 -0
  37. vectara_agentic/agent_endpoint.py +4 -6
  38. vectara_agentic/db_tools.py +37 -12
  39. vectara_agentic/llm_utils.py +41 -42
  40. vectara_agentic/sub_query_workflow.py +9 -14
  41. vectara_agentic/tool_utils.py +138 -83
  42. vectara_agentic/tools.py +36 -21
  43. vectara_agentic/tools_catalog.py +16 -16
  44. vectara_agentic/types.py +98 -6
  45. {vectara_agentic-0.3.3.dist-info → vectara_agentic-0.4.0.dist-info}/METADATA +69 -30
  46. vectara_agentic-0.4.0.dist-info/RECORD +50 -0
  47. tests/test_agent_planning.py +0 -64
  48. tests/test_hhem.py +0 -100
  49. vectara_agentic/hhem.py +0 -82
  50. vectara_agentic-0.3.3.dist-info/RECORD +0 -39
  51. {vectara_agentic-0.3.3.dist-info → vectara_agentic-0.4.0.dist-info}/WHEEL +0 -0
  52. {vectara_agentic-0.3.3.dist-info → vectara_agentic-0.4.0.dist-info}/licenses/LICENSE +0 -0
  53. {vectara_agentic-0.3.3.dist-info → vectara_agentic-0.4.0.dist-info}/top_level.txt +0 -0
vectara_agentic/types.py CHANGED
@@ -3,13 +3,13 @@ This module contains the types used in the Vectara Agentic.
3
3
  """
4
4
 
5
5
  from enum import Enum
6
- from typing import Protocol, Any
6
+ from typing import Any, Dict, Callable, AsyncIterator, Protocol, cast
7
+ from dataclasses import dataclass, field
7
8
 
8
9
  from llama_index.core.schema import Document as LI_Document
9
10
  from llama_index.core.tools.types import ToolOutput as LI_ToolOutput
10
- from llama_index.core.chat_engine.types import AgentChatResponse as LI_AgentChatResponse
11
11
  from llama_index.core.chat_engine.types import (
12
- StreamingAgentChatResponse as LI_StreamingAgentChatResponse,
12
+ AgentChatResponse as LI_AgentChatResponse,
13
13
  )
14
14
 
15
15
 
@@ -17,7 +17,6 @@ class AgentType(Enum):
17
17
  """Enumeration for different types of agents."""
18
18
 
19
19
  REACT = "REACT"
20
- OPENAI = "OPENAI"
21
20
  FUNCTION_CALLING = "FUNCTION_CALLING"
22
21
  LLMCOMPILER = "LLMCOMPILER"
23
22
  LATS = "LATS"
@@ -37,7 +36,6 @@ class ModelProvider(Enum):
37
36
  ANTHROPIC = "ANTHROPIC"
38
37
  TOGETHER = "TOGETHER"
39
38
  GROQ = "GROQ"
40
- FIREWORKS = "FIREWORKS"
41
39
  COHERE = "COHERE"
42
40
  GEMINI = "GEMINI"
43
41
  BEDROCK = "BEDROCK"
@@ -84,8 +82,102 @@ class HumanReadableOutput(Protocol):
84
82
  """Get the raw output data."""
85
83
 
86
84
 
85
+ class _StreamProto(Protocol):
86
+ """What we actually use from the LI streaming response."""
87
+
88
+ response: str | None
89
+ response_id: str | None
90
+
91
+ def get_response(self) -> LI_AgentChatResponse:
92
+ """Get the agent chat response."""
93
+
94
+ def to_response(self) -> LI_AgentChatResponse:
95
+ """Convert to agent chat response."""
96
+
97
+ def get_final_response(self) -> LI_AgentChatResponse:
98
+ """Get the final agent chat response."""
99
+
100
+ def __iter__(self):
101
+ """Return an iterator over the stream."""
102
+
103
+ async def async_response_gen(self) -> AsyncIterator[str]:
104
+ """Async generator that yields response strings."""
105
+
106
+
87
107
  # classes for Agent responses
88
108
  ToolOutput = LI_ToolOutput
89
109
  AgentResponse = LI_AgentChatResponse
90
- AgentStreamingResponse = LI_StreamingAgentChatResponse
91
110
  Document = LI_Document
111
+
112
+
113
+ @dataclass
114
+ class AgentStreamingResponse:
115
+ """Our stream wrapper with writable metadata and a typed get_response()."""
116
+
117
+ base: _StreamProto
118
+ metadata: Dict[str, Any] = field(default_factory=dict)
119
+
120
+ def __getattr__(self, name: str):
121
+ return getattr(self.base, name)
122
+
123
+ def get_response(self) -> AgentResponse:
124
+ """Get the response from the base stream, merging metadata."""
125
+ # choose whichever method the base actually has
126
+ if hasattr(self.base, "get_response"):
127
+ resp = cast(AgentResponse, self.base.get_response())
128
+ elif hasattr(self.base, "to_response"):
129
+ resp = cast(AgentResponse, self.base.to_response())
130
+ else:
131
+ resp = cast(AgentResponse, self.base.get_final_response())
132
+
133
+ resp.metadata = (resp.metadata or {}) | self.metadata
134
+ return resp
135
+
136
+ async def aget_response(self) -> AgentResponse:
137
+ """Get the response from the base stream, merging metadata (async version)."""
138
+ # prefer async version if available
139
+ if hasattr(self.base, "aget_response"):
140
+ resp = cast(AgentResponse, await self.base.aget_response())
141
+ elif hasattr(self.base, "get_response"):
142
+ resp = cast(AgentResponse, self.base.get_response())
143
+ elif hasattr(self.base, "to_response"):
144
+ resp = cast(AgentResponse, self.base.to_response())
145
+ else:
146
+ resp = cast(AgentResponse, self.base.get_final_response())
147
+
148
+ resp.metadata = (resp.metadata or {}) | self.metadata
149
+ return resp
150
+
151
+ @property
152
+ def async_response_gen(self) -> Callable[[], AsyncIterator[str]]:
153
+ """Get the async response generator from the base stream."""
154
+ return self.base.async_response_gen
155
+
156
+ @async_response_gen.setter
157
+ def async_response_gen(self, fn: Callable[[], AsyncIterator[str]]):
158
+ """Set the async response generator for the base stream."""
159
+ self.base.async_response_gen = fn
160
+
161
+ @classmethod
162
+ def from_error(cls, msg: str) -> "AgentStreamingResponse":
163
+ """Create an AgentStreamingResponse from an error message."""
164
+
165
+ async def _empty_gen():
166
+ if False: # pylint: disable=using-constant-test
167
+ yield ""
168
+
169
+ class _ErrStream:
170
+ def __init__(self, msg: str):
171
+ self.response = msg
172
+ self.response_id = None
173
+
174
+ async def async_response_gen(self):
175
+ """Async generator that yields an error message."""
176
+ if False: # pylint: disable=using-constant-test
177
+ yield ""
178
+
179
+ def get_response(self) -> AgentResponse:
180
+ """Return an AgentResponse with the error message."""
181
+ return AgentResponse(response=self.response, metadata={})
182
+
183
+ return cls(base=_ErrStream(msg), metadata={})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vectara_agentic
3
- Version: 0.3.3
3
+ Version: 0.4.0
4
4
  Summary: A Python package for creating AI Assistants and AI Agents with Vectara
5
5
  Home-page: https://github.com/vectara/py-vectara-agentic
6
6
  Author: Ofer Mendelevitch
@@ -16,26 +16,26 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
16
  Requires-Python: >=3.10
17
17
  Description-Content-Type: text/markdown
18
18
  License-File: LICENSE
19
- Requires-Dist: llama-index==0.12.37
20
- Requires-Dist: llama-index-core==0.12.37
21
- Requires-Dist: llama-index-cli==0.4.1
19
+ Requires-Dist: llama-index==0.12.49
20
+ Requires-Dist: llama-index-core==0.12.49
21
+ Requires-Dist: llama-index-workflow==1.0.1
22
+ Requires-Dist: llama-index-cli==0.4.4
22
23
  Requires-Dist: llama-index-indices-managed-vectara==0.4.5
23
- Requires-Dist: llama-index-agent-llm-compiler==0.3.1
24
- Requires-Dist: llama-index-agent-lats==0.3.0
25
- Requires-Dist: llama-index-agent-openai==0.4.8
26
- Requires-Dist: llama-index-llms-openai==0.3.44
27
- Requires-Dist: llama-index-llms-openai-like==0.3.5
28
- Requires-Dist: llama-index-llms-anthropic==0.6.19
29
- Requires-Dist: llama-index-llms-together==0.3.1
30
- Requires-Dist: llama-index-llms-groq==0.3.1
31
- Requires-Dist: llama-index-llms-fireworks==0.3.2
24
+ Requires-Dist: llama-index-agent-llm-compiler==0.3.2
25
+ Requires-Dist: llama-index-agent-lats==0.3.2
26
+ Requires-Dist: llama-index-agent-openai==0.4.12
27
+ Requires-Dist: llama-index-llms-openai==0.4.7
28
+ Requires-Dist: llama-index-llms-openai-like==0.4.0
29
+ Requires-Dist: llama-index-llms-anthropic==0.7.6
30
+ Requires-Dist: llama-index-llms-together==0.3.2
31
+ Requires-Dist: llama-index-llms-groq==0.3.2
32
32
  Requires-Dist: llama-index-llms-cohere==0.5.0
33
- Requires-Dist: llama-index-llms-google-genai==0.2.1
34
- Requires-Dist: llama-index-llms-bedrock-converse==0.7.1
33
+ Requires-Dist: llama-index-llms-google-genai==0.2.5
34
+ Requires-Dist: llama-index-llms-bedrock-converse==0.7.6
35
35
  Requires-Dist: llama-index-tools-yahoo-finance==0.3.0
36
36
  Requires-Dist: llama-index-tools-arxiv==0.3.0
37
37
  Requires-Dist: llama-index-tools-database==0.3.0
38
- Requires-Dist: llama-index-tools-google==0.3.1
38
+ Requires-Dist: llama-index-tools-google==0.5.0
39
39
  Requires-Dist: llama-index-tools-tavily_research==0.3.0
40
40
  Requires-Dist: llama_index.tools.brave_search==0.3.0
41
41
  Requires-Dist: llama-index-tools-neo4j==0.3.0
@@ -44,11 +44,11 @@ Requires-Dist: llama-index-graph-stores-kuzu==0.7.0
44
44
  Requires-Dist: llama-index-tools-salesforce==0.3.0
45
45
  Requires-Dist: llama-index-tools-slack==0.3.0
46
46
  Requires-Dist: llama-index-tools-exa==0.3.0
47
- Requires-Dist: llama-index-tools-wikipedia==0.3.0
47
+ Requires-Dist: llama-index-tools-wikipedia==0.3.1
48
48
  Requires-Dist: llama-index-tools-bing-search==0.3.0
49
- Requires-Dist: openai>=1.82.1
50
- Requires-Dist: tavily-python==0.7.3
51
- Requires-Dist: exa-py==1.13.1
49
+ Requires-Dist: openai>=1.96.1
50
+ Requires-Dist: tavily-python>=0.7.9
51
+ Requires-Dist: exa-py>=1.14.8
52
52
  Requires-Dist: openinference-instrumentation-llama-index==4.3.1
53
53
  Requires-Dist: opentelemetry-proto>=1.31.0
54
54
  Requires-Dist: arize-phoenix==10.9.1
@@ -56,9 +56,9 @@ Requires-Dist: arize-phoenix-otel==0.10.3
56
56
  Requires-Dist: protobuf==5.29.3
57
57
  Requires-Dist: tokenizers>=0.20
58
58
  Requires-Dist: pydantic==2.11.5
59
+ Requires-Dist: pandas==2.2.3
59
60
  Requires-Dist: retrying==1.3.4
60
61
  Requires-Dist: python-dotenv==1.0.1
61
- Requires-Dist: tiktoken==0.9.0
62
62
  Requires-Dist: cloudpickle>=3.1.1
63
63
  Requires-Dist: httpx==0.28.1
64
64
  Requires-Dist: commonmark==0.9.1
@@ -108,6 +108,7 @@ Dynamic: summary
108
108
  - [Using Tools](#using-tools)
109
109
  - [Advanced Usage: Workflows](#advanced-usage-workflows)
110
110
  - [Configuration](#️-configuration)
111
+ - [Migrating from v0.3.x](#-migrating-from-v03x)
111
112
  - [Contributing](#-contributing)
112
113
  - [License](#-license)
113
114
 
@@ -124,11 +125,11 @@ Dynamic: summary
124
125
  - **Rapid Tool Creation:**
125
126
  Build Vectara RAG tools or search tools with a single line of code.
126
127
  - **Agent Flexibility:**
127
- Supports multiple agent types including `ReAct`, `OpenAIAgent`, `LATS`, and `LLMCompiler`.
128
+ Supports multiple agent types including `ReAct`, `Function Calling`, `LATS`, and `LLMCompiler`.
128
129
  - **Pre-Built Domain Tools:**
129
130
  Tools tailored for finance, legal, and other verticals.
130
131
  - **Multi-LLM Integration:**
131
- Seamless integration with OpenAI, Anthropic, Gemini, GROQ, Together.AI, Cohere, Bedrock, and Fireworks.
132
+ Seamless integration with OpenAI, Anthropic, Gemini, GROQ, Together.AI, Cohere, and Bedrock.
132
133
  - **Observability:**
133
134
  Built-in support with Arize Phoenix for monitoring and feedback.
134
135
  - **Workflow Support:**
@@ -148,7 +149,7 @@ Check out our example AI assistants:
148
149
  - [Vectara account](https://console.vectara.com/signup/?utm_source=github&utm_medium=code&utm_term=DevRel&utm_content=vectara-agentic&utm_campaign=github-code-DevRel-vectara-agentic)
149
150
  - A Vectara corpus with an [API key](https://docs.vectara.com/docs/api-keys)
150
151
  - [Python 3.10 or higher](https://www.python.org/downloads/)
151
- - OpenAI API key (or API keys for Anthropic, TOGETHER.AI, Fireworks AI, Cohere, GEMINI or GROQ, if you choose to use them).
152
+ - OpenAI API key (or API keys for Anthropic, TOGETHER.AI, Cohere, GEMINI or GROQ, if you choose to use them).
152
153
  To use AWS Bedrock, make sure that
153
154
  * The Bedrock models you need are enabled on your account
154
155
  * Your environment includes `AWS_PROFILE` with your AWS profile name.
@@ -200,7 +201,8 @@ ask_finance = vec_factory.create_rag_tool(
200
201
  tool_description="Query financial reports for a company and year",
201
202
  tool_args_schema=QueryFinancialReportsArgs,
202
203
  lambda_val=0.005,
203
- summary_num_results=7,
204
+ summary_num_results=7,
205
+ vhc_eligible=True, # RAG tools participate in VHC by default
204
206
  # Additional Vectara query arguments...
205
207
  )
206
208
  ```
@@ -480,6 +482,30 @@ def mult_func(x, y):
480
482
  mult_tool = ToolsFactory().create_tool(mult_func)
481
483
  ```
482
484
 
485
+ #### VHC Eligibility
486
+
487
+ When creating tools, you can control whether they participate in Vectara Hallucination Correction, by using the `vhc_eligible` parameter:
488
+
489
+ ```python
490
+ # Tool that provides factual data - should participate in VHC
491
+ data_tool = ToolsFactory().create_tool(get_company_data, vhc_eligible=True)
492
+
493
+ # Utility tool that doesn't provide context - should not participate in VHC
494
+ summary_tool = ToolsFactory().create_tool(summarize_text, vhc_eligible=False)
495
+ ```
496
+
497
+ **VHC-eligible tools** (default: `True`) are those that provide factual context for responses, such as:
498
+ - Data retrieval tools
499
+ - Search tools
500
+ - API calls that return factual information
501
+
502
+ **Non-VHC-eligible tools** (`vhc_eligible=False`) are utility tools that don't contribute factual context:
503
+ - Text summarization tools
504
+ - Text rephrasing tools
505
+ - Formatting or processing tools
506
+
507
+ Built-in utility tools like `summarize_text`, `rephrase_text`, and `get_bad_topics` are automatically marked as non-VHC-eligible.
508
+
483
509
  #### Human-Readable Tool Output
484
510
 
485
511
  Tools can provide both raw data and human-readable formatted output using the `create_human_readable_output` utility:
@@ -504,7 +530,7 @@ Built-in formatters include `format_as_table`, `format_as_json`, and `format_as_
504
530
  > and not as nested functions. Nested functions are not supported if you use serialization
505
531
  > (dumps/loads or from_dict/to_dict).
506
532
 
507
- The human-readable format, if available, is used when computing the factual consistency score.
533
+ The human-readable format, if available, is used when using Vectara Hallucination Correction.
508
534
 
509
535
  ### Tool Validation
510
536
 
@@ -719,12 +745,13 @@ agent = Agent(
719
745
  ```
720
746
 
721
747
  The `AgentConfig` object may include the following items:
722
- - `agent_type`: the agent type. Valid values are `REACT`, `LLMCOMPILER`, `LATS` or `OPENAI` (default: `OPENAI`).
723
- - `main_llm_provider` and `tool_llm_provider`: the LLM provider for main agent and for the tools. Valid values are `OPENAI`, `ANTHROPIC`, `TOGETHER`, `GROQ`, `COHERE`, `BEDROCK`, `GEMINI` or `FIREWORKS` (default: `OPENAI`).
724
- - `main_llm_model_name` and `tool_llm_model_name`: agent model name for agent and tools (default depends on provider).
748
+ - `agent_type`: the agent type. Valid values are `REACT`, `LLMCOMPILER`, `LATS` or `FUNCTION_CALLING` (default: `FUNCTION_CALLING`).
749
+ - `main_llm_provider` and `tool_llm_provider`: the LLM provider for main agent and for the tools. Valid values are `OPENAI`, `ANTHROPIC`, `TOGETHER`, `GROQ`, `COHERE`, `BEDROCK`, `GEMINI` (default: `OPENAI`).
750
+
751
+ > **Note:** Fireworks AI support has been removed. If you were using Fireworks, please migrate to one of the supported providers listed above.
752
+ - `main_llm_model_name` and `tool_llm_model_name`: agent model name for agent and tools (default depends on provider: OpenAI uses gpt-4.1, Gemini uses gemini-2.5-flash).
725
753
  - `observer`: the observer type; should be `ARIZE_PHOENIX` or if undefined no observation framework will be used.
726
754
  - `endpoint_api_key`: a secret key if using the API endpoint option (defaults to `dev-api-key`)
727
- - `max_reasoning_steps`: the maximum number of reasoning steps (iterations for React and function calls for OpenAI agent, respectively). Defaults to 50.
728
755
 
729
756
  If any of these are not provided, `AgentConfig` first tries to read the values from the OS environment.
730
757
 
@@ -759,3 +786,15 @@ agent = Agent(
759
786
  )
760
787
  ```
761
788
 
789
+ ## 🚀 Migrating from v0.3.x
790
+
791
+ If you're upgrading from v0.3.x, please note the following breaking changes in v0.4.0:
792
+
793
+ - **Fireworks LLM removed**: Migrate to OpenAI, Anthropic, Together.AI, GROQ, Cohere, Bedrock, or Gemini
794
+ - **OPENAI AgentType removed**: Use the FUNCTION_CALLING AgentType instead, when using OpenAI for main_llm_provider
795
+ - **StructuredPlanning deprecated**: Use standard Agent workflows or create custom workflows
796
+ - **Token counting and compact_docstring removed**: Remove these from your configuration
797
+ - **update_func removed**: This functionality is no longer available
798
+
799
+ For detailed migration instructions, see [CHANGELOG.md](CHANGELOG.md).
800
+
@@ -0,0 +1,50 @@
1
+ tests/__init__.py,sha256=vXhQJCyD1Uhx2NP8b8vIUG3RUhkXyvn7oOir2bmctQU,175
2
+ tests/conftest.py,sha256=WHK_SxlhU2EN55w8wXUMMHhks8yriOab5nK1y8HXe3g,9276
3
+ tests/endpoint.py,sha256=0URgtz8uydhP_rtpGn_59P1LiWkd3idNlI85LzXnlUE,2744
4
+ tests/run_tests.py,sha256=eZd50pV4FIbr8riDaqXvDheoW3mOcO3ZRGloGUNusAM,3197
5
+ tests/test_agent.py,sha256=V5r7Cqe0iqV8VmeDJdE2lvB5tBLQUqcX182HIXTNYQQ,5721
6
+ tests/test_agent_type.py,sha256=WNUwyUxC431BTtQPSfKpG42IxsPnexdbXQTM3P6itBk,5085
7
+ tests/test_api_endpoint.py,sha256=I2UDamPMSLLkgw0pZ5QMM0o_8vVga9-F6ql-S3zlMBs,5136
8
+ tests/test_bedrock.py,sha256=lXIHGtH0otjOqCkCSnanEUM6HavSkbail1900drfJiU,1358
9
+ tests/test_fallback.py,sha256=6wkyiyAvsibIdr33aXdsuU9nzDeJt0XSz5yiyuisUEQ,2963
10
+ tests/test_gemini.py,sha256=ksHd8JA7ZMuzs8W40Fb4RBoen1rniXDghSfQImw_3nk,3016
11
+ tests/test_groq.py,sha256=m6HpJEeqmDQqYCQwg9_bCyGJ3ek1tK-aLBktxgRGGJ0,1346
12
+ tests/test_private_llm.py,sha256=P6sldeAWcHg29u_Nu4FdHVUyNaRe5ULE-hjNJz6WKHc,2620
13
+ tests/test_return_direct.py,sha256=QsCw-ZGp06cutLkyrLh1U1rggoH7iBiFz4SQ9MIx-Xk,1521
14
+ tests/test_serialization.py,sha256=CsW7qEXgGE24oEqo85c-GEbzn_mZjbF3er_juL9JbF8,4896
15
+ tests/test_streaming.py,sha256=e_XztBLCWf39HgfN1zsUz_vFNblzmMC2zfYHB8JM-zQ,2795
16
+ tests/test_tools.py,sha256=869Fl54kmLc44ijykO2QpfcXyAWLDqJ9Niq3XNzhzv8,13621
17
+ tests/test_vectara_llms.py,sha256=H1M9OaDvD8_GCFRBm6IdvWejYKn-zm3-Rzt_noCBbiQ,2496
18
+ tests/test_vhc.py,sha256=oDZzx1AdtDO0K5MHpzrCegw7wfc3h9E0V7boVFoMWXs,1945
19
+ tests/test_workflow.py,sha256=FXUM4hKh-La9FRJD0ir2sOiXsvkDFe2kI0r1faRAlMc,3873
20
+ vectara_agentic/__init__.py,sha256=CfS3QR4drKygcTcyH5zUUDuXXQ3WZtTCytz8W4-loeE,1077
21
+ vectara_agentic/_callback.py,sha256=ueckIfLNa9ykmmEyLqrrZwfDNWrEfyZzJeWktpnkwJQ,12970
22
+ vectara_agentic/_observability.py,sha256=c_1WuP8rS9sPuMH6twzcz6CGLqfTT5y4fyOHvDVdxsg,4423
23
+ vectara_agentic/_version.py,sha256=tSVqctgqLCPSvb0zkh8BNhEaR1d92yEJqmdCvwJzdKQ,65
24
+ vectara_agentic/agent.py,sha256=ga-8Flc01EX6xUhEx-MHArjb8bUeAYlRK_cKioihxdk,38667
25
+ vectara_agentic/agent_config.py,sha256=njqEX2qHJjAp2KpNuJglgZhyWXPK74wjIjBPACD6w7w,4074
26
+ vectara_agentic/agent_endpoint.py,sha256=E_AF-YwxaKqd1-p43X62e1e4ugwOWKIyNq4RWOfsO7A,7402
27
+ vectara_agentic/db_tools.py,sha256=nVZkpGdG63ooGngjX9g7YWyBZRtYMDpvzNasbO696nM,11498
28
+ vectara_agentic/llm_utils.py,sha256=s0g04lqQkX27njAKPAM-H0ZFEmohaC0VO7hs_ByaGaQ,7460
29
+ vectara_agentic/sub_query_workflow.py,sha256=wm2Lb2wbKrYx5bSq-npb3XbaxWzTcvK5BkW3NZ9vuIc,12968
30
+ vectara_agentic/tool_utils.py,sha256=whnQlk9coeIt01sqUnKnzUorefgn96yWqhtRfHxNL84,25921
31
+ vectara_agentic/tools.py,sha256=8gmC6UnHFTUr_hWWbuMyRNMMLkeY5Sb1FTgCsb7Hx1w,35689
32
+ vectara_agentic/tools_catalog.py,sha256=p6eRram-diJyMz5dZI703auSAm97FfW5wLAMyz_2sB0,4634
33
+ vectara_agentic/types.py,sha256=V04L8Man79qI9SmnKhlR3verJjm7yhcEE1RHPq9ADpc,5580
34
+ vectara_agentic/utils.py,sha256=R9HitEG5K3Q_p2M_teosT181OUxkhs1-hnj98qDYGbE,2545
35
+ vectara_agentic/agent_core/__init__.py,sha256=R3KGbSOiY21FOjbeQ_GyIi6uR9Rz7PTfudO9RjSuEZQ,722
36
+ vectara_agentic/agent_core/factory.py,sha256=yIoA-GumyuoUu-tmfAp79v2kAujUj7D7a7d5vx3_kj8,17697
37
+ vectara_agentic/agent_core/prompts.py,sha256=JGyAyZyLd__hTuEeBBuCHFdIS1nTIQJZJPGbxRpxY7A,9414
38
+ vectara_agentic/agent_core/serialization.py,sha256=Kxa7irtaeOhw2NbPpPkT3R7rKe-imx13XCL1V63eRqI,11634
39
+ vectara_agentic/agent_core/streaming.py,sha256=0mN5qpDP9evXOG_vj65GINhmUkbSQsWmGUsVDkNVPFE,18134
40
+ vectara_agentic/agent_core/utils/__init__.py,sha256=kLdT0Idw0xhT1zOJIhx13T4qsWh01O3taNC7aN2SEI4,958
41
+ vectara_agentic/agent_core/utils/hallucination.py,sha256=KG-ELY9ZzCwBjj4KMyncPkgvEg190Pw2D612O9fHE-Q,7037
42
+ vectara_agentic/agent_core/utils/logging.py,sha256=-Ll8iUelml92WuhNWScuY6H-RheyZOTBHNxXQ1UGy0M,1701
43
+ vectara_agentic/agent_core/utils/prompt_formatting.py,sha256=C0WqmSHZ-r_asRi2mkMsFOlqrOVrmADqNudidS6CU3s,1801
44
+ vectara_agentic/agent_core/utils/schemas.py,sha256=e7xhJBevgK7IM8cRT5hoO67T-Ep_FhNGp72Zo0OC_Jo,2853
45
+ vectara_agentic/agent_core/utils/tools.py,sha256=k9Gm-UUQ3ZeGxrkjyrjmjcGxOkvnpylcm_Krnr-0fsY,4748
46
+ vectara_agentic-0.4.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
47
+ vectara_agentic-0.4.0.dist-info/METADATA,sha256=BAILIhLZFOZAo71UTsWlzDPnUGfmq8nhJDRfAwzEgEc,33857
48
+ vectara_agentic-0.4.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
49
+ vectara_agentic-0.4.0.dist-info/top_level.txt,sha256=Y7TQTFdOYGYodQRltUGRieZKIYuzeZj2kHqAUpfCUfg,22
50
+ vectara_agentic-0.4.0.dist-info/RECORD,,
@@ -1,64 +0,0 @@
1
- import unittest
2
-
3
- from vectara_agentic.agent_config import AgentConfig
4
- from vectara_agentic.agent import Agent
5
- from vectara_agentic.tools import VectaraToolFactory
6
-
7
- # SETUP special test account credentials for vectara
8
- # It's okay to expose these credentials in the test code
9
- vectara_corpus_key = "vectara-docs_1"
10
- vectara_api_key = 'zqt_UXrBcnI2UXINZkrv4g1tQPhzj02vfdtqYJIDiA'
11
-
12
- vec_factory = VectaraToolFactory(vectara_api_key=vectara_api_key,
13
- vectara_corpus_key=vectara_corpus_key)
14
- summarizer = 'vectara-summary-table-md-query-ext-jan-2025-gpt-4o'
15
- ask_vectara = vec_factory.create_rag_tool(
16
- tool_name = "ask_vectara",
17
- tool_description = "This tool can respond to questions about Vectara.",
18
- reranker = "multilingual_reranker_v1", rerank_k = 100, rerank_cutoff = 0.1,
19
- n_sentences_before = 2, n_sentences_after = 2, lambda_val = 0.005,
20
- summary_num_results = 10,
21
- vectara_summarizer = summarizer,
22
- include_citations = True,
23
- verbose=False,
24
- )
25
-
26
- class TestAgentPlanningPackage(unittest.TestCase):
27
-
28
- def test_no_planning(self):
29
- tools = [ask_vectara]
30
- topic = "vectara"
31
- instructions = "Answer user queries about Vectara."
32
-
33
- query = "What is Vectara and what demos are available of the Vectara platform?"
34
- agent = Agent(
35
- tools=tools,
36
- topic=topic,
37
- custom_instructions=instructions,
38
- agent_config=AgentConfig(),
39
- )
40
- res = agent.chat(query)
41
- self.assertIn("demos", res.response)
42
- self.assertIn("Vectara", res.response)
43
-
44
- def test_structured_planning(self):
45
- tools = [ask_vectara]
46
- topic = "vectara"
47
- instructions = "Answer user queries about Vectara."
48
-
49
- query = "What is Vectara and what demos are available of the Vectara platform?"
50
- agent = Agent(
51
- tools=tools,
52
- topic=topic,
53
- custom_instructions=instructions,
54
- agent_config=AgentConfig(),
55
- use_structured_planning=True,
56
- )
57
-
58
- res = agent.chat(query)
59
- self.assertIn("demos", res.response)
60
- self.assertIn("Vectara", res.response)
61
-
62
-
63
- if __name__ == "__main__":
64
- unittest.main()
tests/test_hhem.py DELETED
@@ -1,100 +0,0 @@
1
- import unittest
2
-
3
- from vectara_agentic.agent import Agent, AgentType
4
- from vectara_agentic.agent_config import AgentConfig
5
- from vectara_agentic.tools import ToolsFactory, VectaraToolFactory
6
- from vectara_agentic.types import ModelProvider
7
-
8
- import nest_asyncio
9
-
10
- nest_asyncio.apply()
11
-
12
- vectara_corpus_key = "vectara-docs_1"
13
- vectara_api_key = 'zqt_UXrBcnI2UXINZkrv4g1tQPhzj02vfdtqYJIDiA'
14
-
15
- vec_factory = VectaraToolFactory(vectara_api_key=vectara_api_key,
16
- vectara_corpus_key=vectara_corpus_key)
17
- summarizer = 'vectara-summary-table-md-query-ext-jan-2025-gpt-4o'
18
- ask_vectara = vec_factory.create_rag_tool(
19
- tool_name = "ask_vectara",
20
- tool_description = "This tool can respond to questions about Vectara.",
21
- reranker = "multilingual_reranker_v1", rerank_k = 100, rerank_cutoff = 0.1,
22
- n_sentences_before = 2, n_sentences_after = 2, lambda_val = 0.005,
23
- summary_num_results = 10,
24
- vectara_summarizer = summarizer,
25
- include_citations = True,
26
- verbose=False,
27
- )
28
-
29
-
30
- statements = [
31
- "The sky is blue.",
32
- "Cats are better than dogs.",
33
- "Python is a great programming language.",
34
- "The Earth revolves around the Sun.",
35
- "Chocolate is the best ice cream flavor.",
36
- ]
37
- st_inx = 0
38
- def get_statement() -> str:
39
- "Generate next statement"
40
- global st_inx
41
- st = statements[st_inx]
42
- st_inx += 1
43
- return st
44
-
45
-
46
- fc_config = AgentConfig(
47
- agent_type=AgentType.FUNCTION_CALLING,
48
- main_llm_provider=ModelProvider.ANTHROPIC,
49
- tool_llm_provider=ModelProvider.ANTHROPIC,
50
- )
51
-
52
-
53
- class TestFCS(unittest.TestCase):
54
-
55
- def test_fcs(self):
56
- tools = [ToolsFactory().create_tool(get_statement)]
57
- topic = "statements"
58
- instructions = (
59
- f"Call the get_statement tool multiple times to get all {len(statements)} statements."
60
- f"Respond to the user question based exclusively on the statements you receive - do not use any other knowledge or information."
61
- )
62
-
63
- agent = Agent(
64
- tools=tools,
65
- topic=topic,
66
- agent_config=fc_config,
67
- custom_instructions=instructions,
68
- vectara_api_key=vectara_api_key,
69
- )
70
-
71
- res = agent.chat("Are cats better than dogs?")
72
- fcs = res.metadata.get("fcs", None)
73
- self.assertIsNotNone(fcs, "FCS score should not be None")
74
- self.assertIsInstance(fcs, float, "FCS score should be a float")
75
- self.assertGreater(
76
- fcs, 0.5, "FCS score should be higher than 0.5 for this question"
77
- )
78
-
79
- def test_vectara_corpus(self):
80
- tools = [ask_vectara]
81
- topic = "vectara"
82
- instructions = "Answer user queries about Vectara."
83
-
84
- query = "What is Vectara and what API endpoints are available of the Vectara platform?"
85
- agent = Agent(
86
- tools=tools,
87
- topic=topic,
88
- custom_instructions=instructions,
89
- agent_config=AgentConfig(),
90
- vectara_api_key=vectara_api_key,
91
- )
92
-
93
- res = agent.chat(query)
94
- fcs = res.metadata.get("fcs", None)
95
- self.assertIn("Vectara", res.response)
96
- self.assertGreater(fcs, 0.5, "FCS score should be higher than 0.5 for this question")
97
-
98
-
99
- if __name__ == "__main__":
100
- unittest.main()
vectara_agentic/hhem.py DELETED
@@ -1,82 +0,0 @@
1
- """Vectara HHEM (Hypothesis Hypothetical Evaluation Model) client."""
2
-
3
- import requests
4
- from commonmark import Parser
5
-
6
-
7
- def markdown_to_text(md: str) -> str:
8
- """
9
- Convert a Markdown-formatted string into plain text.
10
- """
11
- parser = Parser()
12
- ast = parser.parse(md)
13
- out: list[str] = []
14
-
15
- def recurse(node):
16
- if node.t in ("text", "code", "html_inline"):
17
- out.append(node.literal or "")
18
- elif node.t == "softbreak":
19
- out.append(" ")
20
- elif node.t == "linebreak":
21
- out.append("\n")
22
- child = getattr(node, "first_child", None)
23
- while child is not None:
24
- recurse(child)
25
- child = getattr(child, "next", None)
26
-
27
- recurse(ast)
28
- text = "".join(out)
29
- # collapse runs of spaces but preserve newlines
30
- lines = [" ".join(line.split()) for line in text.splitlines()]
31
- return "\n".join(line if line.strip() else "" for line in lines)
32
-
33
-
34
- class HHEM:
35
- """Vectara HHEM (Hypothesis Hypothetical Evaluation Model) client."""
36
-
37
- def __init__(self, vectara_api_key: str):
38
- self._vectara_api_key = vectara_api_key
39
-
40
- def compute(self, context: str, hypothesis: str) -> float:
41
- """
42
- Calls the Vectara HHEM endpoint to evaluate the factual consistency of a hypothesis against a given context.
43
-
44
- Parameters:
45
- context (str): The source text against which the hypothesis will be evaluated.
46
- hypothesis (str): The generated text to be evaluated for factual consistency.
47
-
48
- Returns:
49
- float: The factual consistency score rounded to four decimal places.
50
-
51
- Raises:
52
- requests.exceptions.RequestException: If there is a network-related error or the API call fails.
53
- """
54
-
55
- # clean response from any markdown or other formatting.
56
- try:
57
- clean_hypothesis = markdown_to_text(hypothesis)
58
- except Exception as e:
59
- # If markdown parsing fails, use the original text
60
- raise ValueError(f"Markdown parsing of hypothesis failed: {e}") from e
61
-
62
- # compute HHEM with Vectara endpoint
63
- payload = {
64
- "model_parameters": {"model_name": "hhem_v2.3"},
65
- "generated_text": clean_hypothesis,
66
- "source_texts": [context],
67
- }
68
- headers = {
69
- "Content-Type": "application/json",
70
- "Accept": "application/json",
71
- "x-api-key": self._vectara_api_key,
72
- }
73
-
74
- response = requests.post(
75
- "https://api.vectara.io/v2/evaluate_factual_consistency",
76
- json=payload,
77
- headers=headers,
78
- timeout=30,
79
- )
80
- response.raise_for_status()
81
- data = response.json()
82
- return round(data.get("score", 0.0), 4)
@@ -1,39 +0,0 @@
1
- tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- tests/endpoint.py,sha256=frnpdZQpnuQNNKNYgAn2rFTarNG8MCJaNA77Bw_W22A,1420
3
- tests/test_agent.py,sha256=4aRDhEVM1zARpSOevPR8PFGTkIaSw5g5WvoQDx-4sns,5496
4
- tests/test_agent_planning.py,sha256=JwEebGooROAvsQ9JZoaH6KEcrSyv1F0lL4TD4FjP8a8,2213
5
- tests/test_agent_type.py,sha256=9ZImIDw7Qz5EV2tX8bDD0tT1IFYghS3-SShpAezHO7s,7381
6
- tests/test_api_endpoint.py,sha256=M9YGFCy_Jphzq9JznP4ftHqxZ_yu6dgWdX1jRvdsORA,5002
7
- tests/test_bedrock.py,sha256=23A5_2FRaEl47PzgfUPDL6dgFDPJ9iktz-A-B1UwIhg,1224
8
- tests/test_fallback.py,sha256=M5YD7NHZ0joVU1frYIr9_OiRAIje5mrXrYVcekzlyGs,2829
9
- tests/test_gemini.py,sha256=QUBYWhZkX9AjnhPn5qa7sREf6YHZWeJEmYzKwVC23Io,4081
10
- tests/test_groq.py,sha256=5yTlOLwpzGRmiBPExAuulK6SEO9O13cMJWVSSHX9CsE,1212
11
- tests/test_hhem.py,sha256=XFUX3x0xOa9QsafzYNP8_ZsvzIiLnWee4hdsowzHft8,3250
12
- tests/test_private_llm.py,sha256=-bQBI69Z-SwhhQJGzyC9GGM4kz5c6T5kAbXLbqn_G7E,2248
13
- tests/test_return_direct.py,sha256=mgj1xJnvOX28aaidhZfH2DaI-kM0yfQ0P1PNV0iyLcw,1405
14
- tests/test_serialization.py,sha256=Ed23GN2zhSJNdPFrVK4aqLkOhJKviczR_o0t-r9TuRI,4762
15
- tests/test_tools.py,sha256=bhhq49I3eEJyuNf5FU7M9IxPT0XtwRbRTs3gwoBHihk,17128
16
- tests/test_vectara_llms.py,sha256=gw5KQ4XT3L-_A6yj2jKqj-QomCjOb9VESKBtBH2Xb8s,2362
17
- tests/test_workflow.py,sha256=TmNBxBqSW5owk_Nz9LLtHvqryVNsFPkf-M1G_uFSsAM,3739
18
- vectara_agentic/__init__.py,sha256=2GLDS3U6KckK-dBRl9v_x1kSV507gEhjOfuMmmu0Qxg,850
19
- vectara_agentic/_callback.py,sha256=c3848EMSpaQWXtuwdqRGbhgbZhiDwgGnemJkgm9yWAc,13238
20
- vectara_agentic/_observability.py,sha256=iZlByeQTyx6g3Y8aBYcdGcxdRkoYrfxHdcrTEKO26UE,4485
21
- vectara_agentic/_prompts.py,sha256=9s8VEjaaLuRgNK1xQYWj4bnjM4asJP1Z5zCihUMRonk,10768
22
- vectara_agentic/_version.py,sha256=T5R4By43ti-oVkkFCfZWO1IEj2YgvFsppQ4MOX0xo2s,65
23
- vectara_agentic/agent.py,sha256=zu7nMxhKin3rLuV8y4F_OcssU3R8bJOjMixKMC_P2k0,58857
24
- vectara_agentic/agent_config.py,sha256=E-rtYMcpoGxnEAyy8231bizo2n0uGQ2qWxuSgTEfwdQ,4327
25
- vectara_agentic/agent_endpoint.py,sha256=PzIN7HhEHv8Mq_Zo5cZ2xYrgdv2AN6kx6dc_2AJq28I,7497
26
- vectara_agentic/db_tools.py,sha256=GUsQTZfRbT9F5K_e5HNaKXUkU6x8RErUyjDVKlZi1IA,11196
27
- vectara_agentic/hhem.py,sha256=j4euBX24PSCQ8P_MhhsKKnm1kv6nHKAbduHsTwtQuR0,2774
28
- vectara_agentic/llm_utils.py,sha256=TX01e4QY8qb5O5D6ZrlkLZEZFHJ4LbDL6g-l52lTB40,7561
29
- vectara_agentic/sub_query_workflow.py,sha256=JYwN0wK4QzHjTaFDsSCAQvMx9GD4g6CnqxZCnzi6xb4,13086
30
- vectara_agentic/tool_utils.py,sha256=9xoqVPB97CIDXOxuFIw4yZ2RlXvdayCEGPUaUPC2Tbc,24168
31
- vectara_agentic/tools.py,sha256=LvUUD4gLYoL68gx8Lnr1GoECyC0wd0ahPyOhoW5ouws,35478
32
- vectara_agentic/tools_catalog.py,sha256=cAN_kDOWZUoW4GNFwY5GdS6ImMUQNnF2sggx9OGK9Cg,4906
33
- vectara_agentic/types.py,sha256=3mrtshHiy-d5JHVxl-4tJk5DRspvYKwAYiI5LvKO1Bw,2226
34
- vectara_agentic/utils.py,sha256=R9HitEG5K3Q_p2M_teosT181OUxkhs1-hnj98qDYGbE,2545
35
- vectara_agentic-0.3.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
36
- vectara_agentic-0.3.3.dist-info/METADATA,sha256=aWqHgdQi_bbBUO4YgPg8Cd0E4UP3gv5setaJsm23lW0,32079
37
- vectara_agentic-0.3.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
38
- vectara_agentic-0.3.3.dist-info/top_level.txt,sha256=Y7TQTFdOYGYodQRltUGRieZKIYuzeZj2kHqAUpfCUfg,22
39
- vectara_agentic-0.3.3.dist-info/RECORD,,