vectara-agentic 0.2.12__py3-none-any.whl → 0.2.14__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.
- tests/test_agent.py +18 -1
- tests/test_agent_planning.py +0 -9
- tests/test_agent_type.py +40 -0
- tests/test_groq.py +120 -0
- tests/test_tools.py +176 -42
- tests/test_vectara_llms.py +66 -0
- vectara_agentic/_prompts.py +6 -8
- vectara_agentic/_version.py +1 -1
- vectara_agentic/agent.py +304 -79
- vectara_agentic/llm_utils.py +174 -0
- vectara_agentic/tool_utils.py +513 -0
- vectara_agentic/tools.py +73 -452
- vectara_agentic/tools_catalog.py +2 -1
- vectara_agentic/utils.py +25 -150
- {vectara_agentic-0.2.12.dist-info → vectara_agentic-0.2.14.dist-info}/METADATA +355 -236
- vectara_agentic-0.2.14.dist-info/RECORD +33 -0
- {vectara_agentic-0.2.12.dist-info → vectara_agentic-0.2.14.dist-info}/WHEEL +1 -1
- vectara_agentic-0.2.12.dist-info/RECORD +0 -29
- {vectara_agentic-0.2.12.dist-info → vectara_agentic-0.2.14.dist-info}/licenses/LICENSE +0 -0
- {vectara_agentic-0.2.12.dist-info → vectara_agentic-0.2.14.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: vectara_agentic
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.14
|
|
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,18 +16,18 @@ 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.
|
|
20
|
-
Requires-Dist: llama-index-indices-managed-vectara==0.4.
|
|
19
|
+
Requires-Dist: llama-index==0.12.33
|
|
20
|
+
Requires-Dist: llama-index-indices-managed-vectara==0.4.4
|
|
21
21
|
Requires-Dist: llama-index-agent-llm-compiler==0.3.0
|
|
22
22
|
Requires-Dist: llama-index-agent-lats==0.3.0
|
|
23
23
|
Requires-Dist: llama-index-agent-openai==0.4.6
|
|
24
|
-
Requires-Dist: llama-index-llms-openai==0.3.
|
|
24
|
+
Requires-Dist: llama-index-llms-openai==0.3.38
|
|
25
25
|
Requires-Dist: llama-index-llms-anthropic==0.6.10
|
|
26
26
|
Requires-Dist: llama-index-llms-together==0.3.1
|
|
27
27
|
Requires-Dist: llama-index-llms-groq==0.3.1
|
|
28
28
|
Requires-Dist: llama-index-llms-fireworks==0.3.2
|
|
29
29
|
Requires-Dist: llama-index-llms-cohere==0.4.1
|
|
30
|
-
Requires-Dist: llama-index-llms-
|
|
30
|
+
Requires-Dist: llama-index-llms-google-genai==0.1.8
|
|
31
31
|
Requires-Dist: llama-index-llms-bedrock==0.3.8
|
|
32
32
|
Requires-Dist: llama-index-tools-yahoo-finance==0.3.0
|
|
33
33
|
Requires-Dist: llama-index-tools-arxiv==0.3.0
|
|
@@ -39,15 +39,17 @@ Requires-Dist: llama-index-tools-neo4j==0.3.0
|
|
|
39
39
|
Requires-Dist: llama-index-graph-stores-kuzu==0.7.0
|
|
40
40
|
Requires-Dist: llama-index-tools-slack==0.3.0
|
|
41
41
|
Requires-Dist: llama-index-tools-exa==0.3.0
|
|
42
|
+
Requires-Dist: llama-index-tools-wikipedia==0.3.0
|
|
43
|
+
Requires-Dist: llama-index-tools-bing-search==0.3.0
|
|
42
44
|
Requires-Dist: tavily-python==0.5.4
|
|
43
|
-
Requires-Dist: exa-py==1.
|
|
44
|
-
Requires-Dist: openinference-instrumentation-llama-index==
|
|
45
|
-
Requires-Dist: opentelemetry-proto==1.
|
|
46
|
-
Requires-Dist: arize-phoenix==8.
|
|
47
|
-
Requires-Dist: arize-phoenix-otel==0.
|
|
45
|
+
Requires-Dist: exa-py==1.12.0
|
|
46
|
+
Requires-Dist: openinference-instrumentation-llama-index==4.2.1
|
|
47
|
+
Requires-Dist: opentelemetry-proto==1.32.1
|
|
48
|
+
Requires-Dist: arize-phoenix==8.26.1
|
|
49
|
+
Requires-Dist: arize-phoenix-otel==0.9.2
|
|
48
50
|
Requires-Dist: protobuf==5.29.3
|
|
49
51
|
Requires-Dist: tokenizers>=0.20
|
|
50
|
-
Requires-Dist: pydantic==2.
|
|
52
|
+
Requires-Dist: pydantic==2.11.3
|
|
51
53
|
Requires-Dist: retrying==1.3.4
|
|
52
54
|
Requires-Dist: python-dotenv==1.0.1
|
|
53
55
|
Requires-Dist: tiktoken==0.9.0
|
|
@@ -70,7 +72,7 @@ Dynamic: summary
|
|
|
70
72
|
|
|
71
73
|
<p align="center">
|
|
72
74
|
<a href="https://vectara.github.io/py-vectara-agentic">Documentation</a> ·
|
|
73
|
-
<a href="#
|
|
75
|
+
<a href="#example-ai-assistants">Examples</a> ·
|
|
74
76
|
<a href="https://discord.gg/S9dwgCNEFs">Discord</a>
|
|
75
77
|
</p>
|
|
76
78
|
|
|
@@ -84,8 +86,24 @@ Dynamic: summary
|
|
|
84
86
|
<a href="https://twitter.com/vectara">
|
|
85
87
|
<img src="https://img.shields.io/twitter/follow/vectara.svg?style=social&label=Follow%20%40Vectara" alt="Twitter">
|
|
86
88
|
</a>
|
|
89
|
+
<a href="https://pypi.org/project/vectara-agentic/">
|
|
90
|
+
<img src="https://img.shields.io/pypi/v/vectara-agentic.svg" alt="PyPI version">
|
|
91
|
+
</a>
|
|
92
|
+
<a href="https://pypi.org/project/vectara-agentic/">
|
|
93
|
+
<img src="https://img.shields.io/pypi/pyversions/vectara-agentic.svg" alt="Python versions">
|
|
94
|
+
</a>
|
|
87
95
|
</p>
|
|
88
96
|
|
|
97
|
+
## 📑 Table of Contents
|
|
98
|
+
|
|
99
|
+
- [Overview](#-overview)
|
|
100
|
+
- [Quick Start](#-quick-start)
|
|
101
|
+
- [Using Tools](#using-tools)
|
|
102
|
+
- [Advanced Usage: Workflows](#advanced-usage-workflows)
|
|
103
|
+
- [Configuration](#️-configuration)
|
|
104
|
+
- [Contributing](#-contributing)
|
|
105
|
+
- [License](#-license)
|
|
106
|
+
|
|
89
107
|
## ✨ Overview
|
|
90
108
|
|
|
91
109
|
`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.
|
|
@@ -107,9 +125,9 @@ Dynamic: summary
|
|
|
107
125
|
- **Observability:**
|
|
108
126
|
Built-in support with Arize Phoenix for monitoring and feedback.
|
|
109
127
|
- **Workflow Support:**
|
|
110
|
-
Extend your agent
|
|
128
|
+
Extend your agent's capabilities by defining custom workflows using the `run()` method.
|
|
111
129
|
|
|
112
|
-
###
|
|
130
|
+
### Example AI Assistants
|
|
113
131
|
|
|
114
132
|
Check out our example AI assistants:
|
|
115
133
|
|
|
@@ -118,14 +136,14 @@ Check out our example AI assistants:
|
|
|
118
136
|
- [Legal Assistant](https://huggingface.co/spaces/vectara/legal-agent)
|
|
119
137
|
- [EV Assistant](https://huggingface.co/spaces/vectara/ev-assistant)
|
|
120
138
|
|
|
121
|
-
###
|
|
139
|
+
### Prerequisites
|
|
122
140
|
|
|
123
141
|
- [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)
|
|
124
142
|
- A Vectara corpus with an [API key](https://docs.vectara.com/docs/api-keys)
|
|
125
143
|
- [Python 3.10 or higher](https://www.python.org/downloads/)
|
|
126
144
|
- OpenAI API key (or API keys for Anthropic, TOGETHER.AI, Fireworks AI, Bedrock, Cohere, GEMINI or GROQ, if you choose to use them)
|
|
127
145
|
|
|
128
|
-
###
|
|
146
|
+
### Installation
|
|
129
147
|
|
|
130
148
|
```bash
|
|
131
149
|
pip install vectara-agentic
|
|
@@ -133,6 +151,8 @@ pip install vectara-agentic
|
|
|
133
151
|
|
|
134
152
|
## 🚀 Quick Start
|
|
135
153
|
|
|
154
|
+
Let's see how we create a simple AI assistant to answer questions about financial data ingested into Vectara, using `vectara-agentic`.
|
|
155
|
+
|
|
136
156
|
### 1. Initialize the Vectara tool factory
|
|
137
157
|
|
|
138
158
|
```python
|
|
@@ -147,7 +167,7 @@ vec_factory = VectaraToolFactory(
|
|
|
147
167
|
|
|
148
168
|
### 2. Create a Vectara RAG Tool
|
|
149
169
|
|
|
150
|
-
A RAG tool calls the full Vectara RAG pipeline to provide summarized responses to queries grounded in data.
|
|
170
|
+
A RAG tool calls the full Vectara RAG pipeline to provide summarized responses to queries grounded in data. We define two additional arguments (`year` and `ticker` that map to filter attributes in the Vectara corpus):
|
|
151
171
|
|
|
152
172
|
```python
|
|
153
173
|
from pydantic import BaseModel, Field
|
|
@@ -164,48 +184,60 @@ class QueryFinancialReportsArgs(BaseModel):
|
|
|
164
184
|
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').")
|
|
165
185
|
ticker: str = Field(..., description=f"The company ticker. Must be a valid ticket symbol from the list {tickers.keys()}.")
|
|
166
186
|
|
|
167
|
-
|
|
187
|
+
ask_finance = vec_factory.create_rag_tool(
|
|
168
188
|
tool_name="query_financial_reports",
|
|
169
189
|
tool_description="Query financial reports for a company and year",
|
|
170
190
|
tool_args_schema=QueryFinancialReportsArgs,
|
|
171
191
|
lambda_val=0.005,
|
|
172
192
|
summary_num_results=7,
|
|
173
|
-
# Additional arguments
|
|
193
|
+
# Additional Vectara query arguments...
|
|
174
194
|
)
|
|
175
195
|
```
|
|
176
196
|
|
|
177
|
-
Note
|
|
197
|
+
> **Note:** We only defined the `year` and `ticker` arguments in the QueryFinancialReportsArgs model. The `query` argument is automatically added by `create_rag_tool`.
|
|
178
198
|
|
|
179
|
-
|
|
199
|
+
To learn about additional arguments `create_rag_tool`, please see the full [docs](https://vectara.github.io/py-vectara-agentic/latest/).
|
|
180
200
|
|
|
181
201
|
### 3. Create other tools (optional)
|
|
182
202
|
|
|
183
|
-
In addition to RAG tools, you can generate
|
|
203
|
+
In addition to RAG tools or search tools, you can generate additional tools the agent can use. These could be mathematical tools, tools
|
|
184
204
|
that call other APIs to get more information, or any other type of tool.
|
|
185
205
|
|
|
186
|
-
See [Agent Tools](
|
|
206
|
+
See [Agent Tools](#️-agent-tools-at-a-glance) for more information.
|
|
187
207
|
|
|
188
208
|
### 4. Create your agent
|
|
189
209
|
|
|
210
|
+
Here is how we will instantiate our AI Finance Assistant. First define your custom instructions:
|
|
211
|
+
|
|
212
|
+
```python
|
|
213
|
+
financial_assistant_instructions = """
|
|
214
|
+
- You are a helpful financial assistant, with expertise in financial reporting, in conversation with a user.
|
|
215
|
+
- Never discuss politics, and always respond politely.
|
|
216
|
+
- Respond in a compact format by using appropriate units of measure (e.g., K for thousands, M for millions, B for billions).
|
|
217
|
+
- Do not report the same number twice (e.g. $100K and 100,000 USD).
|
|
218
|
+
- Always check the get_company_info and get_valid_years tools to validate company and year are valid.
|
|
219
|
+
- When querying a tool for a numeric value or KPI, use a concise and non-ambiguous description of what you are looking for.
|
|
220
|
+
- If you calculate a metric, make sure you have all the necessary information to complete the calculation. Don't guess.
|
|
221
|
+
"""
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Then just instantiate the `Agent` class:
|
|
225
|
+
|
|
190
226
|
```python
|
|
191
227
|
from vectara_agentic import Agent
|
|
192
228
|
|
|
193
229
|
agent = Agent(
|
|
194
|
-
tools=
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
- 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.
|
|
200
|
-
- When calculating a financial metric, make sure you have all the information from tools to complete the calculation.
|
|
201
|
-
- In many cases you may need to query tools on each sub-metric separately before computing the final metric.
|
|
202
|
-
- 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.
|
|
203
|
-
- Report financial data in a consistent manner. For example if you report revenue in thousands, always report revenue in thousands.
|
|
204
|
-
"""
|
|
230
|
+
tools =
|
|
231
|
+
[ask_finance],
|
|
232
|
+
topic="10-K annual financial reports",
|
|
233
|
+
custom_instructions=financial_assistant_instructions,
|
|
234
|
+
agent_progress_callback=agent_progress_callback
|
|
205
235
|
)
|
|
206
236
|
```
|
|
207
237
|
|
|
208
|
-
|
|
238
|
+
The `topic` parameter helps identify the agent's area of expertise, while `custom_instructions` lets you customize how the agent behaves and presents information. The agent will combine these with its default general instructions to determine its complete behavior.
|
|
239
|
+
|
|
240
|
+
The `agent_progress_callback` argument is an optional function that will be called when various Agent events occur, and can be used to track agent steps.
|
|
209
241
|
|
|
210
242
|
### 5. Run a chat interaction
|
|
211
243
|
|
|
@@ -214,93 +246,41 @@ res = agent.chat("What was the revenue for Apple in 2021?")
|
|
|
214
246
|
print(res.response)
|
|
215
247
|
```
|
|
216
248
|
|
|
217
|
-
Note
|
|
218
|
-
1. `vectara-agentic` also supports `achat()`
|
|
219
|
-
2. The response types from `chat()` and `achat()` are of type `AgentResponse`. If you just need the actual string
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
## Advanced Usage: Workflows
|
|
224
|
-
|
|
225
|
-
In addition to standard chat interactions, `vectara-agentic` supports custom workflows via the `run()` method.
|
|
226
|
-
Workflows allow you to structure multi-step interactions where inputs and outputs are validated using Pydantic models.
|
|
227
|
-
To learn more about workflows read [the documentation](https://docs.llamaindex.ai/en/stable/understanding/workflows/basic_flow/)
|
|
228
|
-
|
|
229
|
-
### Defining a Custom Workflow
|
|
230
|
-
|
|
231
|
-
Create a workflow by subclassing `llama_index.core.workflow.Workflow` and defining the input/output models:
|
|
232
|
-
|
|
233
|
-
```python
|
|
234
|
-
from pydantic import BaseModel
|
|
235
|
-
from llama_index.core.workflow import (
|
|
236
|
-
StartEvent,StopEvent, Workflow, step,
|
|
237
|
-
)
|
|
238
|
-
|
|
239
|
-
class MyWorkflow(Workflow):
|
|
240
|
-
class InputsModel(BaseModel):
|
|
241
|
-
query: str
|
|
242
|
-
|
|
243
|
-
class OutputsModel(BaseModel):
|
|
244
|
-
answer: str
|
|
245
|
-
|
|
246
|
-
@step
|
|
247
|
-
async def my_step(self, ev: StartEvent) -> StopEvent:
|
|
248
|
-
# do something here
|
|
249
|
-
return StopEvent(result="Hello, world!")
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
When the `run()` method in vectara-agentic is invoked, it calls the workflow with the following variables in the StartEvent:
|
|
253
|
-
* `agent`: the agent object used to call `run()` (self)
|
|
254
|
-
* `tools`: the tools provided to the agent. Those can be used as needed in the flow.
|
|
255
|
-
* `llm`: a pointer to a LlamaIndex llm, so it can be used in the workflow. For example, one of the steps may call `llm.acomplete(prompt)`
|
|
256
|
-
* `verbose`: controls whether extra debug information is displayed
|
|
257
|
-
* `inputs`: this is the actual inputs to the workflow provided by the call to `run()` and must be of type `InputsModel`
|
|
258
|
-
|
|
259
|
-
### Using the Workflow with Your Agent
|
|
260
|
-
|
|
261
|
-
When initializing your agent, pass the workflow class using the `workflow_cls` parameter:
|
|
262
|
-
|
|
263
|
-
```python
|
|
264
|
-
agent = Agent(
|
|
265
|
-
tools=[query_financial_reports_tool],
|
|
266
|
-
topic="10-K financial reports",
|
|
267
|
-
custom_instructions="You are a helpful financial assistant.",
|
|
268
|
-
workflow_cls=MyWorkflow, # Provide your custom workflow here
|
|
269
|
-
workflow_timeout=120 # Optional: Set a timeout (default is 120 seconds)
|
|
270
|
-
)
|
|
271
|
-
```
|
|
249
|
+
> **Note:**
|
|
250
|
+
> 1. `vectara-agentic` also supports `achat()` as well as two streaming variants `stream_chat()` and `astream_chat()`.
|
|
251
|
+
> 2. The response types from `chat()` and `achat()` are of type `AgentResponse`. If you just need the actual string
|
|
252
|
+
> response it's available as the `response` variable, or just use `str()`. For advanced use-cases you can look
|
|
253
|
+
> 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).
|
|
272
254
|
|
|
273
|
-
|
|
255
|
+
## Agent Instructions
|
|
274
256
|
|
|
275
|
-
|
|
257
|
+
When creating an agent, it already comes with a set of general base instructions, designed carefully to enhance its operation and improve how the agent works.
|
|
276
258
|
|
|
277
|
-
|
|
278
|
-
# Create an instance of the workflow's input model
|
|
279
|
-
inputs = MyWorkflow.InputsModel(query="What is Vectara?", extra_param=42)
|
|
259
|
+
In addition, you can add `custom_instructions` that are specific to your use case that customize how the agent behaves.
|
|
280
260
|
|
|
281
|
-
|
|
282
|
-
|
|
261
|
+
When writing custom instructions:
|
|
262
|
+
- Focus on behavior and presentation rather than tool usage (that's what tool descriptions are for)
|
|
263
|
+
- Be precise and clear without overcomplicating
|
|
264
|
+
- Consider edge cases and unusual scenarios
|
|
265
|
+
- Avoid over-specifying behavior based on primary use cases
|
|
266
|
+
- Keep instructions focused on how you want the agent to behave and present information
|
|
283
267
|
|
|
284
|
-
|
|
285
|
-
print(workflow_result.answer)
|
|
286
|
-
```
|
|
268
|
+
The agent will combine both the general instructions and your custom instructions to determine its behavior.
|
|
287
269
|
|
|
288
|
-
|
|
270
|
+
It is not recommended to change the general instructions, but it is possible as well to override them with the optional `general_instructions` parameter. If you do change them, your agent may not work as intended, so be careful if overriding these instructions.
|
|
289
271
|
|
|
290
|
-
|
|
291
|
-
This workflow is called `SubQuestionQueryWorkflow` and it works by breaking a complex query into sub-queries and then
|
|
292
|
-
executing each sub-query with the agent until it reaches a good response.
|
|
272
|
+
## 🧰 Defining Tools
|
|
293
273
|
|
|
294
|
-
|
|
274
|
+
### Vectara tools
|
|
295
275
|
|
|
296
|
-
`vectara-agentic` provides two helper functions to connect with Vectara RAG
|
|
276
|
+
`vectara-agentic` provides two helper functions to connect with Vectara RAG:
|
|
297
277
|
* `create_rag_tool()` to create an agent tool that connects with a Vectara corpus for querying.
|
|
298
278
|
* `create_search_tool()` to create a tool to search a Vectara corpus and return a list of matching documents.
|
|
299
279
|
|
|
300
280
|
See the documentation for the full list of arguments for `create_rag_tool()` and `create_search_tool()`,
|
|
301
281
|
to understand how to configure Vectara query performed by those tools.
|
|
302
282
|
|
|
303
|
-
|
|
283
|
+
#### Creating a Vectara RAG tool
|
|
304
284
|
|
|
305
285
|
A Vectara RAG tool is often the main workhorse for any Agentic RAG application, and enables the agent to query
|
|
306
286
|
one or more Vectara RAG corpora.
|
|
@@ -310,15 +290,14 @@ metadata filtering, defined by `tool_args_schema`.
|
|
|
310
290
|
|
|
311
291
|
For example, in the quickstart example the schema is:
|
|
312
292
|
|
|
313
|
-
```
|
|
293
|
+
```python
|
|
314
294
|
class QueryFinancialReportsArgs(BaseModel):
|
|
315
|
-
query: str = Field(..., description="The user query.")
|
|
316
295
|
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').")
|
|
317
296
|
ticker: str = Field(..., description=f"The company ticker. Must be a valid ticket symbol from the list {tickers.keys()}.")
|
|
318
297
|
```
|
|
319
298
|
|
|
320
|
-
|
|
321
|
-
|
|
299
|
+
Remember, the `query` argument is part of the rag_tool that is generated, but `vectara-agentic` creates it and you do
|
|
300
|
+
not need to specify it explicitly.
|
|
322
301
|
|
|
323
302
|
For example, in the example above, the agent may call the `query_financial_reports_tool` tool with
|
|
324
303
|
query='what is the revenue?', year=2022 and ticker='AAPL'. Subsequently the RAG tool will issue
|
|
@@ -335,19 +314,20 @@ There are also additional cool features supported here:
|
|
|
335
314
|
Note that `tool_args_type` is an optional dictionary that indicates the level at which metadata filtering
|
|
336
315
|
is applied for each argument (`doc` or `part`)
|
|
337
316
|
|
|
338
|
-
|
|
317
|
+
#### Creating a Vectara search tool
|
|
339
318
|
|
|
340
319
|
The Vectara search tool allows the agent to list documents that match a query.
|
|
341
320
|
This can be helpful to the agent to answer queries like "how many documents discuss the iPhone?" or other
|
|
342
321
|
similar queries that require a response in terms of a list of matching documents.
|
|
343
322
|
|
|
344
|
-
|
|
323
|
+
### 🛠️ Agent Tools at a Glance
|
|
345
324
|
|
|
346
|
-
`vectara-agentic` provides a few tools out of the box (see ToolsCatalog for details):
|
|
325
|
+
`vectara-agentic` provides a few tools out of the box (see `ToolsCatalog` for details):
|
|
347
326
|
|
|
348
|
-
1.
|
|
327
|
+
**1. Standard tools**
|
|
349
328
|
- `summarize_text`: a tool to summarize a long text into a shorter summary (uses LLM)
|
|
350
329
|
- `rephrase_text`: a tool to rephrase a given text, given a set of rephrase instructions (uses LLM)
|
|
330
|
+
|
|
351
331
|
These tools use an LLM and so would use the `Tools` LLM specified in your `AgentConfig`.
|
|
352
332
|
To instantiate them:
|
|
353
333
|
|
|
@@ -359,30 +339,82 @@ summarize_text = ToolsCatalog(agent_config).summarize_text
|
|
|
359
339
|
This ensures the summarize_text tool is configured with the proper LLM provider and model as
|
|
360
340
|
specified in the Agent configuration.
|
|
361
341
|
|
|
362
|
-
2.
|
|
342
|
+
**2. Legal tools**
|
|
343
|
+
A set of tools for the legal vertical, such as:
|
|
363
344
|
- `summarize_legal_text`: summarize legal text with a certain point of view
|
|
364
345
|
- `critique_as_judge`: critique a legal text as a judge, providing their perspective
|
|
365
346
|
|
|
366
|
-
3.
|
|
347
|
+
**3. Financial tools**
|
|
348
|
+
Based on tools from Yahoo! Finance:
|
|
367
349
|
- tools to understand the financials of a public company like: `balance_sheet`, `income_statement`, `cash_flow`
|
|
368
350
|
- `stock_news`: provides news about a company
|
|
369
351
|
- `stock_analyst_recommendations`: provides stock analyst recommendations for a company.
|
|
370
352
|
|
|
371
|
-
4.
|
|
353
|
+
**4. Database tools**
|
|
354
|
+
Providing tools to inspect and query a database:
|
|
372
355
|
- `list_tables`: list all tables in the database
|
|
373
356
|
- `describe_tables`: describe the schema of tables in the database
|
|
374
357
|
- `load_data`: returns data based on a SQL query
|
|
375
358
|
- `load_sample_data`: returns the first 25 rows of a table
|
|
376
359
|
- `load_unique_values`: returns the top unique values for a given column
|
|
377
360
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
*
|
|
382
|
-
*
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
361
|
+
**5. Additional integrations**
|
|
362
|
+
vectara-agentic includes various other tools from LlamaIndex ToolSpecs:
|
|
363
|
+
|
|
364
|
+
* **Search Tools**
|
|
365
|
+
* Tavily Search: Real-time web search using [Tavily API](https://tavily.com/)
|
|
366
|
+
```python
|
|
367
|
+
from vectara_agentic.tools_catalog import ToolsCatalog
|
|
368
|
+
tavily_tool = ToolsCatalog(agent_config).tavily_search
|
|
369
|
+
```
|
|
370
|
+
* EXA.AI: Advanced web search and data extraction
|
|
371
|
+
```python
|
|
372
|
+
exa_tool = ToolsCatalog(agent_config).exa_search
|
|
373
|
+
```
|
|
374
|
+
* Brave Search: Web search using Brave's search engine
|
|
375
|
+
```python
|
|
376
|
+
brave_tool = ToolsCatalog(agent_config).brave_search
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
* **Academic Tools**
|
|
380
|
+
* arXiv: Search and retrieve academic papers
|
|
381
|
+
```python
|
|
382
|
+
arxiv_tool = ToolsCatalog(agent_config).arxiv_search
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
* **Graph Database Tools**
|
|
386
|
+
* Neo4j: Graph database integration
|
|
387
|
+
```python
|
|
388
|
+
neo4j_tool = ToolsCatalog(agent_config).neo4j_query
|
|
389
|
+
```
|
|
390
|
+
* Kuzu: Lightweight graph database
|
|
391
|
+
```python
|
|
392
|
+
kuzu_tool = ToolsCatalog(agent_config).kuzu_query
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
* **Google Tools**
|
|
396
|
+
* Gmail: Read and send emails
|
|
397
|
+
```python
|
|
398
|
+
gmail_tool = ToolsCatalog(agent_config).gmail
|
|
399
|
+
```
|
|
400
|
+
* Calendar: Manage calendar events
|
|
401
|
+
```python
|
|
402
|
+
calendar_tool = ToolsCatalog(agent_config).calendar
|
|
403
|
+
```
|
|
404
|
+
* Search: Google search integration
|
|
405
|
+
```python
|
|
406
|
+
google_search_tool = ToolsCatalog(agent_config).google_search
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
* **Communication Tools**
|
|
410
|
+
* Slack: Send messages and interact with Slack
|
|
411
|
+
```python
|
|
412
|
+
slack_tool = ToolsCatalog(agent_config).slack
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
For detailed setup instructions and API key requirements, please refer the instructions on [LlamaIndex hub](https://llamahub.ai/?tab=tools) for the specific tool.
|
|
416
|
+
|
|
417
|
+
### Creating custom tools
|
|
386
418
|
|
|
387
419
|
You can create your own tool directly from a Python function using the `create_tool()` method of the `ToolsFactory` class:
|
|
388
420
|
|
|
@@ -393,165 +425,252 @@ def mult_func(x, y):
|
|
|
393
425
|
mult_tool = ToolsFactory().create_tool(mult_func)
|
|
394
426
|
```
|
|
395
427
|
|
|
396
|
-
|
|
397
|
-
and not as nested functions. Nested functions are not supported if you use serialization
|
|
398
|
-
(dumps/loads or from_dict/to_dict).
|
|
428
|
+
> **Important:** When you define your own Python functions as tools, implement them at the top module level,
|
|
429
|
+
> and not as nested functions. Nested functions are not supported if you use serialization
|
|
430
|
+
> (dumps/loads or from_dict/to_dict).
|
|
399
431
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
## Configuring Vectara-agentic
|
|
432
|
+
### Tool Validation
|
|
403
433
|
|
|
404
|
-
|
|
405
|
-
For example:
|
|
434
|
+
When creating an agent, you can enable tool validation by setting `validate_tools=True`. This will check that any tools mentioned in your custom instructions actually exist in the agent's tool set:
|
|
406
435
|
|
|
407
436
|
```python
|
|
408
|
-
agent_config = AgentConfig(
|
|
409
|
-
agent_type = AgentType.REACT,
|
|
410
|
-
main_llm_provider = ModelProvider.ANTHROPIC,
|
|
411
|
-
main_llm_model_name = 'claude-3-5-sonnet-20241022',
|
|
412
|
-
tool_llm_provider = ModelProvider.TOGETHER,
|
|
413
|
-
tool_llm_model_name = 'meta-llama/Llama-3.3-70B-Instruct-Turbo'
|
|
414
|
-
)
|
|
415
|
-
|
|
416
437
|
agent = Agent(
|
|
417
|
-
tools=[
|
|
418
|
-
topic="
|
|
419
|
-
custom_instructions="
|
|
420
|
-
|
|
438
|
+
tools=[...],
|
|
439
|
+
topic="financial reports",
|
|
440
|
+
custom_instructions="Always use the get_company_info tool first...",
|
|
441
|
+
validate_tools=True # Will raise an error if get_company_info tool doesn't exist
|
|
421
442
|
)
|
|
422
443
|
```
|
|
423
444
|
|
|
424
|
-
|
|
425
|
-
- `agent_type`: the agent type. Valid values are `REACT`, `LLMCOMPILER`, `LATS` or `OPENAI` (default: `OPENAI`).
|
|
426
|
-
- `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`).
|
|
427
|
-
- `main_llm_model_name` and `tool_llm_model_name`: agent model name for agent and tools (default depends on provider).
|
|
428
|
-
- `observer`: the observer type; should be `ARIZE_PHOENIX` or if undefined no observation framework will be used.
|
|
429
|
-
- `endpoint_api_key`: a secret key if using the API endpoint option (defaults to `dev-api-key`)
|
|
430
|
-
- `max_reasoning_steps`: the maximum number of reasoning steps (iterations for React and function calls for OpenAI agent, respectively). Defaults to 50.
|
|
445
|
+
This helps catch errors where your instructions reference tools that aren't available to the agent.
|
|
431
446
|
|
|
432
|
-
|
|
447
|
+
## 🔄 Advanced Usage: Workflows
|
|
433
448
|
|
|
434
|
-
|
|
449
|
+
In addition to standard chat interactions, `vectara-agentic` supports custom workflows via the `run()` method.
|
|
450
|
+
Workflows allow you to structure multi-step interactions where inputs and outputs are validated using Pydantic models.
|
|
451
|
+
To learn more about workflows read [the documentation](https://docs.llamaindex.ai/en/stable/understanding/workflows/basic_flow/)
|
|
435
452
|
|
|
436
|
-
|
|
453
|
+
### What are Workflows?
|
|
437
454
|
|
|
438
|
-
|
|
455
|
+
Workflows provide a structured way to handle complex, multi-step interactions with your agent. They're particularly useful when:
|
|
439
456
|
|
|
440
|
-
|
|
457
|
+
- You need to break down complex queries into simpler sub-questions
|
|
458
|
+
- You want to implement a specific sequence of operations
|
|
459
|
+
- You need to maintain state between different steps of a process
|
|
460
|
+
- You want to parallelize certain operations for better performance
|
|
441
461
|
|
|
442
|
-
|
|
462
|
+
### Defining a Custom Workflow
|
|
443
463
|
|
|
444
|
-
|
|
464
|
+
Create a workflow by subclassing `llama_index.core.workflow.Workflow` and defining the input/output models:
|
|
445
465
|
|
|
446
466
|
```python
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
private_llm_api_base="http://vllm-server.company.com/v1",
|
|
452
|
-
private_llm_api_key="TEST_API_KEY",
|
|
453
|
-
)
|
|
454
|
-
agent = Agent(agent_config=config, tools=tools, topic=topic,
|
|
455
|
-
custom_instructions=custom_instructions)
|
|
456
|
-
```
|
|
467
|
+
from pydantic import BaseModel
|
|
468
|
+
from llama_index.core.workflow import (
|
|
469
|
+
StartEvent, StopEvent, Workflow, step,
|
|
470
|
+
)
|
|
457
471
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
specifies the private API key requires to use this service.
|
|
472
|
+
class MyWorkflow(Workflow):
|
|
473
|
+
class InputsModel(BaseModel):
|
|
474
|
+
query: str
|
|
462
475
|
|
|
463
|
-
|
|
476
|
+
class OutputsModel(BaseModel):
|
|
477
|
+
answer: str
|
|
464
478
|
|
|
465
|
-
|
|
479
|
+
@step
|
|
480
|
+
async def my_step(self, ev: StartEvent) -> StopEvent:
|
|
481
|
+
# do something here
|
|
482
|
+
return StopEvent(result="Hello, world!")
|
|
483
|
+
```
|
|
466
484
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
485
|
+
When the `run()` method in vectara-agentic is invoked, it calls the workflow with the following variables in the `StartEvent`:
|
|
486
|
+
* `agent`: the agent object used to call `run()` (self)
|
|
487
|
+
* `tools`: the tools provided to the agent. Those can be used as needed in the flow.
|
|
488
|
+
* `llm`: a pointer to a LlamaIndex llm, so it can be used in the workflow. For example, one of the steps may call `llm.acomplete(prompt)`
|
|
489
|
+
* `verbose`: controls whether extra debug information is displayed
|
|
490
|
+
* `inputs`: this is the actual inputs to the workflow provided by the call to `run()` and must be of type `InputsModel`
|
|
472
491
|
|
|
473
|
-
|
|
492
|
+
If you want to use `agent`, `tools`, `llm` or `verbose` in other events (that are not `StartEvent`), you can store them in
|
|
493
|
+
the `Context` of the Workflow as follows:
|
|
474
494
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
495
|
+
```python
|
|
496
|
+
await ctx.set("agent", ev.agent)
|
|
497
|
+
```
|
|
478
498
|
|
|
479
|
-
|
|
499
|
+
and then in any other event you can pull that agent object with
|
|
480
500
|
|
|
481
|
-
|
|
501
|
+
```python
|
|
502
|
+
agent = await ctx.get("agent")
|
|
503
|
+
```
|
|
482
504
|
|
|
483
|
-
|
|
505
|
+
Similarly you can reuse the `llm`, `tools` or `verbose` arguments within other nodes in the workflow.
|
|
484
506
|
|
|
485
|
-
###
|
|
507
|
+
### Using the Workflow with Your Agent
|
|
486
508
|
|
|
487
|
-
|
|
488
|
-
First, set `VECTARA_AGENTIC_OBSERVER_TYPE` to `ARIZE_PHOENIX` in `AgentConfig` (or env variable).
|
|
509
|
+
When initializing your agent, pass the workflow class using the `workflow_cls` parameter:
|
|
489
510
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
511
|
+
```python
|
|
512
|
+
agent = Agent(
|
|
513
|
+
tools=[query_financial_reports_tool],
|
|
514
|
+
topic="10-K financial reports",
|
|
515
|
+
custom_instructions="You are a helpful financial assistant.",
|
|
516
|
+
workflow_cls=MyWorkflow, # Provide your custom workflow here
|
|
517
|
+
workflow_timeout=120 # Optional: Set a timeout (default is 120 seconds)
|
|
518
|
+
)
|
|
519
|
+
```
|
|
499
520
|
|
|
500
|
-
|
|
501
|
-
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.
|
|
521
|
+
### Running the Workflow
|
|
502
522
|
|
|
503
|
-
|
|
523
|
+
Prepare the inputs using your workflow's `InputsModel` and execute the workflow using `run()`:
|
|
504
524
|
|
|
505
|
-
|
|
525
|
+
```python
|
|
526
|
+
# Create an instance of the workflow's input model
|
|
527
|
+
inputs = MyWorkflow.InputsModel(query="What is Vectara?", extra_param=42)
|
|
506
528
|
|
|
507
|
-
|
|
508
|
-
|
|
529
|
+
# Run the workflow (ensure you're in an async context or use asyncio.run)
|
|
530
|
+
workflow_result = asyncio.run(agent.run(inputs))
|
|
509
531
|
|
|
532
|
+
# Access the output from the workflow's OutputsModel
|
|
533
|
+
print(workflow_result.answer)
|
|
510
534
|
```
|
|
511
|
-
export VECTARA_AGENTIC_API_KEY=<YOUR-ENDPOINT-API-KEY>
|
|
512
|
-
```
|
|
513
535
|
|
|
514
|
-
|
|
536
|
+
### Built-in Workflows
|
|
537
|
+
|
|
538
|
+
`vectara-agentic` includes two workflow implementations that you can use right away:
|
|
515
539
|
|
|
516
|
-
|
|
517
|
-
Initialize the agent and start the FastAPI server by following this example:
|
|
540
|
+
#### 1. `SubQuestionQueryWorkflow`
|
|
518
541
|
|
|
542
|
+
This workflow breaks down complex queries into simpler sub-questions, executes them in parallel, and then combines the answers:
|
|
519
543
|
|
|
544
|
+
```python
|
|
545
|
+
from vectara_agentic.sub_query_workflow import SubQuestionQueryWorkflow
|
|
546
|
+
|
|
547
|
+
agent = Agent(
|
|
548
|
+
tools=[query_financial_reports_tool],
|
|
549
|
+
topic="10-K financial reports",
|
|
550
|
+
custom_instructions="You are a helpful financial assistant.",
|
|
551
|
+
workflow_cls=SubQuestionQueryWorkflow
|
|
552
|
+
)
|
|
553
|
+
|
|
554
|
+
# Run the workflow with a complex query
|
|
555
|
+
inputs = SubQuestionQueryWorkflow.InputsModel(
|
|
556
|
+
query="Compare Apple's revenue growth to Google's between 2020 and 2023"
|
|
557
|
+
)
|
|
558
|
+
result = asyncio.run(agent.run(inputs))
|
|
559
|
+
print(result.response)
|
|
520
560
|
```
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
561
|
+
|
|
562
|
+
The workflow works in three steps:
|
|
563
|
+
1. **Query**: Breaks down the complex query into sub-questions
|
|
564
|
+
2. **Sub-question**: Executes each sub-question in parallel (using 4 workers by default)
|
|
565
|
+
3. **Combine answers**: Synthesizes all the answers into a coherent response
|
|
566
|
+
|
|
567
|
+
#### 2. `SequentialSubQuestionsWorkflow`
|
|
568
|
+
|
|
569
|
+
This workflow is similar to `SubQuestionQueryWorkflow` but executes sub-questions sequentially, where each question can depend on the answer to the previous question:
|
|
570
|
+
|
|
571
|
+
```python
|
|
572
|
+
from vectara_agentic.sub_query_workflow import SequentialSubQuestionsWorkflow
|
|
573
|
+
|
|
574
|
+
agent = Agent(
|
|
575
|
+
tools=[query_financial_reports_tool],
|
|
576
|
+
topic="10-K financial reports",
|
|
577
|
+
custom_instructions="You are a helpful financial assistant.",
|
|
578
|
+
workflow_cls=SequentialSubQuestionsWorkflow
|
|
579
|
+
)
|
|
580
|
+
|
|
581
|
+
# Run the workflow with a complex query that requires sequential reasoning
|
|
582
|
+
inputs = SequentialSubQuestionsWorkflow.InputsModel(
|
|
583
|
+
query="What was the revenue growth rate of the company with the highest market cap in 2022?"
|
|
584
|
+
)
|
|
585
|
+
result = asyncio.run(agent.run(inputs))
|
|
586
|
+
print(result.response)
|
|
525
587
|
```
|
|
526
588
|
|
|
527
|
-
|
|
528
|
-
|
|
589
|
+
The workflow works in two steps:
|
|
590
|
+
1. **Query**: Breaks down the complex query into sequential sub-questions
|
|
591
|
+
2. **Sub-question**: Executes each sub-question in sequence, passing the answer from one question to the next
|
|
592
|
+
|
|
593
|
+
### When to Use Each Workflow Type
|
|
594
|
+
|
|
595
|
+
- **Use SubQuestionQueryWorkflow** when:
|
|
596
|
+
- Your query can be broken down into independent sub-questions
|
|
597
|
+
- You want to parallelize the execution for better performance
|
|
598
|
+
- The sub-questions don't depend on each other's answers
|
|
599
|
+
|
|
600
|
+
- **Use SequentialSubQuestionsWorkflow** when:
|
|
601
|
+
- Your query requires sequential reasoning
|
|
602
|
+
- Each sub-question depends on the answer to the previous question
|
|
603
|
+
- You need to build up information step by step
|
|
604
|
+
|
|
605
|
+
- **Create a custom workflow** when:
|
|
606
|
+
- You have a specific sequence of operations that doesn't fit the built-in workflows
|
|
607
|
+
- You need to implement complex business logic
|
|
608
|
+
- You want to integrate with external systems or APIs in a specific way
|
|
609
|
+
|
|
610
|
+
## 🛠️ Configuration
|
|
611
|
+
|
|
612
|
+
### Configuring Vectara-agentic
|
|
613
|
+
|
|
614
|
+
The main way to control the behavior of `vectara-agentic` is by passing an `AgentConfig` object to your `Agent` when creating it.
|
|
529
615
|
For example:
|
|
530
|
-
```
|
|
531
|
-
start_app(agent, host="0.0.0.0", port=8000)
|
|
532
|
-
```
|
|
533
616
|
|
|
534
|
-
|
|
535
|
-
|
|
617
|
+
```python
|
|
618
|
+
from vectara_agentic import AgentConfig, AgentType, ModelProvider
|
|
536
619
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
620
|
+
agent_config = AgentConfig(
|
|
621
|
+
agent_type = AgentType.REACT,
|
|
622
|
+
main_llm_provider = ModelProvider.ANTHROPIC,
|
|
623
|
+
main_llm_model_name = 'claude-3-5-sonnet-20241022',
|
|
624
|
+
tool_llm_provider = ModelProvider.TOGETHER,
|
|
625
|
+
tool_llm_model_name = 'meta-llama/Llama-3.3-70B-Instruct-Turbo'
|
|
626
|
+
)
|
|
627
|
+
|
|
628
|
+
agent = Agent(
|
|
629
|
+
tools=[query_financial_reports_tool],
|
|
630
|
+
topic="10-K financial reports",
|
|
631
|
+
custom_instructions="You are a helpful financial assistant in conversation with a user.",
|
|
632
|
+
agent_config=agent_config
|
|
633
|
+
)
|
|
541
634
|
```
|
|
542
635
|
|
|
543
|
-
|
|
636
|
+
The `AgentConfig` object may include the following items:
|
|
637
|
+
- `agent_type`: the agent type. Valid values are `REACT`, `LLMCOMPILER`, `LATS` or `OPENAI` (default: `OPENAI`).
|
|
638
|
+
- `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`).
|
|
639
|
+
- `main_llm_model_name` and `tool_llm_model_name`: agent model name for agent and tools (default depends on provider).
|
|
640
|
+
- `observer`: the observer type; should be `ARIZE_PHOENIX` or if undefined no observation framework will be used.
|
|
641
|
+
- `endpoint_api_key`: a secret key if using the API endpoint option (defaults to `dev-api-key`)
|
|
642
|
+
- `max_reasoning_steps`: the maximum number of reasoning steps (iterations for React and function calls for OpenAI agent, respectively). Defaults to 50.
|
|
544
643
|
|
|
545
|
-
|
|
644
|
+
If any of these are not provided, `AgentConfig` first tries to read the values from the OS environment.
|
|
546
645
|
|
|
547
|
-
|
|
646
|
+
### Configuring Vectara tools: `rag_tool`, or `search_tool`
|
|
548
647
|
|
|
549
|
-
|
|
648
|
+
When creating a `VectaraToolFactory`, you can pass in a `vectara_api_key`, and `vectara_corpus_key` to the factory.
|
|
649
|
+
|
|
650
|
+
If not passed in, it will be taken from the environment variables (`VECTARA_API_KEY` and `VECTARA_CORPUS_KEY`). Note that `VECTARA_CORPUS_KEY` can be a single KEY or a comma-separated list of KEYs (if you want to query multiple corpora).
|
|
651
|
+
|
|
652
|
+
These values will be used as credentials when creating Vectara tools - in `create_rag_tool()` and `create_search_tool()`.
|
|
653
|
+
|
|
654
|
+
### Setting up a privately hosted LLM
|
|
655
|
+
|
|
656
|
+
If you want to setup `vectara-agentic` to use your own self-hosted LLM endpoint, follow the example below:
|
|
550
657
|
|
|
551
|
-
|
|
658
|
+
```python
|
|
659
|
+
from vectara_agentic import AgentConfig, AgentType, ModelProvider
|
|
660
|
+
|
|
661
|
+
config = AgentConfig(
|
|
662
|
+
agent_type=AgentType.REACT,
|
|
663
|
+
main_llm_provider=ModelProvider.PRIVATE,
|
|
664
|
+
main_llm_model_name="meta-llama/Meta-Llama-3.1-8B-Instruct",
|
|
665
|
+
private_llm_api_base="http://vllm-server.company.com/v1",
|
|
666
|
+
private_llm_api_key="TEST_API_KEY",
|
|
667
|
+
)
|
|
668
|
+
|
|
669
|
+
agent = Agent(
|
|
670
|
+
agent_config=config,
|
|
671
|
+
tools=tools,
|
|
672
|
+
topic=topic,
|
|
673
|
+
custom_instructions=custom_instructions
|
|
674
|
+
)
|
|
675
|
+
```
|
|
552
676
|
|
|
553
|
-
- Website: [vectara.com](https://vectara.com)
|
|
554
|
-
- Twitter: [@vectara](https://twitter.com/vectara)
|
|
555
|
-
- GitHub: [@vectara](https://github.com/vectara)
|
|
556
|
-
- LinkedIn: [@vectara](https://www.linkedin.com/company/vectara/)
|
|
557
|
-
- Discord: [Join our community](https://discord.gg/GFb8gMz6UH)
|