vectara-agentic 0.4.1__tar.gz → 0.4.3__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.
Files changed (68) hide show
  1. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/PKG-INFO +156 -61
  2. vectara_agentic-0.4.1/vectara_agentic.egg-info/PKG-INFO → vectara_agentic-0.4.3/README.md +123 -102
  3. vectara_agentic-0.4.3/requirements.txt +43 -0
  4. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/__init__.py +1 -0
  5. vectara_agentic-0.4.3/tests/benchmark_models.py +1120 -0
  6. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/conftest.py +18 -16
  7. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/endpoint.py +9 -5
  8. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/run_tests.py +3 -0
  9. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/test_agent.py +52 -8
  10. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/test_agent_type.py +2 -0
  11. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/test_api_endpoint.py +13 -13
  12. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/test_bedrock.py +9 -1
  13. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/test_fallback.py +19 -8
  14. vectara_agentic-0.4.3/tests/test_gemini.py +57 -0
  15. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/test_groq.py +9 -1
  16. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/test_private_llm.py +20 -7
  17. vectara_agentic-0.4.3/tests/test_react_error_handling.py +293 -0
  18. vectara_agentic-0.4.3/tests/test_react_memory.py +257 -0
  19. vectara_agentic-0.4.3/tests/test_react_streaming.py +135 -0
  20. vectara_agentic-0.4.3/tests/test_react_workflow_events.py +395 -0
  21. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/test_return_direct.py +1 -0
  22. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/test_serialization.py +58 -20
  23. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/test_together.py +9 -1
  24. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/test_tools.py +3 -1
  25. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/test_vectara_llms.py +2 -2
  26. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/test_vhc.py +7 -2
  27. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/test_workflow.py +17 -11
  28. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/_callback.py +79 -21
  29. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/_observability.py +19 -0
  30. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/_version.py +1 -1
  31. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/agent.py +89 -21
  32. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/agent_core/factory.py +5 -6
  33. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/agent_core/prompts.py +3 -4
  34. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/agent_core/serialization.py +12 -10
  35. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/agent_core/streaming.py +245 -68
  36. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/agent_core/utils/schemas.py +2 -2
  37. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/llm_utils.py +6 -2
  38. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/sub_query_workflow.py +3 -2
  39. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/tools.py +0 -19
  40. vectara_agentic-0.4.1/README.md → vectara_agentic-0.4.3/vectara_agentic.egg-info/PKG-INFO +197 -27
  41. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic.egg-info/SOURCES.txt +5 -0
  42. vectara_agentic-0.4.3/vectara_agentic.egg-info/requires.txt +43 -0
  43. vectara_agentic-0.4.1/requirements.txt +0 -44
  44. vectara_agentic-0.4.1/tests/test_gemini.py +0 -83
  45. vectara_agentic-0.4.1/vectara_agentic.egg-info/requires.txt +0 -44
  46. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/LICENSE +0 -0
  47. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/MANIFEST.in +0 -0
  48. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/setup.cfg +0 -0
  49. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/setup.py +0 -0
  50. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/test_agent_fallback_memory.py +0 -0
  51. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/test_agent_memory_consistency.py +0 -0
  52. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/test_session_memory.py +0 -0
  53. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/tests/test_streaming.py +0 -0
  54. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/__init__.py +0 -0
  55. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/agent_config.py +0 -0
  56. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/agent_core/__init__.py +0 -0
  57. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/agent_core/utils/__init__.py +0 -0
  58. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/agent_core/utils/hallucination.py +0 -0
  59. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/agent_core/utils/logging.py +0 -0
  60. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/agent_core/utils/tools.py +0 -0
  61. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/agent_endpoint.py +0 -0
  62. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/db_tools.py +0 -0
  63. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/tool_utils.py +0 -0
  64. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/tools_catalog.py +0 -0
  65. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/types.py +0 -0
  66. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic/utils.py +0 -0
  67. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic.egg-info/dependency_links.txt +0 -0
  68. {vectara_agentic-0.4.1 → vectara_agentic-0.4.3}/vectara_agentic.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vectara_agentic
3
- Version: 0.4.1
3
+ Version: 0.4.3
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,44 +16,43 @@ 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.52
20
- Requires-Dist: llama-index-core==0.12.52.post1
21
- Requires-Dist: llama-index-workflow==1.0.1
22
- Requires-Dist: llama-index-cli==0.4.4
23
- Requires-Dist: llama-index-indices-managed-vectara==0.4.5
24
- Requires-Dist: llama-index-agent-openai==0.4.12
25
- Requires-Dist: llama-index-llms-openai==0.4.7
26
- Requires-Dist: llama-index-llms-openai-like==0.4.0
27
- Requires-Dist: llama-index-llms-anthropic==0.7.6
28
- Requires-Dist: llama-index-llms-together==0.3.2
29
- Requires-Dist: llama-index-llms-groq==0.3.2
30
- Requires-Dist: llama-index-llms-cohere==0.5.0
31
- Requires-Dist: llama-index-llms-google-genai==0.2.5
32
- Requires-Dist: llama-index-llms-bedrock-converse==0.7.6
33
- Requires-Dist: llama-index-tools-yahoo-finance==0.3.0
34
- Requires-Dist: llama-index-tools-arxiv==0.3.0
35
- Requires-Dist: llama-index-tools-database==0.3.0
36
- Requires-Dist: llama-index-tools-google==0.5.0
37
- Requires-Dist: llama-index-tools-tavily_research==0.3.0
38
- Requires-Dist: llama_index.tools.brave_search==0.3.0
39
- Requires-Dist: llama-index-tools-neo4j==0.3.0
40
- Requires-Dist: llama-index-tools-waii==0.3.0
41
- Requires-Dist: llama-index-graph-stores-kuzu==0.7.0
42
- Requires-Dist: llama-index-tools-salesforce==0.3.0
43
- Requires-Dist: llama-index-tools-slack==0.3.0
44
- Requires-Dist: llama-index-tools-exa==0.3.0
45
- Requires-Dist: llama-index-tools-wikipedia==0.3.1
46
- Requires-Dist: llama-index-tools-bing-search==0.3.0
47
- Requires-Dist: openai>=1.96.1
48
- Requires-Dist: tavily-python>=0.7.9
49
- Requires-Dist: exa-py>=1.14.8
50
- Requires-Dist: openinference-instrumentation-llama-index==4.3.1
19
+ Requires-Dist: llama-index==0.13.2
20
+ Requires-Dist: llama-index-core==0.13.2
21
+ Requires-Dist: llama-index-workflows==1.3.0
22
+ Requires-Dist: llama-index-cli==0.5.0
23
+ Requires-Dist: llama-index-indices-managed-vectara==0.5.0
24
+ Requires-Dist: llama-index-llms-openai==0.5.2
25
+ Requires-Dist: llama-index-llms-openai-like==0.5.0
26
+ Requires-Dist: llama-index-llms-anthropic==0.8.2
27
+ Requires-Dist: llama-index-llms-together==0.4.0
28
+ Requires-Dist: llama-index-llms-groq==0.4.0
29
+ Requires-Dist: llama-index-llms-cohere==0.6.0
30
+ Requires-Dist: llama-index-llms-google-genai==0.3.0
31
+ Requires-Dist: llama-index-llms-bedrock-converse==0.8.0
32
+ Requires-Dist: llama-index-tools-yahoo-finance==0.4.0
33
+ Requires-Dist: llama-index-tools-arxiv==0.4.0
34
+ Requires-Dist: llama-index-tools-database==0.4.0
35
+ Requires-Dist: llama-index-tools-google==0.6.0
36
+ Requires-Dist: llama-index-tools-tavily_research==0.4.0
37
+ Requires-Dist: llama_index.tools.brave_search==0.4.0
38
+ Requires-Dist: llama-index-tools-neo4j==0.4.0
39
+ Requires-Dist: llama-index-tools-waii==0.4.0
40
+ Requires-Dist: llama-index-graph-stores-kuzu==0.9.0
41
+ Requires-Dist: llama-index-tools-salesforce==0.4.0
42
+ Requires-Dist: llama-index-tools-slack==0.4.0
43
+ Requires-Dist: llama-index-tools-exa==0.4.0
44
+ Requires-Dist: llama-index-tools-wikipedia==0.4.0
45
+ Requires-Dist: llama-index-tools-bing-search==0.4.0
46
+ Requires-Dist: openai>=1.99.3
47
+ Requires-Dist: tavily-python>=0.7.10
48
+ Requires-Dist: exa-py>=1.14.20
49
+ Requires-Dist: openinference-instrumentation-llama-index==4.3.4
51
50
  Requires-Dist: opentelemetry-proto>=1.31.0
52
51
  Requires-Dist: arize-phoenix==10.9.1
53
52
  Requires-Dist: arize-phoenix-otel==0.10.3
54
53
  Requires-Dist: protobuf==5.29.5
55
54
  Requires-Dist: tokenizers>=0.20
56
- Requires-Dist: pydantic==2.11.5
55
+ Requires-Dist: pydantic>=2.11.5
57
56
  Requires-Dist: pandas==2.2.3
58
57
  Requires-Dist: retrying==1.3.4
59
58
  Requires-Dist: python-dotenv==1.0.1
@@ -101,16 +100,17 @@ Dynamic: summary
101
100
 
102
101
  ## 📑 Table of Contents
103
102
 
104
- - [Overview](#-overview)
105
- - [Quick Start](#-quick-start)
106
- - [Using Tools](#using-tools)
107
- - [Advanced Usage: Workflows](#advanced-usage-workflows)
108
- - [Configuration](#️-configuration)
109
- - [Migrating from v0.3.x](#-migrating-from-v03x)
110
- - [Contributing](#-contributing)
111
- - [License](#-license)
103
+ - [Overview](#overview)
104
+ - [🚀 Quick Start](#quick-start)
105
+ - [🗒️ Agent Instructions](#agent-instructions)
106
+ - [🧰 Defining Tools](#defining-tools)
107
+ - [🌊 Streaming & Real-time Responses](#streaming--real-time-responses)
108
+ - [🔍 Vectara Hallucination Correction (VHC)](#vectara-hallucination-correction-vhc)
109
+ - [🔄 Advanced Usage: Workflows](#advanced-usage-workflows)
110
+ - [🛠️ Configuration](#configuration)
111
+ - [📝 Migrating from v0.3.x](#migrating-from-v03x)
112
112
 
113
- ## Overview
113
+ ## Overview
114
114
 
115
115
  `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.
116
116
 
@@ -159,7 +159,7 @@ Check out our example AI assistants:
159
159
  pip install vectara-agentic
160
160
  ```
161
161
 
162
- ## 🚀 Quick Start
162
+ ## Quick Start
163
163
 
164
164
  Let's see how we create a simple AI assistant to answer questions about financial data ingested into Vectara, using `vectara-agentic`.
165
165
 
@@ -182,7 +182,7 @@ A RAG tool calls the full Vectara RAG pipeline to provide summarized responses t
182
182
  ```python
183
183
  from pydantic import BaseModel, Field
184
184
 
185
- years = list(range(2020, 2024))
185
+ years = list(range(2020, 2025))
186
186
  tickers = {
187
187
  "AAPL": "Apple Computer",
188
188
  "GOOG": "Google",
@@ -214,7 +214,7 @@ To learn about additional arguments `create_rag_tool`, please see the full [docs
214
214
  In addition to RAG tools or search tools, you can generate additional tools the agent can use. These could be mathematical tools, tools
215
215
  that call other APIs to get more information, or any other type of tool.
216
216
 
217
- See [Agent Tools](#️-agent-tools-at-a-glance) for more information.
217
+ See [Agent Tools](#agent-tools-at-a-glance) for more information.
218
218
 
219
219
  ### 4. Create your agent
220
220
 
@@ -248,26 +248,67 @@ agent = Agent(
248
248
 
249
249
  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.
250
250
 
251
- 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.
251
+ The `agent_progress_callback` argument is an optional function that will be called when various Agent events occur (tool calls, tool outputs, etc.), and can be used to track agent steps in real-time. This works with both regular chat methods (`chat()`, `achat()`) and streaming methods (`stream_chat()`, `astream_chat()`).
252
252
 
253
253
  ### 5. Run a chat interaction
254
254
 
255
+ You have multiple ways to interact with your agent:
256
+
257
+ **Standard Chat (synchronous)**
255
258
  ```python
256
259
  res = agent.chat("What was the revenue for Apple in 2021?")
257
260
  print(res.response)
258
261
  ```
259
262
 
263
+ **Async Chat**
264
+ ```python
265
+ res = await agent.achat("What was the revenue for Apple in 2021?")
266
+ print(res.response)
267
+ ```
268
+
269
+ **Streaming Chat with AgentStreamingResponse**
270
+ ```python
271
+ # Synchronous streaming
272
+ stream_response = agent.stream_chat("What was the revenue for Apple in 2021?")
273
+
274
+ # Option 1: Process stream manually
275
+ async for chunk in stream_response.async_response_gen():
276
+ print(chunk, end="", flush=True)
277
+
278
+ # Option 2: Get final response without streaming
279
+ # (Note: stream still executes, just not processed chunk by chunk)
280
+
281
+ # Get final response after streaming
282
+ final_response = stream_response.get_response()
283
+ print(f"\nFinal response: {final_response.response}")
284
+ ```
285
+
286
+ **Async Streaming Chat**
287
+ ```python
288
+ # Asynchronous streaming
289
+ stream_response = await agent.astream_chat("What was the revenue for Apple in 2021?")
290
+
291
+ # Process chunks manually
292
+ async for chunk in stream_response.async_response_gen():
293
+ print(chunk, end="", flush=True)
294
+
295
+ # Get final response after streaming
296
+ final_response = await stream_response.aget_response()
297
+ print(f"\nFinal response: {final_response.response}")
298
+ ```
299
+
260
300
  > **Note:**
261
- > 1. `vectara-agentic` also supports `achat()` as well as two streaming variants `stream_chat()` and `astream_chat()`.
262
- > 2. The response types from `chat()` and `achat()` are of type `AgentResponse`. If you just need the actual string
263
- > response it's available as the `response` variable, or just use `str()`. For advanced use-cases you can look
264
- > 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).
301
+ > 1. Both `chat()` and `achat()` return `AgentResponse` objects. Access the text with `.response` or use `str()`.
302
+ > 2. Streaming methods return `AgentStreamingResponse` objects that provide both real-time chunks and final responses.
303
+ > 3. For advanced use-cases, explore other `AgentResponse` properties like `sources` and `metadata`.
304
+ > 4. Streaming is ideal for long responses and real-time user interfaces. See [Streaming & Real-time Responses](#streaming--real-time-responses) for detailed examples.
305
+ > 5. The `agent_progress_callback` works with both regular chat methods (`chat()`, `achat()`) and streaming methods to track tool calls in real-time.
265
306
 
266
307
  ## Agent Instructions
267
308
 
268
- 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.
309
+ When creating an agent, it already comes with a set of general base instructions, designed to enhance its operation and improve how the agent works.
269
310
 
270
- In addition, you can add `custom_instructions` that are specific to your use case that customize how the agent behaves.
311
+ In addition, you can add `custom_instructions` that are specific to your use case to customize how the agent behaves.
271
312
 
272
313
  When writing custom instructions:
273
314
  - Focus on behavior and presentation rather than tool usage (that's what tool descriptions are for)
@@ -280,7 +321,7 @@ The agent will combine both the general instructions and your custom instruction
280
321
 
281
322
  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.
282
323
 
283
- ## 🧰 Defining Tools
324
+ ## Defining Tools
284
325
 
285
326
  ### Vectara tools
286
327
 
@@ -334,7 +375,7 @@ The Vectara search tool allows the agent to list documents that match a query.
334
375
  This can be helpful to the agent to answer queries like "how many documents discuss the iPhone?" or other
335
376
  similar queries that require a response in terms of a list of matching documents.
336
377
 
337
- ### 🛠️ Agent Tools at a Glance
378
+ ### Agent Tools at a Glance
338
379
 
339
380
  `vectara-agentic` provides a few tools out of the box (see `ToolsCatalog` for details):
340
381
 
@@ -482,7 +523,7 @@ mult_tool = ToolsFactory().create_tool(mult_func)
482
523
 
483
524
  #### VHC Eligibility
484
525
 
485
- When creating tools, you can control whether they participate in Vectara Hallucination Correction, by using the `vhc_eligible` parameter:
526
+ When creating tools, you can control whether their output is eligible for Vectara Hallucination Correction, by using the `vhc_eligible` parameter:
486
527
 
487
528
  ```python
488
529
  # Tool that provides factual data - should participate in VHC
@@ -530,7 +571,61 @@ Built-in formatters include `format_as_table`, `format_as_json`, and `format_as_
530
571
 
531
572
  The human-readable format, if available, is used when using Vectara Hallucination Correction.
532
573
 
533
- ## 🔍 Vectara Hallucination Correction (VHC)
574
+ ## Streaming & Real-time Responses
575
+
576
+ `vectara-agentic` provides powerful streaming capabilities for real-time response generation, ideal for interactive applications and long-form content.
577
+
578
+ ### Why Use Streaming?
579
+
580
+ - **Better User Experience**: Users see responses as they're generated instead of waiting for completion
581
+ - **Real-time Feedback**: Perfect for chat interfaces, web applications, and interactive demos
582
+ - **Progress Visibility**: Combined with callbacks, users can see both tool usage and response generation
583
+ - **Reduced Perceived Latency**: Streaming makes applications feel faster and more responsive
584
+
585
+ ### Quick Streaming Example
586
+
587
+ ```python
588
+ # Create streaming response
589
+ stream_response = agent.stream_chat("Analyze the financial performance of tech companies in 2022")
590
+ async for chunk in stream_response.async_response_gen():
591
+ print(chunk, end="", flush=True) # Update your UI here
592
+
593
+ # Get complete response with metadata after streaming completes
594
+ final_response = stream_response.get_response()
595
+ print(f"\nSources consulted: {len(final_response.sources)}")
596
+ ```
597
+
598
+ ### Tool Call Progress Tracking
599
+
600
+ You can track tool calls and outputs in real-time with `agent_progress_callback` - this works with both regular chat and streaming methods:
601
+
602
+ ```python
603
+ from vectara_agentic import AgentStatusType
604
+
605
+ def tool_tracker(status_type, msg, event_id):
606
+ if status_type == AgentStatusType.TOOL_CALL:
607
+ print(f"🔧 Using {msg['tool_name']} with {msg['arguments']}")
608
+ elif status_type == AgentStatusType.TOOL_OUTPUT:
609
+ print(f"📊 {msg['tool_name']} completed")
610
+
611
+ agent = Agent(
612
+ tools=[your_tools],
613
+ agent_progress_callback=tool_tracker
614
+ )
615
+
616
+ # With streaming - see tool calls as they happen, plus streaming response
617
+ stream_response = await agent.astream_chat("Analyze Apple's finances")
618
+ async for chunk in stream_response.async_response_gen():
619
+ print(chunk, end="", flush=True)
620
+
621
+ # With regular chat - see tool calls as they happen, then get final response
622
+ response = await agent.achat("Analyze Apple's finances")
623
+ print(response.response)
624
+ ```
625
+
626
+ For detailed examples including FastAPI integration, Streamlit apps, and decision guidelines, see our [comprehensive streaming documentation](https://vectara.github.io/py-vectara-agentic/latest/usage/#streaming-chat-methods).
627
+
628
+ ## Vectara Hallucination Correction (VHC)
534
629
 
535
630
  `vectara-agentic` provides built-in support for Vectara Hallucination Correction (VHC), which analyzes agent responses and corrects any detected hallucinations based on the factual content retrieved by VHC-eligible tools.
536
631
 
@@ -588,7 +683,7 @@ agent = Agent(
588
683
 
589
684
  This helps catch errors where your instructions reference tools that aren't available to the agent.
590
685
 
591
- ## 🔄 Advanced Usage: Workflows
686
+ ## Advanced Usage: Workflows
592
687
 
593
688
  In addition to standard chat interactions, `vectara-agentic` supports custom workflows via the `run()` method.
594
689
  Workflows allow you to structure multi-step interactions where inputs and outputs are validated using Pydantic models.
@@ -759,7 +854,7 @@ The workflow works in two steps:
759
854
  - You need to implement complex business logic
760
855
  - You want to integrate with external systems or APIs in a specific way
761
856
 
762
- ## 🛠️ Configuration
857
+ ## Configuration
763
858
 
764
859
  ### Configuring Vectara-agentic
765
860
 
@@ -790,7 +885,7 @@ The `AgentConfig` object may include the following items:
790
885
  - `main_llm_provider` and `tool_llm_provider`: the LLM provider for main agent and for the tools. Valid values are `OPENAI`, `ANTHROPIC`, `TOGETHER`, `GROQ`, `COHERE`, `BEDROCK`, `GEMINI` (default: `OPENAI`).
791
886
 
792
887
  > **Note:** Fireworks AI support has been removed. If you were using Fireworks, please migrate to one of the supported providers listed above.
793
- - `main_llm_model_name` and `tool_llm_model_name`: agent model name for agent and tools (default depends on provider: OpenAI uses gpt-4.1, Gemini uses gemini-2.5-flash).
888
+ - `main_llm_model_name` and `tool_llm_model_name`: agent model name for agent and tools (default depends on provider: OpenAI uses gpt-4.1-mini, Gemini uses gemini-2.5-flash-lite).
794
889
  - `observer`: the observer type; should be `ARIZE_PHOENIX` or if undefined no observation framework will be used.
795
890
  - `endpoint_api_key`: a secret key if using the API endpoint option (defaults to `dev-api-key`)
796
891
 
@@ -827,7 +922,7 @@ agent = Agent(
827
922
  )
828
923
  ```
829
924
 
830
- ## 🚀 Migrating from v0.3.x
925
+ ## Migrating from v0.3.x
831
926
 
832
927
  If you're upgrading from v0.3.x, please note the following breaking changes in v0.4.0:
833
928
 
@@ -1,78 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: vectara_agentic
3
- Version: 0.4.1
4
- Summary: A Python package for creating AI Assistants and AI Agents with Vectara
5
- Home-page: https://github.com/vectara/py-vectara-agentic
6
- Author: Ofer Mendelevitch
7
- Author-email: ofer@vectara.com
8
- Project-URL: Documentation, https://vectara.github.io/py-vectara-agentic/
9
- Keywords: LLM,NLP,RAG,Agentic-RAG,AI assistant,AI Agent,Vectara
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: License :: OSI Approved :: Apache Software License
12
- Classifier: Operating System :: OS Independent
13
- Classifier: Development Status :: 4 - Beta
14
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
15
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
- Requires-Python: >=3.10
17
- Description-Content-Type: text/markdown
18
- License-File: LICENSE
19
- Requires-Dist: llama-index==0.12.52
20
- Requires-Dist: llama-index-core==0.12.52.post1
21
- Requires-Dist: llama-index-workflow==1.0.1
22
- Requires-Dist: llama-index-cli==0.4.4
23
- Requires-Dist: llama-index-indices-managed-vectara==0.4.5
24
- Requires-Dist: llama-index-agent-openai==0.4.12
25
- Requires-Dist: llama-index-llms-openai==0.4.7
26
- Requires-Dist: llama-index-llms-openai-like==0.4.0
27
- Requires-Dist: llama-index-llms-anthropic==0.7.6
28
- Requires-Dist: llama-index-llms-together==0.3.2
29
- Requires-Dist: llama-index-llms-groq==0.3.2
30
- Requires-Dist: llama-index-llms-cohere==0.5.0
31
- Requires-Dist: llama-index-llms-google-genai==0.2.5
32
- Requires-Dist: llama-index-llms-bedrock-converse==0.7.6
33
- Requires-Dist: llama-index-tools-yahoo-finance==0.3.0
34
- Requires-Dist: llama-index-tools-arxiv==0.3.0
35
- Requires-Dist: llama-index-tools-database==0.3.0
36
- Requires-Dist: llama-index-tools-google==0.5.0
37
- Requires-Dist: llama-index-tools-tavily_research==0.3.0
38
- Requires-Dist: llama_index.tools.brave_search==0.3.0
39
- Requires-Dist: llama-index-tools-neo4j==0.3.0
40
- Requires-Dist: llama-index-tools-waii==0.3.0
41
- Requires-Dist: llama-index-graph-stores-kuzu==0.7.0
42
- Requires-Dist: llama-index-tools-salesforce==0.3.0
43
- Requires-Dist: llama-index-tools-slack==0.3.0
44
- Requires-Dist: llama-index-tools-exa==0.3.0
45
- Requires-Dist: llama-index-tools-wikipedia==0.3.1
46
- Requires-Dist: llama-index-tools-bing-search==0.3.0
47
- Requires-Dist: openai>=1.96.1
48
- Requires-Dist: tavily-python>=0.7.9
49
- Requires-Dist: exa-py>=1.14.8
50
- Requires-Dist: openinference-instrumentation-llama-index==4.3.1
51
- Requires-Dist: opentelemetry-proto>=1.31.0
52
- Requires-Dist: arize-phoenix==10.9.1
53
- Requires-Dist: arize-phoenix-otel==0.10.3
54
- Requires-Dist: protobuf==5.29.5
55
- Requires-Dist: tokenizers>=0.20
56
- Requires-Dist: pydantic==2.11.5
57
- Requires-Dist: pandas==2.2.3
58
- Requires-Dist: retrying==1.3.4
59
- Requires-Dist: python-dotenv==1.0.1
60
- Requires-Dist: cloudpickle>=3.1.1
61
- Requires-Dist: httpx==0.28.1
62
- Requires-Dist: commonmark==0.9.1
63
- Dynamic: author
64
- Dynamic: author-email
65
- Dynamic: classifier
66
- Dynamic: description
67
- Dynamic: description-content-type
68
- Dynamic: home-page
69
- Dynamic: keywords
70
- Dynamic: license-file
71
- Dynamic: project-url
72
- Dynamic: requires-dist
73
- Dynamic: requires-python
74
- Dynamic: summary
75
-
76
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
77
2
 
78
3
  <p align="center">
@@ -101,16 +26,17 @@ Dynamic: summary
101
26
 
102
27
  ## 📑 Table of Contents
103
28
 
104
- - [Overview](#-overview)
105
- - [Quick Start](#-quick-start)
106
- - [Using Tools](#using-tools)
107
- - [Advanced Usage: Workflows](#advanced-usage-workflows)
108
- - [Configuration](#️-configuration)
109
- - [Migrating from v0.3.x](#-migrating-from-v03x)
110
- - [Contributing](#-contributing)
111
- - [License](#-license)
29
+ - [Overview](#overview)
30
+ - [🚀 Quick Start](#quick-start)
31
+ - [🗒️ Agent Instructions](#agent-instructions)
32
+ - [🧰 Defining Tools](#defining-tools)
33
+ - [🌊 Streaming & Real-time Responses](#streaming--real-time-responses)
34
+ - [🔍 Vectara Hallucination Correction (VHC)](#vectara-hallucination-correction-vhc)
35
+ - [🔄 Advanced Usage: Workflows](#advanced-usage-workflows)
36
+ - [🛠️ Configuration](#configuration)
37
+ - [📝 Migrating from v0.3.x](#migrating-from-v03x)
112
38
 
113
- ## Overview
39
+ ## Overview
114
40
 
115
41
  `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.
116
42
 
@@ -159,7 +85,7 @@ Check out our example AI assistants:
159
85
  pip install vectara-agentic
160
86
  ```
161
87
 
162
- ## 🚀 Quick Start
88
+ ## Quick Start
163
89
 
164
90
  Let's see how we create a simple AI assistant to answer questions about financial data ingested into Vectara, using `vectara-agentic`.
165
91
 
@@ -182,7 +108,7 @@ A RAG tool calls the full Vectara RAG pipeline to provide summarized responses t
182
108
  ```python
183
109
  from pydantic import BaseModel, Field
184
110
 
185
- years = list(range(2020, 2024))
111
+ years = list(range(2020, 2025))
186
112
  tickers = {
187
113
  "AAPL": "Apple Computer",
188
114
  "GOOG": "Google",
@@ -214,7 +140,7 @@ To learn about additional arguments `create_rag_tool`, please see the full [docs
214
140
  In addition to RAG tools or search tools, you can generate additional tools the agent can use. These could be mathematical tools, tools
215
141
  that call other APIs to get more information, or any other type of tool.
216
142
 
217
- See [Agent Tools](#️-agent-tools-at-a-glance) for more information.
143
+ See [Agent Tools](#agent-tools-at-a-glance) for more information.
218
144
 
219
145
  ### 4. Create your agent
220
146
 
@@ -248,26 +174,67 @@ agent = Agent(
248
174
 
249
175
  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.
250
176
 
251
- 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.
177
+ The `agent_progress_callback` argument is an optional function that will be called when various Agent events occur (tool calls, tool outputs, etc.), and can be used to track agent steps in real-time. This works with both regular chat methods (`chat()`, `achat()`) and streaming methods (`stream_chat()`, `astream_chat()`).
252
178
 
253
179
  ### 5. Run a chat interaction
254
180
 
181
+ You have multiple ways to interact with your agent:
182
+
183
+ **Standard Chat (synchronous)**
255
184
  ```python
256
185
  res = agent.chat("What was the revenue for Apple in 2021?")
257
186
  print(res.response)
258
187
  ```
259
188
 
189
+ **Async Chat**
190
+ ```python
191
+ res = await agent.achat("What was the revenue for Apple in 2021?")
192
+ print(res.response)
193
+ ```
194
+
195
+ **Streaming Chat with AgentStreamingResponse**
196
+ ```python
197
+ # Synchronous streaming
198
+ stream_response = agent.stream_chat("What was the revenue for Apple in 2021?")
199
+
200
+ # Option 1: Process stream manually
201
+ async for chunk in stream_response.async_response_gen():
202
+ print(chunk, end="", flush=True)
203
+
204
+ # Option 2: Get final response without streaming
205
+ # (Note: stream still executes, just not processed chunk by chunk)
206
+
207
+ # Get final response after streaming
208
+ final_response = stream_response.get_response()
209
+ print(f"\nFinal response: {final_response.response}")
210
+ ```
211
+
212
+ **Async Streaming Chat**
213
+ ```python
214
+ # Asynchronous streaming
215
+ stream_response = await agent.astream_chat("What was the revenue for Apple in 2021?")
216
+
217
+ # Process chunks manually
218
+ async for chunk in stream_response.async_response_gen():
219
+ print(chunk, end="", flush=True)
220
+
221
+ # Get final response after streaming
222
+ final_response = await stream_response.aget_response()
223
+ print(f"\nFinal response: {final_response.response}")
224
+ ```
225
+
260
226
  > **Note:**
261
- > 1. `vectara-agentic` also supports `achat()` as well as two streaming variants `stream_chat()` and `astream_chat()`.
262
- > 2. The response types from `chat()` and `achat()` are of type `AgentResponse`. If you just need the actual string
263
- > response it's available as the `response` variable, or just use `str()`. For advanced use-cases you can look
264
- > 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).
227
+ > 1. Both `chat()` and `achat()` return `AgentResponse` objects. Access the text with `.response` or use `str()`.
228
+ > 2. Streaming methods return `AgentStreamingResponse` objects that provide both real-time chunks and final responses.
229
+ > 3. For advanced use-cases, explore other `AgentResponse` properties like `sources` and `metadata`.
230
+ > 4. Streaming is ideal for long responses and real-time user interfaces. See [Streaming & Real-time Responses](#streaming--real-time-responses) for detailed examples.
231
+ > 5. The `agent_progress_callback` works with both regular chat methods (`chat()`, `achat()`) and streaming methods to track tool calls in real-time.
265
232
 
266
233
  ## Agent Instructions
267
234
 
268
- 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.
235
+ When creating an agent, it already comes with a set of general base instructions, designed to enhance its operation and improve how the agent works.
269
236
 
270
- In addition, you can add `custom_instructions` that are specific to your use case that customize how the agent behaves.
237
+ In addition, you can add `custom_instructions` that are specific to your use case to customize how the agent behaves.
271
238
 
272
239
  When writing custom instructions:
273
240
  - Focus on behavior and presentation rather than tool usage (that's what tool descriptions are for)
@@ -280,7 +247,7 @@ The agent will combine both the general instructions and your custom instruction
280
247
 
281
248
  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.
282
249
 
283
- ## 🧰 Defining Tools
250
+ ## Defining Tools
284
251
 
285
252
  ### Vectara tools
286
253
 
@@ -334,7 +301,7 @@ The Vectara search tool allows the agent to list documents that match a query.
334
301
  This can be helpful to the agent to answer queries like "how many documents discuss the iPhone?" or other
335
302
  similar queries that require a response in terms of a list of matching documents.
336
303
 
337
- ### 🛠️ Agent Tools at a Glance
304
+ ### Agent Tools at a Glance
338
305
 
339
306
  `vectara-agentic` provides a few tools out of the box (see `ToolsCatalog` for details):
340
307
 
@@ -482,7 +449,7 @@ mult_tool = ToolsFactory().create_tool(mult_func)
482
449
 
483
450
  #### VHC Eligibility
484
451
 
485
- When creating tools, you can control whether they participate in Vectara Hallucination Correction, by using the `vhc_eligible` parameter:
452
+ When creating tools, you can control whether their output is eligible for Vectara Hallucination Correction, by using the `vhc_eligible` parameter:
486
453
 
487
454
  ```python
488
455
  # Tool that provides factual data - should participate in VHC
@@ -530,7 +497,61 @@ Built-in formatters include `format_as_table`, `format_as_json`, and `format_as_
530
497
 
531
498
  The human-readable format, if available, is used when using Vectara Hallucination Correction.
532
499
 
533
- ## 🔍 Vectara Hallucination Correction (VHC)
500
+ ## Streaming & Real-time Responses
501
+
502
+ `vectara-agentic` provides powerful streaming capabilities for real-time response generation, ideal for interactive applications and long-form content.
503
+
504
+ ### Why Use Streaming?
505
+
506
+ - **Better User Experience**: Users see responses as they're generated instead of waiting for completion
507
+ - **Real-time Feedback**: Perfect for chat interfaces, web applications, and interactive demos
508
+ - **Progress Visibility**: Combined with callbacks, users can see both tool usage and response generation
509
+ - **Reduced Perceived Latency**: Streaming makes applications feel faster and more responsive
510
+
511
+ ### Quick Streaming Example
512
+
513
+ ```python
514
+ # Create streaming response
515
+ stream_response = agent.stream_chat("Analyze the financial performance of tech companies in 2022")
516
+ async for chunk in stream_response.async_response_gen():
517
+ print(chunk, end="", flush=True) # Update your UI here
518
+
519
+ # Get complete response with metadata after streaming completes
520
+ final_response = stream_response.get_response()
521
+ print(f"\nSources consulted: {len(final_response.sources)}")
522
+ ```
523
+
524
+ ### Tool Call Progress Tracking
525
+
526
+ You can track tool calls and outputs in real-time with `agent_progress_callback` - this works with both regular chat and streaming methods:
527
+
528
+ ```python
529
+ from vectara_agentic import AgentStatusType
530
+
531
+ def tool_tracker(status_type, msg, event_id):
532
+ if status_type == AgentStatusType.TOOL_CALL:
533
+ print(f"🔧 Using {msg['tool_name']} with {msg['arguments']}")
534
+ elif status_type == AgentStatusType.TOOL_OUTPUT:
535
+ print(f"📊 {msg['tool_name']} completed")
536
+
537
+ agent = Agent(
538
+ tools=[your_tools],
539
+ agent_progress_callback=tool_tracker
540
+ )
541
+
542
+ # With streaming - see tool calls as they happen, plus streaming response
543
+ stream_response = await agent.astream_chat("Analyze Apple's finances")
544
+ async for chunk in stream_response.async_response_gen():
545
+ print(chunk, end="", flush=True)
546
+
547
+ # With regular chat - see tool calls as they happen, then get final response
548
+ response = await agent.achat("Analyze Apple's finances")
549
+ print(response.response)
550
+ ```
551
+
552
+ For detailed examples including FastAPI integration, Streamlit apps, and decision guidelines, see our [comprehensive streaming documentation](https://vectara.github.io/py-vectara-agentic/latest/usage/#streaming-chat-methods).
553
+
554
+ ## Vectara Hallucination Correction (VHC)
534
555
 
535
556
  `vectara-agentic` provides built-in support for Vectara Hallucination Correction (VHC), which analyzes agent responses and corrects any detected hallucinations based on the factual content retrieved by VHC-eligible tools.
536
557
 
@@ -588,7 +609,7 @@ agent = Agent(
588
609
 
589
610
  This helps catch errors where your instructions reference tools that aren't available to the agent.
590
611
 
591
- ## 🔄 Advanced Usage: Workflows
612
+ ## Advanced Usage: Workflows
592
613
 
593
614
  In addition to standard chat interactions, `vectara-agentic` supports custom workflows via the `run()` method.
594
615
  Workflows allow you to structure multi-step interactions where inputs and outputs are validated using Pydantic models.
@@ -759,7 +780,7 @@ The workflow works in two steps:
759
780
  - You need to implement complex business logic
760
781
  - You want to integrate with external systems or APIs in a specific way
761
782
 
762
- ## 🛠️ Configuration
783
+ ## Configuration
763
784
 
764
785
  ### Configuring Vectara-agentic
765
786
 
@@ -790,7 +811,7 @@ The `AgentConfig` object may include the following items:
790
811
  - `main_llm_provider` and `tool_llm_provider`: the LLM provider for main agent and for the tools. Valid values are `OPENAI`, `ANTHROPIC`, `TOGETHER`, `GROQ`, `COHERE`, `BEDROCK`, `GEMINI` (default: `OPENAI`).
791
812
 
792
813
  > **Note:** Fireworks AI support has been removed. If you were using Fireworks, please migrate to one of the supported providers listed above.
793
- - `main_llm_model_name` and `tool_llm_model_name`: agent model name for agent and tools (default depends on provider: OpenAI uses gpt-4.1, Gemini uses gemini-2.5-flash).
814
+ - `main_llm_model_name` and `tool_llm_model_name`: agent model name for agent and tools (default depends on provider: OpenAI uses gpt-4.1-mini, Gemini uses gemini-2.5-flash-lite).
794
815
  - `observer`: the observer type; should be `ARIZE_PHOENIX` or if undefined no observation framework will be used.
795
816
  - `endpoint_api_key`: a secret key if using the API endpoint option (defaults to `dev-api-key`)
796
817
 
@@ -827,7 +848,7 @@ agent = Agent(
827
848
  )
828
849
  ```
829
850
 
830
- ## 🚀 Migrating from v0.3.x
851
+ ## Migrating from v0.3.x
831
852
 
832
853
  If you're upgrading from v0.3.x, please note the following breaking changes in v0.4.0:
833
854