vectara-agentic 0.1.24__py3-none-any.whl → 0.1.26__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.

@@ -2,11 +2,15 @@
2
2
  This module contains the tools catalog for the Vectara Agentic.
3
3
  """
4
4
  from typing import List
5
- from functools import lru_cache
6
- from pydantic import Field
5
+ from datetime import date
6
+
7
+ from inspect import signature
7
8
  import requests
8
9
 
10
+ from pydantic import Field
11
+
9
12
  from .types import LLMRole
13
+ from .agent_config import AgentConfig
10
14
  from .utils import get_llm
11
15
 
12
16
  req_session = requests.Session()
@@ -19,98 +23,120 @@ get_headers = {
19
23
  "Connection": "keep-alive",
20
24
  }
21
25
 
22
-
23
- #
24
- # Standard Tools
25
- #
26
- @lru_cache(maxsize=None)
27
- def summarize_text(
28
- text: str = Field(description="the original text."),
29
- expertise: str = Field(
30
- description="the expertise to apply to the summarization.",
31
- ),
32
- ) -> str:
33
- """
34
- This is a helper tool.
35
- Use this tool to summarize text using a given expertise
36
- with no more than summary_max_length characters.
37
-
38
- Args:
39
- text (str): The original text.
40
- expertise (str): The expertise to apply to the summarization.
41
-
42
- Returns:
43
- str: The summarized text.
26
+ def get_current_date() -> str:
44
27
  """
45
- if not isinstance(expertise, str):
46
- return "Please provide a valid string for expertise."
47
- if not isinstance(text, str):
48
- return "Please provide a valid string for text."
49
- expertise = "general" if len(expertise) < 3 else expertise.lower()
50
- prompt = f"As an expert in {expertise}, summarize the provided text"
51
- prompt += " into a concise summary."
52
- prompt += f"\noriginal text: {text}\nsummary:"
53
- llm = get_llm(LLMRole.TOOL)
54
- response = llm.complete(prompt)
55
- return response.text
56
-
57
-
58
- @lru_cache(maxsize=None)
59
- def rephrase_text(
60
- text: str = Field(description="the original text."),
61
- instructions: str = Field(description="the specific instructions for how to rephrase the text."),
62
- ) -> str:
28
+ Returns: the current date.
63
29
  """
64
- This is a helper tool.
65
- Use this tool to rephrase the text according to the provided instructions.
66
- For example, instructions could be "as a 5 year old would say it."
30
+ return date.today().strftime("%A, %B %d, %Y")
67
31
 
68
- Args:
69
- text (str): The original text.
70
- instructions (str): The specific instructions for how to rephrase the text.
71
-
72
- Returns:
73
- str: The rephrased text.
74
- """
75
- prompt = f"""
76
- Rephrase the provided text according to the following instructions: {instructions}.
77
- If the input is Markdown, keep the output in Markdown as well.
78
- original text: {text}
79
- rephrased text:
80
- """
81
- llm = get_llm(LLMRole.TOOL)
82
- response = llm.complete(prompt)
83
- return response.text
84
32
 
33
+ def remove_self_from_signature(func):
34
+ """Decorator to remove 'self' from a method's signature for introspection."""
35
+ sig = signature(func)
36
+ params = list(sig.parameters.values())
37
+ # Remove the first parameter if it is named 'self'
38
+ if params and params[0].name == "self":
39
+ params = params[1:]
40
+ new_sig = sig.replace(parameters=params)
41
+ func.__signature__ = new_sig
42
+ return func
85
43
 
86
- @lru_cache(maxsize=None)
87
- def critique_text(
88
- text: str = Field(description="the original text."),
89
- role: str = Field(default=None, description="the role of the person providing critique."),
90
- point_of_view: str = Field(default=None, description="the point of view with which to provide critique."),
91
- ) -> str:
44
+ class ToolsCatalog:
92
45
  """
93
- This is a helper tool.
94
- Critique the text from the specified point of view.
95
-
96
- Args:
97
- text (str): The original text.
98
- role (str): The role of the person providing critique.
99
- point_of_view (str): The point of view with which to provide critique.
100
-
101
- Returns:
102
- str: The critique of the text.
46
+ A curated set of tools for vectara-agentic
103
47
  """
104
- if role:
105
- prompt = f"As a {role}, critique the provided text from the point of view of {point_of_view}."
106
- else:
107
- prompt = f"Critique the provided text from the point of view of {point_of_view}."
108
- prompt += "Structure the critique as bullet points.\n"
109
- prompt += f"Original text: {text}\nCritique:"
110
- llm = get_llm(LLMRole.TOOL)
111
- response = llm.complete(prompt)
112
- return response.text
113
-
48
+ def __init__(self, agent_config: AgentConfig):
49
+ self.agent_config = agent_config
50
+
51
+ @remove_self_from_signature
52
+ def summarize_text(
53
+ self,
54
+ text: str = Field(description="the original text."),
55
+ expertise: str = Field(
56
+ description="the expertise to apply to the summarization.",
57
+ ),
58
+ ) -> str:
59
+ """
60
+ This is a helper tool.
61
+ Use this tool to summarize text using a given expertise
62
+ with no more than summary_max_length characters.
63
+
64
+ Args:
65
+ text (str): The original text.
66
+ expertise (str): The expertise to apply to the summarization.
67
+
68
+ Returns:
69
+ str: The summarized text.
70
+ """
71
+ if not isinstance(expertise, str):
72
+ return "Please provide a valid string for expertise."
73
+ if not isinstance(text, str):
74
+ return "Please provide a valid string for text."
75
+ expertise = "general" if len(expertise) < 3 else expertise.lower()
76
+ prompt = (
77
+ f"As an expert in {expertise}, summarize the provided text "
78
+ "into a concise summary.\n"
79
+ f"Original text: {text}\nSummary:"
80
+ )
81
+ llm = get_llm(LLMRole.TOOL, config=self.agent_config)
82
+ response = llm.complete(prompt)
83
+ return response.text
84
+
85
+ @remove_self_from_signature
86
+ def rephrase_text(
87
+ self,
88
+ text: str = Field(description="the original text."),
89
+ instructions: str = Field(description="the specific instructions for how to rephrase the text."),
90
+ ) -> str:
91
+ """
92
+ This is a helper tool.
93
+ Use this tool to rephrase the text according to the provided instructions.
94
+ For example, instructions could be "as a 5 year old would say it."
95
+
96
+ Args:
97
+ text (str): The original text.
98
+ instructions (str): The specific instructions for how to rephrase the text.
99
+
100
+ Returns:
101
+ str: The rephrased text.
102
+ """
103
+ prompt = (
104
+ f"Rephrase the provided text according to the following instructions: {instructions}.\n"
105
+ "If the input is Markdown, keep the output in Markdown as well.\n"
106
+ f"Original text: {text}\nRephrased text:"
107
+ )
108
+ llm = get_llm(LLMRole.TOOL, config=self.agent_config)
109
+ response = llm.complete(prompt)
110
+ return response.text
111
+
112
+ @remove_self_from_signature
113
+ def critique_text(
114
+ self,
115
+ text: str = Field(description="the original text."),
116
+ role: str = Field(default=None, description="the role of the person providing critique."),
117
+ point_of_view: str = Field(default=None, description="the point of view with which to provide critique."),
118
+ ) -> str:
119
+ """
120
+ This is a helper tool.
121
+ Critique the text from the specified point of view.
122
+
123
+ Args:
124
+ text (str): The original text.
125
+ role (str): The role of the person providing critique.
126
+ point_of_view (str): The point of view with which to provide critique.
127
+
128
+ Returns:
129
+ str: The critique of the text.
130
+ """
131
+ if role:
132
+ prompt = f"As a {role}, critique the provided text from the point of view of {point_of_view}."
133
+ else:
134
+ prompt = f"Critique the provided text from the point of view of {point_of_view}."
135
+ prompt += "\nStructure the critique as bullet points.\n"
136
+ prompt += f"Original text: {text}\nCritique:"
137
+ llm = get_llm(LLMRole.TOOL, config=self.agent_config)
138
+ response = llm.complete(prompt)
139
+ return response.text
114
140
 
115
141
  #
116
142
  # Guardrails tool: returns list of topics to avoid
vectara_agentic/types.py CHANGED
@@ -3,6 +3,9 @@ This module contains the types used in the Vectara Agentic.
3
3
  """
4
4
  from enum import Enum
5
5
 
6
+ from llama_index.core.tools.types import ToolOutput as LI_ToolOutput
7
+ from llama_index.core.chat_engine.types import AgentChatResponse as LI_AgentChatResponse
8
+ from llama_index.core.chat_engine.types import StreamingAgentChatResponse as LI_StreamingAgentChatResponse
6
9
 
7
10
  class AgentType(Enum):
8
11
  """Enumeration for different types of agents."""
@@ -29,6 +32,7 @@ class ModelProvider(Enum):
29
32
  FIREWORKS = "FIREWORKS"
30
33
  COHERE = "COHERE"
31
34
  GEMINI = "GEMINI"
35
+ BEDROCK = "BEDROCK"
32
36
 
33
37
 
34
38
  class AgentStatusType(Enum):
@@ -51,3 +55,9 @@ class ToolType(Enum):
51
55
  """Enumeration for different types of tools."""
52
56
  QUERY = "query"
53
57
  ACTION = "action"
58
+
59
+
60
+ # classes for Agent responses
61
+ ToolOutput = LI_ToolOutput
62
+ AgentResponse = LI_AgentChatResponse
63
+ AgentStreamingResponse = LI_StreamingAgentChatResponse
vectara_agentic/utils.py CHANGED
@@ -20,6 +20,7 @@ provider_to_default_model_name = {
20
20
  ModelProvider.TOGETHER: "meta-llama/Llama-3.3-70B-Instruct-Turbo",
21
21
  ModelProvider.GROQ: "llama-3.3-70b-versatile",
22
22
  ModelProvider.FIREWORKS: "accounts/fireworks/models/firefunction-v2",
23
+ ModelProvider.BEDROCK: "anthropic.claude-3-5-sonnet-20241022-v2:0",
23
24
  ModelProvider.COHERE: "command-r-plus",
24
25
  ModelProvider.GEMINI: "models/gemini-1.5-flash",
25
26
  }
@@ -105,6 +106,9 @@ def get_llm(
105
106
  elif model_provider == ModelProvider.FIREWORKS:
106
107
  from llama_index.llms.fireworks import Fireworks
107
108
  llm = Fireworks(model=model_name, temperature=0)
109
+ elif model_provider == ModelProvider.BEDROCK:
110
+ from llama_index.llms.bedrock import Bedrock
111
+ llm = Bedrock(model=model_name, temperature=0)
108
112
  elif model_provider == ModelProvider.COHERE:
109
113
  from llama_index.llms.cohere import Cohere
110
114
  llm = Cohere(model=model_name, temperature=0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: vectara_agentic
3
- Version: 0.1.24
3
+ Version: 0.1.26
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,39 +16,39 @@ 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.7
19
+ Requires-Dist: llama-index==0.12.11
20
20
  Requires-Dist: llama-index-indices-managed-vectara==0.3.1
21
21
  Requires-Dist: llama-index-agent-llm-compiler==0.3.0
22
22
  Requires-Dist: llama-index-agent-lats==0.3.0
23
- Requires-Dist: llama-index-agent-openai==0.4.1
24
- Requires-Dist: llama-index-llms-openai==0.3.12
25
- Requires-Dist: llama-index-llms-anthropic==0.6.3
23
+ Requires-Dist: llama-index-agent-openai==0.4.3
24
+ Requires-Dist: llama-index-llms-openai==0.3.18
25
+ Requires-Dist: llama-index-llms-anthropic==0.6.4
26
26
  Requires-Dist: llama-index-llms-together==0.3.1
27
27
  Requires-Dist: llama-index-llms-groq==0.3.1
28
- Requires-Dist: llama-index-llms-fireworks==0.3.0
28
+ Requires-Dist: llama-index-llms-fireworks==0.3.1
29
29
  Requires-Dist: llama-index-llms-cohere==0.4.0
30
- Requires-Dist: llama-index-llms-gemini==0.4.2
30
+ Requires-Dist: llama-index-llms-gemini==0.4.4
31
+ Requires-Dist: llama-index-llms-bedrock==0.3.3
31
32
  Requires-Dist: llama-index-tools-yahoo-finance==0.3.0
32
33
  Requires-Dist: llama-index-tools-arxiv==0.3.0
33
34
  Requires-Dist: llama-index-tools-database==0.3.0
34
35
  Requires-Dist: llama-index-tools-google==0.3.0
35
36
  Requires-Dist: llama-index-tools-tavily_research==0.3.0
36
37
  Requires-Dist: llama-index-tools-neo4j==0.3.0
37
- Requires-Dist: llama-index-graph-stores-kuzu==0.5.0
38
+ Requires-Dist: llama-index-graph-stores-kuzu==0.6.0
38
39
  Requires-Dist: llama-index-tools-slack==0.3.0
39
40
  Requires-Dist: llama-index-tools-exa==0.3.0
40
41
  Requires-Dist: tavily-python==0.5.0
41
- Requires-Dist: exa-py==1.7.0
42
+ Requires-Dist: exa-py==1.8.5
42
43
  Requires-Dist: yahoo-finance==1.4.0
43
- Requires-Dist: openinference-instrumentation-llama-index==3.0.3
44
+ Requires-Dist: openinference-instrumentation-llama-index==3.1.4
44
45
  Requires-Dist: opentelemetry-proto==1.26.0
45
- Requires-Dist: arize-phoenix==5.7.0
46
+ Requires-Dist: arize-phoenix==7.11.0
46
47
  Requires-Dist: arize-phoenix-otel==0.6.1
47
48
  Requires-Dist: protobuf==4.25.5
48
49
  Requires-Dist: tokenizers>=0.20
49
- Requires-Dist: pydantic==2.9.2
50
+ Requires-Dist: pydantic==2.10.3
50
51
  Requires-Dist: retrying==1.3.4
51
- Requires-Dist: pymongo==4.10.1
52
52
  Requires-Dist: python-dotenv==1.0.1
53
53
  Requires-Dist: tiktoken==0.8.0
54
54
  Requires-Dist: dill>=0.3.7
@@ -87,7 +87,7 @@ Dynamic: summary
87
87
 
88
88
  ## ✨ Overview
89
89
 
90
- `vectara-agentic` is a Python library for developing powerful AI assistants and agents using Vectara and Agentic-RAG. It leverages the LlamaIndex Agent framework, customized for use with Vectara.
90
+ `vectara-agentic` is a Python library for developing powerful AI assistants and agents using Vectara and Agentic-RAG. It leverages the LlamaIndex Agent framework and provides helper functions to quickly create tools that connect to Vectara corpora.
91
91
 
92
92
  <p align="center">
93
93
  <img src="https://raw.githubusercontent.com/vectara/py-vectara-agentic/main/.github/assets/diagram1.png" alt="Agentic RAG diagram" width="100%" style="vertical-align: middle;">
@@ -96,10 +96,10 @@ Dynamic: summary
96
96
  ### Features
97
97
 
98
98
  - Enables easy creation of custom AI assistants and agents.
99
- - Create a Vectara RAG tool with a single line of code.
100
- - Supports `ReAct`, `OpenAIAgent`, `LATS' and `LLMCompiler` agent types.
99
+ - Create a Vectara RAG tool or search tool with a single line of code.
100
+ - Supports `ReAct`, `OpenAIAgent`, `LATS` and `LLMCompiler` agent types.
101
101
  - Includes pre-built tools for various domains (e.g., finance, legal).
102
- - Integrates with various LLM inference services like OpenAI, Anthropic, Gemini, GROQ, Together.AI, Cohere and Fireworks
102
+ - Integrates with various LLM inference services like OpenAI, Anthropic, Gemini, GROQ, Together.AI, Cohere, Bedrock and Fireworks
103
103
  - Built-in support for observability with Arize Phoenix
104
104
 
105
105
  ### 📚 Example AI Assistants
@@ -109,14 +109,14 @@ Check out our example AI assistants:
109
109
  - [Financial Assistant](https://huggingface.co/spaces/vectara/finance-chat)
110
110
  - [Justice Harvard Teaching Assistant](https://huggingface.co/spaces/vectara/Justice-Harvard)
111
111
  - [Legal Assistant](https://huggingface.co/spaces/vectara/legal-agent)
112
-
112
+ - [EV Assistant](https://huggingface.co/spaces/vectara/ev-assistant)
113
113
 
114
114
  ### Prerequisites
115
115
 
116
116
  - [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)
117
117
  - A Vectara corpus with an [API key](https://docs.vectara.com/docs/api-keys)
118
118
  - [Python 3.10 or higher](https://www.python.org/downloads/)
119
- - OpenAI API key (or API keys for Anthropic, TOGETHER.AI, Fireworks AI, Cohere, GEMINI or GROQ, if you choose to use them)
119
+ - OpenAI API key (or API keys for Anthropic, TOGETHER.AI, Fireworks AI, Bedrock, Cohere, GEMINI or GROQ, if you choose to use them)
120
120
 
121
121
  ### Installation
122
122
 
@@ -126,18 +126,25 @@ pip install vectara-agentic
126
126
 
127
127
  ## 🚀 Quick Start
128
128
 
129
- ### 1. Create a Vectara RAG tool
129
+ ### 1. Initialize the Vectara tool factory
130
130
 
131
131
  ```python
132
132
  import os
133
133
  from vectara_agentic.tools import VectaraToolFactory
134
- from pydantic import BaseModel, Field
135
134
 
136
135
  vec_factory = VectaraToolFactory(
137
136
  vectara_api_key=os.environ['VECTARA_API_KEY'],
138
137
  vectara_customer_id=os.environ['VECTARA_CUSTOMER_ID'],
139
138
  vectara_corpus_id=os.environ['VECTARA_CORPUS_ID']
140
139
  )
140
+ ```
141
+
142
+ ### 2. Create a Vectara RAG Tool
143
+
144
+ A RAG tool calls the full Vectara RAG pipeline to provide summarized responses to queries grounded in data.
145
+
146
+ ```python
147
+ from pydantic import BaseModel, Field
141
148
 
142
149
  years = list(range(2020, 2024))
143
150
  tickers = {
@@ -156,17 +163,22 @@ query_financial_reports_tool = vec_factory.create_rag_tool(
156
163
  tool_name="query_financial_reports",
157
164
  tool_description="Query financial reports for a company and year",
158
165
  tool_args_schema=QueryFinancialReportsArgs,
166
+ lambda_val=0.005,
167
+ summary_num_results=7,
168
+ # Additional arguments
159
169
  )
160
170
  ```
161
171
 
162
- ### 2. Create other tools (optional)
172
+ See the [docs](https://vectara.github.io/vectara-agentic-docs/) for additional arguments to customize your Vectara RAG tool.
173
+
174
+ ### 3. Create other tools (optional)
163
175
 
164
176
  In addition to RAG tools, you can generate a lot of other types of tools the agent can use. These could be mathematical tools, tools
165
177
  that call other APIs to get more information, or any other type of tool.
166
178
 
167
179
  See [Agent Tools](#agent-tools) for more information.
168
180
 
169
- ### 3. Create your agent
181
+ ### 4. Create your agent
170
182
 
171
183
  ```python
172
184
  from vectara_agentic import Agent
@@ -186,20 +198,89 @@ agent = Agent(
186
198
  )
187
199
  ```
188
200
 
189
- ### 4. Run your agent
201
+ See the [docs](https://vectara.github.io/vectara-agentic-docs/) for additional arguments, including `agent_progress_callback` and `query_logging_callback`.
202
+
203
+ ### 5. Run your agent
190
204
 
191
205
  ```python
192
- response = agent.chat("What was the revenue for Apple in 2021?")
193
- print(response)
206
+ res = agent.chat("What was the revenue for Apple in 2021?")
207
+ print(res.response)
208
+ ```
209
+
210
+ Note that:
211
+ 1. `vectara-agentic` also supports `achat()` and two streaming variants `stream_chat()` and `astream_chat()`.
212
+ 2. The response types from `chat()` and `achat()` are of type `AgentResponse`. If you just need the actual string
213
+ response it's available as the `response` variable, or just use `str()`. For advanced use-cases you can look
214
+ at other `AgentResponse` variables [such as `sources`](https://github.com/run-llama/llama_index/blob/659f9faaafbecebb6e6c65f42143c0bf19274a37/llama-index-core/llama_index/core/chat_engine/types.py#L53).
215
+
216
+ ## 🧰 Vectara tools
217
+
218
+ `vectara-agentic` provides two helper functions to connect with Vectara RAG
219
+ * `create_rag_tool()` to create an agent tool that connects with a Vectara corpus for querying.
220
+ * `create_search_tool()` to create a tool to search a Vectara corpus and return a list of matching documents.
221
+
222
+ See the documentation for the full list of arguments for `create_rag_tool()` and `create_search_tool()`,
223
+ to understand how to configure Vectara query performed by those tools.
224
+
225
+ ### Creating a Vectara RAG tool
226
+
227
+ A Vectara RAG tool is often the main workhorse for any Agentic RAG application, and enables the agent to query
228
+ one or more Vectara RAG corpora.
229
+
230
+ The tool generated always includes the `query` argument, followed by 1 or more optional arguments used for
231
+ metadata filtering, defined by `tool_args_schema`.
232
+
233
+ For example, in the quickstart example the schema is:
234
+
194
235
  ```
236
+ class QueryFinancialReportsArgs(BaseModel):
237
+ query: str = Field(..., description="The user query.")
238
+ year: int | str = Field(..., description=f"The year this query relates to. An integer between {min(years)} and {max(years)} or a string specifying a condition on the year (example: '>2020').")
239
+ ticker: str = Field(..., description=f"The company ticker. Must be a valid ticket symbol from the list {tickers.keys()}.")
240
+ ```
241
+
242
+ The `query` is required and is always the query string.
243
+ The other arguments are optional and will be interpreted as Vectara metadata filters.
195
244
 
196
- ## 🛠️ Agent Tools
245
+ For example, in the example above, the agent may call the `query_financial_reports_tool` tool with
246
+ query='what is the revenue?', year=2022 and ticker='AAPL'. Subsequently the RAG tool will issue
247
+ a Vectara RAG query with the same query, but with metadata filtering (doc.year=2022 and doc.ticker='AAPL').
248
+
249
+ There are also additional cool features supported here:
250
+ * An argument can be a condition, for example year='>2022' translates to the correct metadata
251
+ filtering condition doc.year>2022
252
+ * if `fixed_filter` is defined in the RAG tool, it provides a constant metadata filtering that is always applied.
253
+ For example, if fixed_filter=`doc.filing_type='10K'` then a query with query='what is the reveue', year=2022
254
+ and ticker='AAPL' would translate into query='what is the revenue' with metadata filtering condition of
255
+ "doc.year=2022 AND doc.ticker='AAPL' and doc.filing_type='10K'"
256
+
257
+ Note that `tool_args_type` is an optional dictionary that indicates the level at which metadata filtering
258
+ is applied for each argument (`doc` or `part`)
259
+
260
+ ### Creating a Vectara search tool
261
+
262
+ The Vectara search tool allows the agent to list documents that match a query.
263
+ This can be helpful to the agent to answer queries like "how many documents discuss the iPhone?" or other
264
+ similar queries that require a response in terms of a list of matching documents.
265
+
266
+ ## 🛠️ Agent Tools at a Glance
267
+
268
+ `vectara-agentic` provides a few tools out of the box (see ToolsCatalog for details):
197
269
 
198
- `vectara-agentic` provides a few tools out of the box:
199
270
  1. **Standard tools**:
200
271
  - `summarize_text`: a tool to summarize a long text into a shorter summary (uses LLM)
201
272
  - `rephrase_text`: a tool to rephrase a given text, given a set of rephrase instructions (uses LLM)
202
-
273
+ These tools use an LLM and so would use the `Tools` LLM specified in your `AgentConfig`.
274
+ To instantiate them:
275
+
276
+ ```python
277
+ from vectara_agentic.tools_catalog import ToolsCatalog
278
+ summarize_text = ToolsCatalog(agent_config).summarize_text
279
+ ```
280
+
281
+ This ensures the summarize_text tool is configured with the proper LLM provider and model as
282
+ specified in the Agent configuration.
283
+
203
284
  2. **Legal tools**: a set of tools for the legal vertical, such as:
204
285
  - `summarize_legal_text`: summarize legal text with a certain point of view
205
286
  - `critique_as_judge`: critique a legal text as a judge, providing their perspective
@@ -217,10 +298,9 @@ print(response)
217
298
  - `load_unique_values`: returns the top unique values for a given column
218
299
 
219
300
  In addition, we include various other tools from LlamaIndex ToolSpecs:
220
- * Tavily search
221
- * EXA.AI
301
+ * Tavily search and EXA.AI
222
302
  * arxiv
223
- * neo4j & Kuzu for Graph integration
303
+ * neo4j & Kuzu for Graph DB integration
224
304
  * Google tools (including gmail, calendar, and search)
225
305
  * Slack
226
306
 
@@ -237,19 +317,44 @@ mult_tool = ToolsFactory().create_tool(mult_func)
237
317
 
238
318
  ## 🛠️ Configuration
239
319
 
320
+ ## Configuring Vectara-agentic
321
+
240
322
  The main way to control the behavior of `vectara-agentic` is by passing an `AgentConfig` object to your `Agent` when creating it.
241
- This object will include the following items:
242
- - `VECTARA_AGENTIC_AGENT_TYPE`: valid values are `REACT`, `LLMCOMPILER`, `LATS` or `OPENAI` (default: `OPENAI`)
243
- - `VECTARA_AGENTIC_MAIN_LLM_PROVIDER`: valid values are `OPENAI`, `ANTHROPIC`, `TOGETHER`, `GROQ`, `COHERE`, `GEMINI` or `FIREWORKS` (default: `OPENAI`)
244
- - `VECTARA_AGENTIC_MAIN_MODEL_NAME`: agent model name (default depends on provider)
245
- - `VECTARA_AGENTIC_TOOL_LLM_PROVIDER`: tool LLM provider (default: `OPENAI`)
246
- - `VECTARA_AGENTIC_TOOL_MODEL_NAME`: tool model name (default depends on provider)
247
- - `VECTARA_AGENTIC_OBSERVER_TYPE`: valid values are `ARIZE_PHOENIX` or `NONE` (default: `NONE`)
248
- - `VECTARA_AGENTIC_API_KEY`: a secret key if using the API endpoint option (defaults to `dev-api-key`)
323
+ For example:
324
+
325
+ ```python
326
+ agent_config = AgentConfig(
327
+ agent_type = AgentType.REACT,
328
+ main_llm_provider = ModelProvider.ANTHROPIC,
329
+ main_llm_model_name = 'claude-3-5-sonnet-20241022',
330
+ tool_llm_provider = ModelProvider.TOGETHER,
331
+ tool_llm_model_name = 'meta-llama/Llama-3.3-70B-Instruct-Turbo'
332
+ )
333
+
334
+ agent = Agent(
335
+ tools=[query_financial_reports_tool],
336
+ topic="10-K financial reports",
337
+ custom_instructions="You are a helpful financial assistant in conversation with a user.",
338
+ agent_config=agent_config
339
+ )
340
+ ```
341
+
342
+ The `AgentConfig` object may include the following items:
343
+ - `agent_type`: the agent type. Valid values are `REACT`, `LLMCOMPILER`, `LATS` or `OPENAI` (default: `OPENAI`).
344
+ - `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`).
345
+ - `main_llm_model_name` and `tool_llm_model_name`: agent model name for agent and tools (default depends on provider).
346
+ - `observer`: the observer type; should be `ARIZE_PHOENIX` or if undefined no observation framework will be used.
347
+ - `endpoint_api_key`: a secret key if using the API endpoint option (defaults to `dev-api-key`)
249
348
 
250
349
  If any of these are not provided, `AgentConfig` first tries to read the values from the OS environment.
251
350
 
252
- When creating a `VectaraToolFactory`, you can pass in a `vectara_api_key`, `vectara_customer_id`, and `vectara_corpus_id` to the factory. If not passed in, it will be taken from the environment variables (`VECTARA_API_KEY`, `VECTARA_CUSTOMER_ID` and `VECTARA_CORPUS_ID`). Note that `VECTARA_CORPUS_ID` can be a single ID or a comma-separated list of IDs (if you want to query multiple corpora).
351
+ ## Configuring Vectara RAG or search tools
352
+
353
+ When creating a `VectaraToolFactory`, you can pass in a `vectara_api_key`, `vectara_customer_id`, and `vectara_corpus_id` to the factory.
354
+
355
+ If not passed in, it will be taken from the environment variables (`VECTARA_API_KEY`, `VECTARA_CUSTOMER_ID` and `VECTARA_CORPUS_ID`). Note that `VECTARA_CORPUS_ID` can be a single ID or a comma-separated list of IDs (if you want to query multiple corpora).
356
+
357
+ These values will be used as credentials when creating Vectara tools - in `create_rag_tool()` and `create_search_tool()`.
253
358
 
254
359
  ## ℹ️ Additional Information
255
360
 
@@ -0,0 +1,21 @@
1
+ tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ tests/test_agent.py,sha256=8LQlny0rIuVa13LGtebG0vatES6Ln7gmenbSwX-ctrY,4260
3
+ tests/test_tools.py,sha256=2ofZYz3Q-YMSxjpiEg1VNUlA9gMjvNAcJAO2Ucd0eVE,2969
4
+ vectara_agentic/__init__.py,sha256=ADH4fPKLbpGNYYYszv3c3QDOjPToPE_qh3LpkH_seCU,430
5
+ vectara_agentic/_callback.py,sha256=OBiHk_OJZTS3iKz_LigfEjnl_p5V90XYsQC0vEYVSPo,8782
6
+ vectara_agentic/_observability.py,sha256=HeQYJIkqPLW3EWHiXHatkaJzo08IQGESKujdeWTuRgk,3805
7
+ vectara_agentic/_prompts.py,sha256=mgGx3zUJPtpS1epBLtl0BnoLeE7wb6AX1SX6dFNaTTQ,6368
8
+ vectara_agentic/_version.py,sha256=Fg_mimtI4WLCh87AZhsbvuJjEepRJHslbknNvA70s_Q,66
9
+ vectara_agentic/agent.py,sha256=jUXiwhN6pJl3zWb01oF1PwbZCWWOE96aD8A6GsR2TC0,26031
10
+ vectara_agentic/agent_config.py,sha256=9P9lyFAAXLX1ft2dBQ6tYN7dKzp7SC7B-h-DnhUHsSg,2941
11
+ vectara_agentic/agent_endpoint.py,sha256=QIMejCLlpW2qzXxeDAxv3anF46XMDdVMdKGWhJh3azY,1996
12
+ vectara_agentic/db_tools.py,sha256=kCEENzmnorm8i-k4Kpd4KLJt1QWh_ZlAyX1aG-tzET0,3619
13
+ vectara_agentic/tools.py,sha256=pWRiuHLoS8jxmiuHTepWT-mbn9NUJqrjWOf5Q3u_MSs,34374
14
+ vectara_agentic/tools_catalog.py,sha256=O3vYFpZ5EQeh37X70TiHepXFGN5yGk4_d7CkrkLeUhk,5205
15
+ vectara_agentic/types.py,sha256=00wm3YsJRyddvIBzeVjF3qklA38NuTkCvy_B-e68v6c,1589
16
+ vectara_agentic/utils.py,sha256=eDEOUpCkb0r216LxSLkamll2NmJhu76Z1TgQFbAVq7A,4690
17
+ vectara_agentic-0.1.26.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
18
+ vectara_agentic-0.1.26.dist-info/METADATA,sha256=PeWZ9nc92otAPQJC27UCgHqBOXnuwWA4MrGvBAPuamE,20565
19
+ vectara_agentic-0.1.26.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
20
+ vectara_agentic-0.1.26.dist-info/top_level.txt,sha256=Y7TQTFdOYGYodQRltUGRieZKIYuzeZj2kHqAUpfCUfg,22
21
+ vectara_agentic-0.1.26.dist-info/RECORD,,
@@ -1,21 +0,0 @@
1
- tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- tests/test_agent.py,sha256=8LQlny0rIuVa13LGtebG0vatES6Ln7gmenbSwX-ctrY,4260
3
- tests/test_tools.py,sha256=2ofZYz3Q-YMSxjpiEg1VNUlA9gMjvNAcJAO2Ucd0eVE,2969
4
- vectara_agentic/__init__.py,sha256=FUWwh37ia9AduK4YDo_TCD52A09ocbYo49oYyBJtyqY,219
5
- vectara_agentic/_callback.py,sha256=OBiHk_OJZTS3iKz_LigfEjnl_p5V90XYsQC0vEYVSPo,8782
6
- vectara_agentic/_observability.py,sha256=HeQYJIkqPLW3EWHiXHatkaJzo08IQGESKujdeWTuRgk,3805
7
- vectara_agentic/_prompts.py,sha256=ITHWQQ4oSmRhqBwRcheYC_nMdZZielUOjfVIbDYi9rw,6257
8
- vectara_agentic/_version.py,sha256=3P-p27Ccx3RQ_PJQDAu-lIwPrPQ8S780FnRmeItjqNg,66
9
- vectara_agentic/agent.py,sha256=35dc7RBYevvX9XGz1WoPRQL6N8NnWxL_Eac56e1JpFo,22427
10
- vectara_agentic/agent_config.py,sha256=8q_eRPURAZYHUXu_rxD2eO1XHC9jNGe_d9ytPgXbS7g,2949
11
- vectara_agentic/agent_endpoint.py,sha256=QIMejCLlpW2qzXxeDAxv3anF46XMDdVMdKGWhJh3azY,1996
12
- vectara_agentic/db_tools.py,sha256=kCEENzmnorm8i-k4Kpd4KLJt1QWh_ZlAyX1aG-tzET0,3619
13
- vectara_agentic/tools.py,sha256=Qhql8IA_CGvsZ3ErOFQH2y-sxxHXvL3GUDH6shgxmzQ,28262
14
- vectara_agentic/tools_catalog.py,sha256=5NlJypdu0IKa7mODxVOwo05lw3PqQJtSl_ZOsUDH_TA,3986
15
- vectara_agentic/types.py,sha256=siRh9VmFt3jhTu4uJzYpvNlLi60lyIH5_xqYHKpB24Q,1149
16
- vectara_agentic/utils.py,sha256=-hnILxUAAtcFRlupeNEVBwHpm-EMF98iLV1Z_hjVrNA,4460
17
- vectara_agentic-0.1.24.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
18
- vectara_agentic-0.1.24.dist-info/METADATA,sha256=VtSVDzA0zHVWq5C8fNqjATQCOpF_zXIAsWiPYd2_Y5E,15379
19
- vectara_agentic-0.1.24.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
20
- vectara_agentic-0.1.24.dist-info/top_level.txt,sha256=Y7TQTFdOYGYodQRltUGRieZKIYuzeZj2kHqAUpfCUfg,22
21
- vectara_agentic-0.1.24.dist-info/RECORD,,