vectara-agentic 0.1.13__tar.gz → 0.1.15__tar.gz

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 (24) hide show
  1. {vectara_agentic-0.1.13/vectara_agentic.egg-info → vectara_agentic-0.1.15}/PKG-INFO +85 -75
  2. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/README.md +85 -76
  3. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/requirements.txt +1 -0
  4. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/setup.py +2 -2
  5. vectara_agentic-0.1.15/tests/__init__.py +0 -0
  6. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/tests/test_tools.py +2 -1
  7. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/vectara_agentic/__init__.py +1 -1
  8. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/vectara_agentic/_callback.py +24 -5
  9. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/vectara_agentic/_observability.py +24 -7
  10. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/vectara_agentic/_prompts.py +4 -2
  11. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/vectara_agentic/agent.py +14 -40
  12. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/vectara_agentic/tools.py +14 -10
  13. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/vectara_agentic/tools_catalog.py +33 -21
  14. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/vectara_agentic/types.py +2 -1
  15. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/vectara_agentic/utils.py +7 -9
  16. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15/vectara_agentic.egg-info}/PKG-INFO +85 -75
  17. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/vectara_agentic.egg-info/SOURCES.txt +1 -0
  18. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/vectara_agentic.egg-info/requires.txt +1 -0
  19. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/vectara_agentic.egg-info/top_level.txt +1 -0
  20. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/LICENSE +0 -0
  21. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/MANIFEST.in +0 -0
  22. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/setup.cfg +0 -0
  23. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/tests/test_agent.py +0 -0
  24. {vectara_agentic-0.1.13 → vectara_agentic-0.1.15}/vectara_agentic.egg-info/dependency_links.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vectara_agentic
3
- Version: 0.1.13
3
+ Version: 0.1.15
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
@@ -34,6 +34,7 @@ Requires-Dist: llama-index-tools-google==0.2.0
34
34
  Requires-Dist: llama-index-tools-tavily_research==0.2.0
35
35
  Requires-Dist: tavily-python==0.5.0
36
36
  Requires-Dist: yahoo-finance==1.4.0
37
+ Requires-Dist: llama-index-tools-neo4j==0.2.0
37
38
  Requires-Dist: openinference-instrumentation-llama-index==3.0.2
38
39
  Requires-Dist: arize-phoenix==4.35.1
39
40
  Requires-Dist: arize-phoenix-otel==0.5.1
@@ -45,47 +46,57 @@ Requires-Dist: python-dotenv==1.0.1
45
46
  Requires-Dist: tiktoken==0.7.0
46
47
  Requires-Dist: dill==0.3.8
47
48
 
48
- # vectara-agentic
49
+ # <img src="https://raw.githubusercontent.com/vectara/py-vectara-agentic/main/.github/assets/Vectara-logo.png" alt="Vectara Logo" width="30" height="30" style="vertical-align: middle;"> vectara-agentic
49
50
 
50
- [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
51
- [![Maintained](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/vectara/py-vectara-agentic/graphs/commit-activity)
52
- [![Twitter](https://img.shields.io/twitter/follow/vectara.svg?style=social&label=Follow%20%40Vectara)](https://twitter.com/vectara)
53
- [![Discord](https://img.shields.io/badge/Discord-Join%20Us-blue?style=social&logo=discord)](https://discord.com/invite/GFb8gMz6UH)
51
+ <p align="center">
52
+ <a href="https://vectara.github.io/vectara-agentic-docs">Documentation</a> ·
53
+ <a href="#examples">Examples</a> ·
54
+ <a href="https://discord.gg/S9dwgCNEFs">Discord</a>
55
+ </p>
54
56
 
55
- ## Overview
57
+ <p align="center">
58
+ <a href="https://opensource.org/licenses/Apache-2.0">
59
+ <img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License">
60
+ </a>
61
+ <a href="https://github.com/vectara/py-vectara-agentic/graphs/commit-activity">
62
+ <img src="https://img.shields.io/badge/Maintained%3F-yes-green.svg" alt="Maintained">
63
+ </a>
64
+ <a href="https://twitter.com/vectara">
65
+ <img src="https://img.shields.io/twitter/follow/vectara.svg?style=social&label=Follow%20%40Vectara" alt="Twitter">
66
+ </a>
67
+ </p>
68
+
69
+ ## ✨ Overview
56
70
 
57
71
  `vectara-agentic` is a Python library for developing powerful AI assistants using Vectara and Agentic-RAG. It leverages the LlamaIndex Agent framework, customized for use with Vectara.
58
72
 
59
- ### Key Features
73
+ ### Key Features
60
74
 
61
- - Supports `ReAct` and `OpenAIAgent` agent types.
75
+ - Supports `ReAct`, `OpenAIAgent` and `LLMCompiler` agent types.
62
76
  - Includes pre-built tools for various domains (e.g., finance, legal).
63
77
  - Enables easy creation of custom AI assistants and agents.
64
78
 
65
- ## Important Links
66
-
67
- - Documentation: [https://vectara.github.io/vectara-agentic-docs/](https://vectara.github.io/vectara-agentic-docs/)
68
-
69
- ## Prerequisites
79
+ ### Prerequisites
70
80
 
71
81
  - [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)
72
82
  - A Vectara corpus with an [API key](https://docs.vectara.com/docs/api-keys)
73
83
  - [Python 3.10 or higher](https://www.python.org/downloads/)
74
- - OpenAI API key (or API keys for Anthropic, TOGETHER.AI, Fireworks AI, Cohere, GEMINI or GROQ)
84
+ - OpenAI API key (or API keys for Anthropic, TOGETHER.AI, Fireworks AI, Cohere, GEMINI or GROQ, if you choose to use them)
75
85
 
76
- ## Installation
86
+ ### Installation
77
87
 
78
88
  ```bash
79
89
  pip install vectara-agentic
80
90
  ```
81
91
 
82
- ## Quick Start
92
+ ## 🚀 Quick Start
83
93
 
84
- 1. **Create a Vectara RAG tool**
94
+ ### 1. Create a Vectara RAG tool
85
95
 
86
96
  ```python
87
97
  import os
88
98
  from vectara_agentic import VectaraToolFactory
99
+ from pydantic import BaseModel, Field
89
100
 
90
101
  vec_factory = VectaraToolFactory(
91
102
  vectara_api_key=os.environ['VECTARA_API_KEY'],
@@ -94,108 +105,109 @@ vec_factory = VectaraToolFactory(
94
105
  )
95
106
 
96
107
  class QueryFinancialReportsArgs(BaseModel):
97
- query: str = Field(..., description="The user query.")
98
- year: int = Field(..., description=f"The year. An integer between {min(years)} and {max(years)}.")
99
- ticker: str = Field(..., description=f"The company ticker. Must be a valid ticket symbol from the list {tickers.keys()}.")
108
+ query: str = Field(..., description="The user query.")
109
+ year: int = Field(..., description="The year. An integer between {min(years)} and {max(years)}.")
110
+ ticker: str = Field(..., description="The company ticker. Must be a valid ticket symbol from the list {tickers.keys()}.")
100
111
 
101
- query_financial_reports = vec_factory.create_rag_tool(
112
+ query_financial_reports_tool = vec_factory.create_rag_tool(
102
113
  tool_name="query_financial_reports",
103
114
  tool_description="Query financial reports for a company and year",
104
115
  tool_args_schema=QueryFinancialReportsArgs,
105
116
  )
106
117
  ```
107
118
 
108
- Note that `VECTARA_CORPUS_ID` can be a single ID or a comma-separated list of IDs.
109
-
110
- 2. **Create other tools (optional)**
119
+ ### 2. Create other tools (optional)
111
120
 
112
121
  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
113
122
  that call other APIs to get more information, or any other type of tool.
114
123
 
115
- See [Tools](#agent-tools) for more information.
124
+ See [Agent Tools](#agent-tools) for more information.
116
125
 
117
- 3. **Create your agent**
126
+ ### 3. Create your agent
118
127
 
119
128
  ```python
129
+ from vectara_agentic import Agent
130
+
120
131
  agent = Agent(
121
- tools = [query_financial_reports],
122
- topic = topic_of_expertise,
123
- custom_instructions = financial_bot_instructions,
132
+ tools=[query_financial_reports_tool],
133
+ topic="10-K financial reports",
134
+ custom_instructions="""
135
+ - You are a helpful financial assistant in conversation with a user. Use your financial expertise when crafting a query to the tool, to ensure you get the most accurate information.
136
+ - You can answer questions, provide insights, or summarize any information from financial reports.
137
+ - A user may refer to a company's ticker instead of its full name - consider those the same when a user is asking about a company.
138
+ - When calculating a financial metric, make sure you have all the information from tools to complete the calculation.
139
+ - In many cases you may need to query tools on each sub-metric separately before computing the final metric.
140
+ - When using a tool to obtain financial data, consider the fact that information for a certain year may be reported in the following year's report.
141
+ - Report financial data in a consistent manner. For example if you report revenue in thousands, always report revenue in thousands.
142
+ """
124
143
  )
125
144
  ```
126
- - `tools` is the list of tools you want to provide to the agent. In this example it's just a single tool.
127
- - `topic` is a string that defines the expertise you want the agent to specialize in.
128
- - `custom_instructions` is an optional string that defines special instructions to the agent.
129
145
 
130
- For example, for a financial agent we might use:
146
+ ### 4. Run your agent
131
147
 
132
148
  ```python
133
- topic_of_expertise = "10-K financial reports",
134
-
135
- financial_bot_instructions = """
136
- - You are a helpful financial assistant in conversation with a user. Use your financial expertise when crafting a query to the tool, to ensure you get the most accurate information.
137
- - You can answer questions, provide insights, or summarize any information from financial reports.
138
- - A user may refer to a company's ticker instead of its full name - consider those the same when a user is asking about a company.
139
- - When calculating a financial metric, make sure you have all the information from tools to complete the calculation.
140
- - In many cases you may need to query tools on each sub-metric separately before computing the final metric.
141
- - When using a tool to obtain financial data, consider the fact that information for a certain year may be reported in the the following year's report.
142
- - Report financial data in a consistent manner. For example if you report revenue in thousands, always report revenue in thousands.
143
- """
149
+ response = agent.chat("What was the revenue for Apple in 2021?")
150
+ print(response)
144
151
  ```
145
152
 
146
- ## Configuration
147
-
148
- Configure `vectara-agentic` using environment variables:
149
-
150
- - `VECTARA_AGENTIC_AGENT_TYPE`: valid values are `REACT`, `LLMCOMPILER` or `OPENAI` (default: `OPENAI`)
151
- - `VECTARA_AGENTIC_MAIN_LLM_PROVIDER`: valid values are `OPENAI`, `ANTHROPIC`, `TOGETHER`, `GROQ`, `COHERE`, `GEMINI` or `FIREWORKS` (default: `OPENAI`)
152
- - `VECTARA_AGENTIC_MAIN_MODEL_NAME`: agent model name (default depends on provider)
153
- - `VECTARA_AGENTIC_TOOL_LLM_PROVIDER`: tool LLM provider (default: `OPENAI`)
154
- - `VECTARA_AGENTIC_TOOL_MODEL_NAME`: tool model name (default depends on provider)
155
-
156
- ## Agent Tools
153
+ ## 🛠️ Agent Tools
157
154
 
158
155
  `vectara-agentic` provides a few tools out of the box:
159
- 1. Standard tools:
156
+ 1. **Standard tools**:
160
157
  - `summarize_text`: a tool to summarize a long text into a shorter summary (uses LLM)
161
158
  - `rephrase_text`: a tool to rephrase a given text, given a set of rephrase instructions (uses LLM)
162
159
 
163
- 2. Legal tools: a set of tools for the legal vertical, such as:
160
+ 2. **Legal tools**: a set of tools for the legal vertical, such as:
164
161
  - `summarize_legal_text`: summarize legal text with a certain point of view
165
162
  - `critique_as_judge`: critique a legal text as a judge, providing their perspective
166
163
 
167
- 3. Financial tools: based on tools from Yahoo Finance:
164
+ 3. **Financial tools**: based on tools from Yahoo! Finance:
168
165
  - tools to understand the financials of a public company like: `balance_sheet`, `income_statement`, `cash_flow`
169
166
  - `stock_news`: provides news about a company
170
167
  - `stock_analyst_recommendations`: provides stock analyst recommendations for a company.
171
168
 
172
- 4. database_tools: providing a few tools to inspect and query a database
169
+ 1. **Database tools**: providing tools to inspect and query a database
173
170
  - `list_tables`: list all tables in the database
174
171
  - `describe_tables`: describe the schema of tables in the database
175
172
  - `load_data`: returns data based on a SQL query
176
173
 
177
- More tools coming soon.
174
+ More tools coming soon...
178
175
 
179
- You can create your own tool directly from a Python function using the `create_tool()` method of the `ToolsFactor` class:
176
+ You can create your own tool directly from a Python function using the `create_tool()` method of the `ToolsFactory` class:
180
177
 
181
- ```Python
178
+ ```python
182
179
  def mult_func(x, y):
183
- return x*y
180
+ return x * y
184
181
 
185
182
  mult_tool = ToolsFactory().create_tool(mult_func)
186
183
  ```
187
184
 
188
- ## Agent Diagnostics
185
+ ## 🛠️ Configuration
186
+
187
+ Configure `vectara-agentic` using environment variables:
188
+
189
+ - `VECTARA_AGENTIC_AGENT_TYPE`: valid values are `REACT`, `LLMCOMPILER` or `OPENAI` (default: `OPENAI`)
190
+ - `VECTARA_AGENTIC_MAIN_LLM_PROVIDER`: valid values are `OPENAI`, `ANTHROPIC`, `TOGETHER`, `GROQ`, `COHERE`, `GEMINI` or `FIREWORKS` (default: `OPENAI`)
191
+ - `VECTARA_AGENTIC_MAIN_MODEL_NAME`: agent model name (default depends on provider)
192
+ - `VECTARA_AGENTIC_TOOL_LLM_PROVIDER`: tool LLM provider (default: `OPENAI`)
193
+ - `VECTARA_AGENTIC_TOOL_MODEL_NAME`: tool model name (default depends on provider)
194
+ - `VECTARA_AGENTIC_OBSERVER_TYPE`: valid values are `ARIZE_PHOENIX` or `NONE` (default: `NONE`)
195
+
196
+ 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. Note that `VECTARA_CORPUS_ID` can be a single ID or a comma-separated list of IDs (if you want to query multiple corpora).
197
+
198
+ ## ℹ️ Additional Information
199
+
200
+ ### Agent Diagnostics
189
201
 
190
202
  The `Agent` class defines a few helpful methods to help you understand the internals of your application.
191
203
  * The `report()` method prints out the agent object’s type, the tools, and the LLMs used for the main agent and tool calling.
192
204
  * The `token_counts()` method tells you how many tokens you have used in the current session for both the main agent and tool calling LLMs. This can be helpful if you want to track spend by token.
193
205
 
194
- ## Serialization
206
+ ### Serialization
195
207
 
196
208
  The `Agent` class supports serialization. Use the `dumps()` to serialize and `loads()` to read back from a serialized stream.
197
209
 
198
- ## Observability
210
+ ### Observability
199
211
 
200
212
  vectara-agentic supports observability via the existing integration of LlamaIndex and Arize Phoenix.
201
213
  First, set `os["VECTARA_AGENTIC_OBSERVER_TYPE"] = "ARIZE_PHOENIX"`.
@@ -210,10 +222,9 @@ Then you can use Arize Phoenix in three ways:
210
222
  3. To view the traces go to `https://app.phoenix.arize.com`.
211
223
 
212
224
  Now when you run your agent, all call traces are sent to Phoenix and recorded.
213
- In addition, vectara-agentic also records `FCS` values into Arize for every Vectara RAG call. You can see those results in the `Feedback` column of the arize UI.
214
-
225
+ In addition, vectara-agentic also records `FCS` (factual consistency score, aka HHEM) values into Arize for every Vectara RAG call. You can see those results in the `Feedback` column of the arize UI.
215
226
 
216
- ## About Custom Instructions
227
+ ### About Custom Instructions
217
228
 
218
229
  The custom instructions you provide to the agent guide its behavior.
219
230
  Here are some guidelines when creating your instructions:
@@ -221,7 +232,7 @@ Here are some guidelines when creating your instructions:
221
232
  - Consider edge cases and unusual or atypical scenarios.
222
233
  - Be cautious to not over-specify behavior based on your primary use-case, as it may limit the agent's ability to behave properly in others.
223
234
 
224
- ## Examples
235
+ ## 📚 Examples
225
236
 
226
237
  Check out our example AI assistants:
227
238
 
@@ -229,16 +240,15 @@ Check out our example AI assistants:
229
240
  - [Justice Harvard Teaching Assistant](https://huggingface.co/spaces/vectara/Justice-Harvard)
230
241
  - [Legal Assistant](https://huggingface.co/spaces/vectara/legal-agent)
231
242
 
232
-
233
- ## Contributing
243
+ ## 🤝 Contributing
234
244
 
235
245
  We welcome contributions! Please see our [contributing guide](https://github.com/vectara/py-vectara-agentic/blob/main/CONTRIBUTING.md) for more information.
236
246
 
237
- ## License
247
+ ## 📝 License
238
248
 
239
249
  This project is licensed under the Apache 2.0 License. See the [LICENSE](https://github.com/vectara/py-vectara-agentic/blob/master/LICENSE) file for details.
240
250
 
241
- ## Contact
251
+ ## 📞 Contact
242
252
 
243
253
  - Website: [vectara.com](https://vectara.com)
244
254
  - Twitter: [@vectara](https://twitter.com/vectara)
@@ -1,44 +1,54 @@
1
- # vectara-agentic
2
-
3
- [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
4
- [![Maintained](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/vectara/py-vectara-agentic/graphs/commit-activity)
5
- [![Twitter](https://img.shields.io/twitter/follow/vectara.svg?style=social&label=Follow%20%40Vectara)](https://twitter.com/vectara)
6
- [![Discord](https://img.shields.io/badge/Discord-Join%20Us-blue?style=social&logo=discord)](https://discord.com/invite/GFb8gMz6UH)
7
-
8
- ## Overview
1
+ # <img src="https://raw.githubusercontent.com/vectara/py-vectara-agentic/main/.github/assets/Vectara-logo.png" alt="Vectara Logo" width="30" height="30" style="vertical-align: middle;"> vectara-agentic
2
+
3
+ <p align="center">
4
+ <a href="https://vectara.github.io/vectara-agentic-docs">Documentation</a> ·
5
+ <a href="#examples">Examples</a> ·
6
+ <a href="https://discord.gg/S9dwgCNEFs">Discord</a>
7
+ </p>
8
+
9
+ <p align="center">
10
+ <a href="https://opensource.org/licenses/Apache-2.0">
11
+ <img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License">
12
+ </a>
13
+ <a href="https://github.com/vectara/py-vectara-agentic/graphs/commit-activity">
14
+ <img src="https://img.shields.io/badge/Maintained%3F-yes-green.svg" alt="Maintained">
15
+ </a>
16
+ <a href="https://twitter.com/vectara">
17
+ <img src="https://img.shields.io/twitter/follow/vectara.svg?style=social&label=Follow%20%40Vectara" alt="Twitter">
18
+ </a>
19
+ </p>
20
+
21
+ ## ✨ Overview
9
22
 
10
23
  `vectara-agentic` is a Python library for developing powerful AI assistants using Vectara and Agentic-RAG. It leverages the LlamaIndex Agent framework, customized for use with Vectara.
11
24
 
12
- ### Key Features
25
+ ### Key Features
13
26
 
14
- - Supports `ReAct` and `OpenAIAgent` agent types.
27
+ - Supports `ReAct`, `OpenAIAgent` and `LLMCompiler` agent types.
15
28
  - Includes pre-built tools for various domains (e.g., finance, legal).
16
29
  - Enables easy creation of custom AI assistants and agents.
17
30
 
18
- ## Important Links
19
-
20
- - Documentation: [https://vectara.github.io/vectara-agentic-docs/](https://vectara.github.io/vectara-agentic-docs/)
21
-
22
- ## Prerequisites
31
+ ### Prerequisites
23
32
 
24
33
  - [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)
25
34
  - A Vectara corpus with an [API key](https://docs.vectara.com/docs/api-keys)
26
35
  - [Python 3.10 or higher](https://www.python.org/downloads/)
27
- - OpenAI API key (or API keys for Anthropic, TOGETHER.AI, Fireworks AI, Cohere, GEMINI or GROQ)
36
+ - OpenAI API key (or API keys for Anthropic, TOGETHER.AI, Fireworks AI, Cohere, GEMINI or GROQ, if you choose to use them)
28
37
 
29
- ## Installation
38
+ ### Installation
30
39
 
31
40
  ```bash
32
41
  pip install vectara-agentic
33
42
  ```
34
43
 
35
- ## Quick Start
44
+ ## 🚀 Quick Start
36
45
 
37
- 1. **Create a Vectara RAG tool**
46
+ ### 1. Create a Vectara RAG tool
38
47
 
39
48
  ```python
40
49
  import os
41
50
  from vectara_agentic import VectaraToolFactory
51
+ from pydantic import BaseModel, Field
42
52
 
43
53
  vec_factory = VectaraToolFactory(
44
54
  vectara_api_key=os.environ['VECTARA_API_KEY'],
@@ -47,108 +57,109 @@ vec_factory = VectaraToolFactory(
47
57
  )
48
58
 
49
59
  class QueryFinancialReportsArgs(BaseModel):
50
- query: str = Field(..., description="The user query.")
51
- year: int = Field(..., description=f"The year. An integer between {min(years)} and {max(years)}.")
52
- ticker: str = Field(..., description=f"The company ticker. Must be a valid ticket symbol from the list {tickers.keys()}.")
60
+ query: str = Field(..., description="The user query.")
61
+ year: int = Field(..., description="The year. An integer between {min(years)} and {max(years)}.")
62
+ ticker: str = Field(..., description="The company ticker. Must be a valid ticket symbol from the list {tickers.keys()}.")
53
63
 
54
- query_financial_reports = vec_factory.create_rag_tool(
64
+ query_financial_reports_tool = vec_factory.create_rag_tool(
55
65
  tool_name="query_financial_reports",
56
66
  tool_description="Query financial reports for a company and year",
57
67
  tool_args_schema=QueryFinancialReportsArgs,
58
68
  )
59
69
  ```
60
70
 
61
- Note that `VECTARA_CORPUS_ID` can be a single ID or a comma-separated list of IDs.
62
-
63
- 2. **Create other tools (optional)**
71
+ ### 2. Create other tools (optional)
64
72
 
65
73
  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
66
74
  that call other APIs to get more information, or any other type of tool.
67
75
 
68
- See [Tools](#agent-tools) for more information.
76
+ See [Agent Tools](#agent-tools) for more information.
69
77
 
70
- 3. **Create your agent**
78
+ ### 3. Create your agent
71
79
 
72
80
  ```python
81
+ from vectara_agentic import Agent
82
+
73
83
  agent = Agent(
74
- tools = [query_financial_reports],
75
- topic = topic_of_expertise,
76
- custom_instructions = financial_bot_instructions,
84
+ tools=[query_financial_reports_tool],
85
+ topic="10-K financial reports",
86
+ custom_instructions="""
87
+ - You are a helpful financial assistant in conversation with a user. Use your financial expertise when crafting a query to the tool, to ensure you get the most accurate information.
88
+ - You can answer questions, provide insights, or summarize any information from financial reports.
89
+ - A user may refer to a company's ticker instead of its full name - consider those the same when a user is asking about a company.
90
+ - When calculating a financial metric, make sure you have all the information from tools to complete the calculation.
91
+ - In many cases you may need to query tools on each sub-metric separately before computing the final metric.
92
+ - When using a tool to obtain financial data, consider the fact that information for a certain year may be reported in the following year's report.
93
+ - Report financial data in a consistent manner. For example if you report revenue in thousands, always report revenue in thousands.
94
+ """
77
95
  )
78
96
  ```
79
- - `tools` is the list of tools you want to provide to the agent. In this example it's just a single tool.
80
- - `topic` is a string that defines the expertise you want the agent to specialize in.
81
- - `custom_instructions` is an optional string that defines special instructions to the agent.
82
97
 
83
- For example, for a financial agent we might use:
98
+ ### 4. Run your agent
84
99
 
85
100
  ```python
86
- topic_of_expertise = "10-K financial reports",
87
-
88
- financial_bot_instructions = """
89
- - You are a helpful financial assistant in conversation with a user. Use your financial expertise when crafting a query to the tool, to ensure you get the most accurate information.
90
- - You can answer questions, provide insights, or summarize any information from financial reports.
91
- - A user may refer to a company's ticker instead of its full name - consider those the same when a user is asking about a company.
92
- - When calculating a financial metric, make sure you have all the information from tools to complete the calculation.
93
- - In many cases you may need to query tools on each sub-metric separately before computing the final metric.
94
- - When using a tool to obtain financial data, consider the fact that information for a certain year may be reported in the the following year's report.
95
- - Report financial data in a consistent manner. For example if you report revenue in thousands, always report revenue in thousands.
96
- """
101
+ response = agent.chat("What was the revenue for Apple in 2021?")
102
+ print(response)
97
103
  ```
98
104
 
99
- ## Configuration
100
-
101
- Configure `vectara-agentic` using environment variables:
102
-
103
- - `VECTARA_AGENTIC_AGENT_TYPE`: valid values are `REACT`, `LLMCOMPILER` or `OPENAI` (default: `OPENAI`)
104
- - `VECTARA_AGENTIC_MAIN_LLM_PROVIDER`: valid values are `OPENAI`, `ANTHROPIC`, `TOGETHER`, `GROQ`, `COHERE`, `GEMINI` or `FIREWORKS` (default: `OPENAI`)
105
- - `VECTARA_AGENTIC_MAIN_MODEL_NAME`: agent model name (default depends on provider)
106
- - `VECTARA_AGENTIC_TOOL_LLM_PROVIDER`: tool LLM provider (default: `OPENAI`)
107
- - `VECTARA_AGENTIC_TOOL_MODEL_NAME`: tool model name (default depends on provider)
108
-
109
- ## Agent Tools
105
+ ## 🛠️ Agent Tools
110
106
 
111
107
  `vectara-agentic` provides a few tools out of the box:
112
- 1. Standard tools:
108
+ 1. **Standard tools**:
113
109
  - `summarize_text`: a tool to summarize a long text into a shorter summary (uses LLM)
114
110
  - `rephrase_text`: a tool to rephrase a given text, given a set of rephrase instructions (uses LLM)
115
111
 
116
- 2. Legal tools: a set of tools for the legal vertical, such as:
112
+ 2. **Legal tools**: a set of tools for the legal vertical, such as:
117
113
  - `summarize_legal_text`: summarize legal text with a certain point of view
118
114
  - `critique_as_judge`: critique a legal text as a judge, providing their perspective
119
115
 
120
- 3. Financial tools: based on tools from Yahoo Finance:
116
+ 3. **Financial tools**: based on tools from Yahoo! Finance:
121
117
  - tools to understand the financials of a public company like: `balance_sheet`, `income_statement`, `cash_flow`
122
118
  - `stock_news`: provides news about a company
123
119
  - `stock_analyst_recommendations`: provides stock analyst recommendations for a company.
124
120
 
125
- 4. database_tools: providing a few tools to inspect and query a database
121
+ 1. **Database tools**: providing tools to inspect and query a database
126
122
  - `list_tables`: list all tables in the database
127
123
  - `describe_tables`: describe the schema of tables in the database
128
124
  - `load_data`: returns data based on a SQL query
129
125
 
130
- More tools coming soon.
126
+ More tools coming soon...
131
127
 
132
- You can create your own tool directly from a Python function using the `create_tool()` method of the `ToolsFactor` class:
128
+ You can create your own tool directly from a Python function using the `create_tool()` method of the `ToolsFactory` class:
133
129
 
134
- ```Python
130
+ ```python
135
131
  def mult_func(x, y):
136
- return x*y
132
+ return x * y
137
133
 
138
134
  mult_tool = ToolsFactory().create_tool(mult_func)
139
135
  ```
140
136
 
141
- ## Agent Diagnostics
137
+ ## 🛠️ Configuration
138
+
139
+ Configure `vectara-agentic` using environment variables:
140
+
141
+ - `VECTARA_AGENTIC_AGENT_TYPE`: valid values are `REACT`, `LLMCOMPILER` or `OPENAI` (default: `OPENAI`)
142
+ - `VECTARA_AGENTIC_MAIN_LLM_PROVIDER`: valid values are `OPENAI`, `ANTHROPIC`, `TOGETHER`, `GROQ`, `COHERE`, `GEMINI` or `FIREWORKS` (default: `OPENAI`)
143
+ - `VECTARA_AGENTIC_MAIN_MODEL_NAME`: agent model name (default depends on provider)
144
+ - `VECTARA_AGENTIC_TOOL_LLM_PROVIDER`: tool LLM provider (default: `OPENAI`)
145
+ - `VECTARA_AGENTIC_TOOL_MODEL_NAME`: tool model name (default depends on provider)
146
+ - `VECTARA_AGENTIC_OBSERVER_TYPE`: valid values are `ARIZE_PHOENIX` or `NONE` (default: `NONE`)
147
+
148
+ 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. Note that `VECTARA_CORPUS_ID` can be a single ID or a comma-separated list of IDs (if you want to query multiple corpora).
149
+
150
+ ## ℹ️ Additional Information
151
+
152
+ ### Agent Diagnostics
142
153
 
143
154
  The `Agent` class defines a few helpful methods to help you understand the internals of your application.
144
155
  * The `report()` method prints out the agent object’s type, the tools, and the LLMs used for the main agent and tool calling.
145
156
  * The `token_counts()` method tells you how many tokens you have used in the current session for both the main agent and tool calling LLMs. This can be helpful if you want to track spend by token.
146
157
 
147
- ## Serialization
158
+ ### Serialization
148
159
 
149
160
  The `Agent` class supports serialization. Use the `dumps()` to serialize and `loads()` to read back from a serialized stream.
150
161
 
151
- ## Observability
162
+ ### Observability
152
163
 
153
164
  vectara-agentic supports observability via the existing integration of LlamaIndex and Arize Phoenix.
154
165
  First, set `os["VECTARA_AGENTIC_OBSERVER_TYPE"] = "ARIZE_PHOENIX"`.
@@ -163,10 +174,9 @@ Then you can use Arize Phoenix in three ways:
163
174
  3. To view the traces go to `https://app.phoenix.arize.com`.
164
175
 
165
176
  Now when you run your agent, all call traces are sent to Phoenix and recorded.
166
- In addition, vectara-agentic also records `FCS` values into Arize for every Vectara RAG call. You can see those results in the `Feedback` column of the arize UI.
167
-
177
+ In addition, vectara-agentic also records `FCS` (factual consistency score, aka HHEM) values into Arize for every Vectara RAG call. You can see those results in the `Feedback` column of the arize UI.
168
178
 
169
- ## About Custom Instructions
179
+ ### About Custom Instructions
170
180
 
171
181
  The custom instructions you provide to the agent guide its behavior.
172
182
  Here are some guidelines when creating your instructions:
@@ -174,7 +184,7 @@ Here are some guidelines when creating your instructions:
174
184
  - Consider edge cases and unusual or atypical scenarios.
175
185
  - Be cautious to not over-specify behavior based on your primary use-case, as it may limit the agent's ability to behave properly in others.
176
186
 
177
- ## Examples
187
+ ## 📚 Examples
178
188
 
179
189
  Check out our example AI assistants:
180
190
 
@@ -182,16 +192,15 @@ Check out our example AI assistants:
182
192
  - [Justice Harvard Teaching Assistant](https://huggingface.co/spaces/vectara/Justice-Harvard)
183
193
  - [Legal Assistant](https://huggingface.co/spaces/vectara/legal-agent)
184
194
 
185
-
186
- ## Contributing
195
+ ## 🤝 Contributing
187
196
 
188
197
  We welcome contributions! Please see our [contributing guide](https://github.com/vectara/py-vectara-agentic/blob/main/CONTRIBUTING.md) for more information.
189
198
 
190
- ## License
199
+ ## 📝 License
191
200
 
192
201
  This project is licensed under the Apache 2.0 License. See the [LICENSE](https://github.com/vectara/py-vectara-agentic/blob/master/LICENSE) file for details.
193
202
 
194
- ## Contact
203
+ ## 📞 Contact
195
204
 
196
205
  - Website: [vectara.com](https://vectara.com)
197
206
  - Twitter: [@vectara](https://twitter.com/vectara)
@@ -16,6 +16,7 @@ llama-index-tools-google==0.2.0
16
16
  llama-index-tools-tavily_research==0.2.0
17
17
  tavily-python==0.5.0
18
18
  yahoo-finance==1.4.0
19
+ llama-index-tools-neo4j==0.2.0
19
20
  openinference-instrumentation-llama-index==3.0.2
20
21
  arize-phoenix==4.35.1
21
22
  arize-phoenix-otel==0.5.1
@@ -8,7 +8,7 @@ def read_requirements():
8
8
 
9
9
  setup(
10
10
  name="vectara_agentic",
11
- version="0.1.13",
11
+ version="0.1.15",
12
12
  author="Ofer Mendelevitch",
13
13
  author_email="ofer@vectara.com",
14
14
  description="A Python package for creating AI Assistants and AI Agents with Vectara",
@@ -25,7 +25,7 @@ setup(
25
25
  "Topic :: Scientific/Engineering :: Artificial Intelligence",
26
26
  "Topic :: Software Development :: Libraries :: Python Modules",
27
27
  ],
28
- keywords = ["LLM", "NLP", "RAG", "Agentic-RAG"],
28
+ keywords=["LLM", "NLP", "RAG", "Agentic-RAG"],
29
29
  project_urls={
30
30
  "Documentation": "https://vectara.github.io/vectara-agentic-docs/",
31
31
  },
File without changes
@@ -76,7 +76,8 @@ class TestToolsPackage(unittest.TestCase):
76
76
  vectara_summarizer="mockingbird-1.0-2024-07-16"
77
77
  )
78
78
 
79
- self.assertContains(agent.chat("What is Vectara?"), "Vectara is an end-to-end platform")
79
+ self.assertIn("Vectara is an end-to-end platform", agent.chat("What is Vectara?"))
80
+
80
81
 
81
82
  if __name__ == "__main__":
82
83
  unittest.main()
@@ -3,7 +3,7 @@ vectara_agentic package.
3
3
  """
4
4
 
5
5
  # Define the package version
6
- __version__ = "0.1.13"
6
+ __version__ = "0.1.15"
7
7
 
8
8
  # Import classes and functions from modules
9
9
  # from .module1 import Class1, function1