vectara-agentic 0.4.2__py3-none-any.whl → 0.4.4__py3-none-any.whl

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

Potentially problematic release.


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

Files changed (43) hide show
  1. tests/__init__.py +1 -0
  2. tests/benchmark_models.py +547 -372
  3. tests/conftest.py +14 -12
  4. tests/endpoint.py +9 -5
  5. tests/run_tests.py +1 -0
  6. tests/test_agent.py +22 -9
  7. tests/test_agent_fallback_memory.py +4 -4
  8. tests/test_agent_memory_consistency.py +4 -4
  9. tests/test_agent_type.py +2 -0
  10. tests/test_api_endpoint.py +13 -13
  11. tests/test_bedrock.py +9 -1
  12. tests/test_fallback.py +18 -7
  13. tests/test_gemini.py +14 -40
  14. tests/test_groq.py +43 -1
  15. tests/test_openai.py +160 -0
  16. tests/test_private_llm.py +19 -6
  17. tests/test_react_error_handling.py +293 -0
  18. tests/test_react_memory.py +257 -0
  19. tests/test_react_streaming.py +135 -0
  20. tests/test_react_workflow_events.py +395 -0
  21. tests/test_return_direct.py +1 -0
  22. tests/test_serialization.py +58 -20
  23. tests/test_session_memory.py +11 -11
  24. tests/test_streaming.py +0 -44
  25. tests/test_together.py +75 -1
  26. tests/test_tools.py +3 -1
  27. tests/test_vectara_llms.py +2 -2
  28. tests/test_vhc.py +7 -2
  29. tests/test_workflow.py +17 -11
  30. vectara_agentic/_callback.py +79 -21
  31. vectara_agentic/_version.py +1 -1
  32. vectara_agentic/agent.py +65 -27
  33. vectara_agentic/agent_core/serialization.py +5 -9
  34. vectara_agentic/agent_core/streaming.py +245 -64
  35. vectara_agentic/agent_core/utils/schemas.py +2 -2
  36. vectara_agentic/llm_utils.py +64 -15
  37. vectara_agentic/tools.py +88 -31
  38. {vectara_agentic-0.4.2.dist-info → vectara_agentic-0.4.4.dist-info}/METADATA +133 -36
  39. vectara_agentic-0.4.4.dist-info/RECORD +59 -0
  40. vectara_agentic-0.4.2.dist-info/RECORD +0 -54
  41. {vectara_agentic-0.4.2.dist-info → vectara_agentic-0.4.4.dist-info}/WHEEL +0 -0
  42. {vectara_agentic-0.4.2.dist-info → vectara_agentic-0.4.4.dist-info}/licenses/LICENSE +0 -0
  43. {vectara_agentic-0.4.2.dist-info → vectara_agentic-0.4.4.dist-info}/top_level.txt +0 -0
vectara_agentic/tools.py CHANGED
@@ -3,12 +3,12 @@ This module contains the ToolsFactory class for creating agent tools.
3
3
  """
4
4
 
5
5
  import inspect
6
- import re
7
6
  import importlib
8
7
  import os
9
8
  import asyncio
10
-
11
9
  from typing import Callable, List, Dict, Any, Optional, Union
10
+
11
+ from retrying import retry
12
12
  from pydantic import BaseModel, Field
13
13
 
14
14
  from llama_index.core.tools import FunctionTool
@@ -65,6 +65,18 @@ LI_packages = {
65
65
  }
66
66
 
67
67
 
68
+ @retry(stop_max_attempt_number=3, wait_exponential_multiplier=1000, wait_exponential_max=10000)
69
+ def _query_with_retry(vectara_query_engine, query):
70
+ """Execute Vectara query with automatic retry on timeout/failure."""
71
+ return vectara_query_engine.query(query)
72
+
73
+
74
+ @retry(stop_max_attempt_number=3, wait_exponential_multiplier=1000, wait_exponential_max=10000)
75
+ def _retrieve_with_retry(vectara_retriever, query):
76
+ """Execute Vectara retrieve with automatic retry on timeout/failure."""
77
+ return vectara_retriever.retrieve(query)
78
+
79
+
68
80
  class VectaraToolFactory:
69
81
  """
70
82
  A factory class for creating Vectara RAG tools.
@@ -165,6 +177,7 @@ class VectaraToolFactory:
165
177
  vectara_base_url=vectara_base_url,
166
178
  vectara_verify_ssl=vectara_verify_ssl,
167
179
  )
180
+ vectara.vectara_api_timeout = 10
168
181
 
169
182
  # Dynamically generate the search function
170
183
  def search_function(*args: Any, **kwargs: Any) -> list[dict]:
@@ -220,7 +233,7 @@ class VectaraToolFactory:
220
233
  x_source_str="vectara-agentic",
221
234
  verbose=verbose,
222
235
  )
223
- response = vectara_retriever.retrieve(query)
236
+ response = _retrieve_with_retry(vectara_retriever, query)
224
237
 
225
238
  if len(response) == 0:
226
239
  msg = "Vectara Tool failed to retrieve any results for the query."
@@ -370,6 +383,7 @@ class VectaraToolFactory:
370
383
  save_history: bool = False,
371
384
  fcs_threshold: float = 0.0,
372
385
  return_direct: bool = False,
386
+ return_human_readable_output: bool = False,
373
387
  verbose: bool = False,
374
388
  vectara_base_url: str = "https://api.vectara.io",
375
389
  vectara_verify_ssl: bool = True,
@@ -432,6 +446,7 @@ class VectaraToolFactory:
432
446
  fcs_threshold (float, optional): A threshold for factual consistency.
433
447
  If set above 0, the tool notifies the calling agent that it "cannot respond" if FCS is too low.
434
448
  return_direct (bool, optional): Whether the agent should return the tool's response directly.
449
+ return_human_readable_output (bool, optional): Whether to return the output in a human-readable format.
435
450
  verbose (bool, optional): Whether to print verbose output.
436
451
  vectara_base_url (str, optional): The base URL for the Vectara API.
437
452
  vectara_verify_ssl (bool, optional): Whether to verify SSL certificates for the Vectara API.
@@ -447,6 +462,7 @@ class VectaraToolFactory:
447
462
  vectara_base_url=vectara_base_url,
448
463
  vectara_verify_ssl=vectara_verify_ssl,
449
464
  )
465
+ vectara.vectara_api_timeout = 60
450
466
  keys_to_ignore = ["lang", "offset", "len"]
451
467
 
452
468
  # Dynamically generate the RAG function
@@ -473,7 +489,7 @@ class VectaraToolFactory:
473
489
  )
474
490
  return {"text": msg, "metadata": {"args": args, "kwargs": kwargs}}
475
491
 
476
- citations_url_pattern = (
492
+ computed_citations_url_pattern = (
477
493
  (
478
494
  citation_url_pattern
479
495
  if citation_url_pattern is not None
@@ -482,6 +498,8 @@ class VectaraToolFactory:
482
498
  if include_citations
483
499
  else None
484
500
  )
501
+ computed_citations_text_pattern = citation_text_pattern if include_citations else None
502
+
485
503
  vectara_query_engine = vectara.as_query_engine(
486
504
  summary_enabled=True,
487
505
  similarity_top_k=summary_num_results,
@@ -514,15 +532,13 @@ class VectaraToolFactory:
514
532
  frequency_penalty=frequency_penalty,
515
533
  presence_penalty=presence_penalty,
516
534
  citations_style="markdown" if include_citations else None,
517
- citations_url_pattern=citations_url_pattern,
518
- citations_text_pattern=(
519
- citation_text_pattern if include_citations else None
520
- ),
535
+ citations_url_pattern=computed_citations_url_pattern,
536
+ citations_text_pattern=computed_citations_text_pattern,
521
537
  save_history=save_history,
522
538
  x_source_str="vectara-agentic",
523
539
  verbose=verbose,
524
540
  )
525
- response = vectara_query_engine.query(query)
541
+ response = _query_with_retry(vectara_query_engine, query)
526
542
 
527
543
  if len(response.source_nodes) == 0:
528
544
  msg = (
@@ -536,20 +552,6 @@ class VectaraToolFactory:
536
552
  kwargs["query"] = query
537
553
  return {"text": msg, "metadata": {"args": args, "kwargs": kwargs}}
538
554
 
539
- # Extract citation metadata
540
- pattern = r"\[(\d+)\]"
541
- matches = re.findall(pattern, response.response)
542
- citation_numbers = sorted(set(int(match) for match in matches))
543
- citation_metadata = {}
544
- for citation_number in citation_numbers:
545
- metadata = {
546
- k: v
547
- for k, v in response.source_nodes[
548
- citation_number - 1
549
- ].metadata.items()
550
- if k not in keys_to_ignore
551
- }
552
- citation_metadata[str(citation_number)] = metadata
553
555
  fcs = 0.0
554
556
  fcs_str = response.metadata["fcs"] if "fcs" in response.metadata else "0.0"
555
557
  if fcs_str and is_float(fcs_str):
@@ -560,16 +562,71 @@ class VectaraToolFactory:
560
562
  "text": msg,
561
563
  "metadata": {"args": args, "kwargs": kwargs, "fcs": fcs},
562
564
  }
563
- if fcs:
564
- citation_metadata["fcs"] = fcs
565
- res = {"text": response.response, "metadata": citation_metadata}
566
565
 
567
- # Create human-readable output with citation formatting
568
- def format_rag_response(result):
569
- text = result["text"]
570
- return text
566
+ # Add source nodes to tool output
567
+ if ((not return_human_readable_output) and
568
+ (computed_citations_url_pattern is not None) and
569
+ (computed_citations_text_pattern is not None)):
570
+ response_text = str(response.response)
571
+ citation_metadata = []
572
+
573
+ # Converts a dictionary to an object with .<field> access
574
+ def to_obj(data):
575
+ return type('obj', (object,), data)()
576
+
577
+ for source_node in response.source_nodes:
578
+ node = source_node.node
579
+ node_id = node.id_
580
+ node_text = (
581
+ node.text_resource.text if hasattr(node, 'text_resource')
582
+ else getattr(node, 'text', '')
583
+ )
584
+ node_metadata = getattr(node, 'metadata', {})
585
+ for key in keys_to_ignore:
586
+ if key in node_metadata:
587
+ del node_metadata[key]
588
+
589
+ try:
590
+ template_data = {}
591
+
592
+ doc_data = node_metadata.get('document', {})
593
+ template_data['doc'] = to_obj(doc_data)
594
+
595
+ part_data = {k: v for k, v in node_metadata.items() if k != 'document'}
596
+ template_data['part'] = to_obj(part_data)
597
+
598
+ formatted_citation_text = computed_citations_text_pattern.format(**template_data)
599
+ formatted_citation_url = computed_citations_url_pattern.format(**template_data)
600
+ expected_citation = f"[{formatted_citation_text}]({formatted_citation_url})"
601
+
602
+ if expected_citation in response_text:
603
+ citation_metadata.append({
604
+ 'doc_id': node_id,
605
+ 'text': node_text,
606
+ 'metadata': node_metadata,
607
+ 'score': getattr(node, 'score', None)
608
+ })
609
+
610
+ except Exception as e:
611
+ if verbose:
612
+ print(f"Could not format citation for search result {node_id}: {e}")
613
+ continue
614
+
615
+ res = {"text": response.response, "citations": citation_metadata}
616
+ if fcs:
617
+ res["fcs"] = fcs
618
+ else:
619
+ res = {"text": response.response}
620
+
621
+ # Create human-readable output
622
+ if return_human_readable_output:
623
+ def format_rag_response(result):
624
+ text = result["text"]
625
+ return text
626
+
627
+ return create_human_readable_output(res, format_rag_response)
571
628
 
572
- return create_human_readable_output(res, format_rag_response)
629
+ return res
573
630
 
574
631
  class RagToolBaseParams(BaseModel):
575
632
  """Model for the base parameters of the RAG tool."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vectara_agentic
3
- Version: 0.4.2
3
+ Version: 0.4.4
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,19 +16,20 @@ 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.13.1
20
- Requires-Dist: llama-index-core==0.13.1
21
- Requires-Dist: llama-index-workflow==1.0.1
19
+ Requires-Dist: llama-index==0.13.3
20
+ Requires-Dist: llama-index-core==0.13.3
21
+ Requires-Dist: llama-index-workflows==1.3.0
22
22
  Requires-Dist: llama-index-cli==0.5.0
23
23
  Requires-Dist: llama-index-indices-managed-vectara==0.5.0
24
- Requires-Dist: llama-index-llms-openai==0.5.2
24
+ Requires-Dist: llama-index-llms-openai==0.5.4
25
25
  Requires-Dist: llama-index-llms-openai-like==0.5.0
26
- Requires-Dist: llama-index-llms-anthropic==0.8.2
26
+ Requires-Dist: llama-index-llms-anthropic==0.8.5
27
27
  Requires-Dist: llama-index-llms-together==0.4.0
28
28
  Requires-Dist: llama-index-llms-groq==0.4.0
29
29
  Requires-Dist: llama-index-llms-cohere==0.6.0
30
30
  Requires-Dist: llama-index-llms-google-genai==0.3.0
31
- Requires-Dist: llama-index-llms-bedrock-converse==0.8.0
31
+ Requires-Dist: google_genai>=1.31.0
32
+ Requires-Dist: llama-index-llms-bedrock-converse==0.8.2
32
33
  Requires-Dist: llama-index-tools-yahoo-finance==0.4.0
33
34
  Requires-Dist: llama-index-tools-arxiv==0.4.0
34
35
  Requires-Dist: llama-index-tools-database==0.4.0
@@ -54,7 +55,7 @@ Requires-Dist: protobuf==5.29.5
54
55
  Requires-Dist: tokenizers>=0.20
55
56
  Requires-Dist: pydantic>=2.11.5
56
57
  Requires-Dist: pandas==2.2.3
57
- Requires-Dist: retrying==1.3.4
58
+ Requires-Dist: retrying==1.4.2
58
59
  Requires-Dist: python-dotenv==1.0.1
59
60
  Requires-Dist: cloudpickle>=3.1.1
60
61
  Requires-Dist: httpx==0.28.1
@@ -100,16 +101,17 @@ Dynamic: summary
100
101
 
101
102
  ## 📑 Table of Contents
102
103
 
103
- - [Overview](#-overview)
104
- - [Quick Start](#-quick-start)
105
- - [Using Tools](#using-tools)
106
- - [Advanced Usage: Workflows](#advanced-usage-workflows)
107
- - [Configuration](#️-configuration)
108
- - [Migrating from v0.3.x](#-migrating-from-v03x)
109
- - [Contributing](#-contributing)
110
- - [License](#-license)
104
+ - [Overview](#overview)
105
+ - [🚀 Quick Start](#quick-start)
106
+ - [🗒️ Agent Instructions](#agent-instructions)
107
+ - [🧰 Defining Tools](#defining-tools)
108
+ - [🌊 Streaming & Real-time Responses](#streaming--real-time-responses)
109
+ - [🔍 Vectara Hallucination Correction (VHC)](#vectara-hallucination-correction-vhc)
110
+ - [🔄 Advanced Usage: Workflows](#advanced-usage-workflows)
111
+ - [🛠️ Configuration](#configuration)
112
+ - [📝 Migrating from v0.3.x](#migrating-from-v03x)
111
113
 
112
- ## Overview
114
+ ## Overview
113
115
 
114
116
  `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.
115
117
 
@@ -158,7 +160,7 @@ Check out our example AI assistants:
158
160
  pip install vectara-agentic
159
161
  ```
160
162
 
161
- ## 🚀 Quick Start
163
+ ## Quick Start
162
164
 
163
165
  Let's see how we create a simple AI assistant to answer questions about financial data ingested into Vectara, using `vectara-agentic`.
164
166
 
@@ -181,7 +183,7 @@ A RAG tool calls the full Vectara RAG pipeline to provide summarized responses t
181
183
  ```python
182
184
  from pydantic import BaseModel, Field
183
185
 
184
- years = list(range(2020, 2024))
186
+ years = list(range(2020, 2025))
185
187
  tickers = {
186
188
  "AAPL": "Apple Computer",
187
189
  "GOOG": "Google",
@@ -213,7 +215,7 @@ To learn about additional arguments `create_rag_tool`, please see the full [docs
213
215
  In addition to RAG tools or search tools, you can generate additional tools the agent can use. These could be mathematical tools, tools
214
216
  that call other APIs to get more information, or any other type of tool.
215
217
 
216
- See [Agent Tools](#️-agent-tools-at-a-glance) for more information.
218
+ See [Agent Tools](#agent-tools-at-a-glance) for more information.
217
219
 
218
220
  ### 4. Create your agent
219
221
 
@@ -247,26 +249,67 @@ agent = Agent(
247
249
 
248
250
  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.
249
251
 
250
- 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.
252
+ 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()`).
251
253
 
252
254
  ### 5. Run a chat interaction
253
255
 
256
+ You have multiple ways to interact with your agent:
257
+
258
+ **Standard Chat (synchronous)**
254
259
  ```python
255
260
  res = agent.chat("What was the revenue for Apple in 2021?")
256
261
  print(res.response)
257
262
  ```
258
263
 
264
+ **Async Chat**
265
+ ```python
266
+ res = await agent.achat("What was the revenue for Apple in 2021?")
267
+ print(res.response)
268
+ ```
269
+
270
+ **Streaming Chat with AgentStreamingResponse**
271
+ ```python
272
+ # Synchronous streaming
273
+ stream_response = agent.stream_chat("What was the revenue for Apple in 2021?")
274
+
275
+ # Option 1: Process stream manually
276
+ async for chunk in stream_response.async_response_gen():
277
+ print(chunk, end="", flush=True)
278
+
279
+ # Option 2: Get final response without streaming
280
+ # (Note: stream still executes, just not processed chunk by chunk)
281
+
282
+ # Get final response after streaming
283
+ final_response = stream_response.get_response()
284
+ print(f"\nFinal response: {final_response.response}")
285
+ ```
286
+
287
+ **Async Streaming Chat**
288
+ ```python
289
+ # Asynchronous streaming
290
+ stream_response = await agent.astream_chat("What was the revenue for Apple in 2021?")
291
+
292
+ # Process chunks manually
293
+ async for chunk in stream_response.async_response_gen():
294
+ print(chunk, end="", flush=True)
295
+
296
+ # Get final response after streaming
297
+ final_response = await stream_response.aget_response()
298
+ print(f"\nFinal response: {final_response.response}")
299
+ ```
300
+
259
301
  > **Note:**
260
- > 1. `vectara-agentic` also supports `achat()` as well as two streaming variants `stream_chat()` and `astream_chat()`.
261
- > 2. The response types from `chat()` and `achat()` are of type `AgentResponse`. If you just need the actual string
262
- > response it's available as the `response` variable, or just use `str()`. For advanced use-cases you can look
263
- > 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).
302
+ > 1. Both `chat()` and `achat()` return `AgentResponse` objects. Access the text with `.response` or use `str()`.
303
+ > 2. Streaming methods return `AgentStreamingResponse` objects that provide both real-time chunks and final responses.
304
+ > 3. For advanced use-cases, explore other `AgentResponse` properties like `sources` and `metadata`.
305
+ > 4. Streaming is ideal for long responses and real-time user interfaces. See [Streaming & Real-time Responses](#streaming--real-time-responses) for detailed examples.
306
+ > 5. The `agent_progress_callback` works with both regular chat methods (`chat()`, `achat()`) and streaming methods to track tool calls in real-time.
264
307
 
265
308
  ## Agent Instructions
266
309
 
267
- 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.
310
+ 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.
268
311
 
269
- In addition, you can add `custom_instructions` that are specific to your use case that customize how the agent behaves.
312
+ In addition, you can add `custom_instructions` that are specific to your use case to customize how the agent behaves.
270
313
 
271
314
  When writing custom instructions:
272
315
  - Focus on behavior and presentation rather than tool usage (that's what tool descriptions are for)
@@ -279,7 +322,7 @@ The agent will combine both the general instructions and your custom instruction
279
322
 
280
323
  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.
281
324
 
282
- ## 🧰 Defining Tools
325
+ ## Defining Tools
283
326
 
284
327
  ### Vectara tools
285
328
 
@@ -333,7 +376,7 @@ The Vectara search tool allows the agent to list documents that match a query.
333
376
  This can be helpful to the agent to answer queries like "how many documents discuss the iPhone?" or other
334
377
  similar queries that require a response in terms of a list of matching documents.
335
378
 
336
- ### 🛠️ Agent Tools at a Glance
379
+ ### Agent Tools at a Glance
337
380
 
338
381
  `vectara-agentic` provides a few tools out of the box (see `ToolsCatalog` for details):
339
382
 
@@ -481,7 +524,7 @@ mult_tool = ToolsFactory().create_tool(mult_func)
481
524
 
482
525
  #### VHC Eligibility
483
526
 
484
- When creating tools, you can control whether they participate in Vectara Hallucination Correction, by using the `vhc_eligible` parameter:
527
+ When creating tools, you can control whether their output is eligible for Vectara Hallucination Correction, by using the `vhc_eligible` parameter:
485
528
 
486
529
  ```python
487
530
  # Tool that provides factual data - should participate in VHC
@@ -529,7 +572,61 @@ Built-in formatters include `format_as_table`, `format_as_json`, and `format_as_
529
572
 
530
573
  The human-readable format, if available, is used when using Vectara Hallucination Correction.
531
574
 
532
- ## 🔍 Vectara Hallucination Correction (VHC)
575
+ ## Streaming & Real-time Responses
576
+
577
+ `vectara-agentic` provides powerful streaming capabilities for real-time response generation, ideal for interactive applications and long-form content.
578
+
579
+ ### Why Use Streaming?
580
+
581
+ - **Better User Experience**: Users see responses as they're generated instead of waiting for completion
582
+ - **Real-time Feedback**: Perfect for chat interfaces, web applications, and interactive demos
583
+ - **Progress Visibility**: Combined with callbacks, users can see both tool usage and response generation
584
+ - **Reduced Perceived Latency**: Streaming makes applications feel faster and more responsive
585
+
586
+ ### Quick Streaming Example
587
+
588
+ ```python
589
+ # Create streaming response
590
+ stream_response = agent.stream_chat("Analyze the financial performance of tech companies in 2022")
591
+ async for chunk in stream_response.async_response_gen():
592
+ print(chunk, end="", flush=True) # Update your UI here
593
+
594
+ # Get complete response with metadata after streaming completes
595
+ final_response = stream_response.get_response()
596
+ print(f"\nSources consulted: {len(final_response.sources)}")
597
+ ```
598
+
599
+ ### Tool Call Progress Tracking
600
+
601
+ You can track tool calls and outputs in real-time with `agent_progress_callback` - this works with both regular chat and streaming methods:
602
+
603
+ ```python
604
+ from vectara_agentic import AgentStatusType
605
+
606
+ def tool_tracker(status_type, msg, event_id):
607
+ if status_type == AgentStatusType.TOOL_CALL:
608
+ print(f"🔧 Using {msg['tool_name']} with {msg['arguments']}")
609
+ elif status_type == AgentStatusType.TOOL_OUTPUT:
610
+ print(f"📊 {msg['tool_name']} completed")
611
+
612
+ agent = Agent(
613
+ tools=[your_tools],
614
+ agent_progress_callback=tool_tracker
615
+ )
616
+
617
+ # With streaming - see tool calls as they happen, plus streaming response
618
+ stream_response = await agent.astream_chat("Analyze Apple's finances")
619
+ async for chunk in stream_response.async_response_gen():
620
+ print(chunk, end="", flush=True)
621
+
622
+ # With regular chat - see tool calls as they happen, then get final response
623
+ response = await agent.achat("Analyze Apple's finances")
624
+ print(response.response)
625
+ ```
626
+
627
+ 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).
628
+
629
+ ## Vectara Hallucination Correction (VHC)
533
630
 
534
631
  `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.
535
632
 
@@ -587,7 +684,7 @@ agent = Agent(
587
684
 
588
685
  This helps catch errors where your instructions reference tools that aren't available to the agent.
589
686
 
590
- ## 🔄 Advanced Usage: Workflows
687
+ ## Advanced Usage: Workflows
591
688
 
592
689
  In addition to standard chat interactions, `vectara-agentic` supports custom workflows via the `run()` method.
593
690
  Workflows allow you to structure multi-step interactions where inputs and outputs are validated using Pydantic models.
@@ -758,7 +855,7 @@ The workflow works in two steps:
758
855
  - You need to implement complex business logic
759
856
  - You want to integrate with external systems or APIs in a specific way
760
857
 
761
- ## 🛠️ Configuration
858
+ ## Configuration
762
859
 
763
860
  ### Configuring Vectara-agentic
764
861
 
@@ -773,7 +870,7 @@ agent_config = AgentConfig(
773
870
  main_llm_provider = ModelProvider.ANTHROPIC,
774
871
  main_llm_model_name = 'claude-3-5-sonnet-20241022',
775
872
  tool_llm_provider = ModelProvider.TOGETHER,
776
- tool_llm_model_name = 'meta-llama/Llama-3.3-70B-Instruct-Turbo'
873
+ tool_llm_model_name = 'deepseek-ai/DeepSeek-V3'
777
874
  )
778
875
 
779
876
  agent = Agent(
@@ -789,7 +886,7 @@ The `AgentConfig` object may include the following items:
789
886
  - `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`).
790
887
 
791
888
  > **Note:** Fireworks AI support has been removed. If you were using Fireworks, please migrate to one of the supported providers listed above.
792
- - `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).
889
+ - `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).
793
890
  - `observer`: the observer type; should be `ARIZE_PHOENIX` or if undefined no observation framework will be used.
794
891
  - `endpoint_api_key`: a secret key if using the API endpoint option (defaults to `dev-api-key`)
795
892
 
@@ -826,7 +923,7 @@ agent = Agent(
826
923
  )
827
924
  ```
828
925
 
829
- ## 🚀 Migrating from v0.3.x
926
+ ## Migrating from v0.3.x
830
927
 
831
928
  If you're upgrading from v0.3.x, please note the following breaking changes in v0.4.0:
832
929
 
@@ -0,0 +1,59 @@
1
+ tests/__init__.py,sha256=Bmsv0bLu2Hx-b7RZVvEzoodqYxE37hHd7fXCF2cT5pg,176
2
+ tests/benchmark_models.py,sha256=f9SMmPc4h8WL9TQUJaeA22fcbu2oSx8lhhm1ht3fjDE,44125
3
+ tests/conftest.py,sha256=Y9lOptmjCFQ4VI0zmlOF80ERbkskwAn2XEWOk5CwMaQ,9362
4
+ tests/endpoint.py,sha256=bOmjEjLt7PIR3s74M0HOtFj43l4k1s0urBUQNMUVKS0,2749
5
+ tests/run_tests.py,sha256=juM7vnTz7B8Gr6DKD8L5zBPbgBQf_RQnjRkmsQPeWYw,3338
6
+ tests/test_agent.py,sha256=7SvDAvXsy6z3k7YaYVhyzF-Jc6cIBzrZhNXHSOpzwEI,6935
7
+ tests/test_agent_fallback_memory.py,sha256=1LoRHxUM767bGmCeusPlGubX_pIeP5KxIABRwdWLJGo,10862
8
+ tests/test_agent_memory_consistency.py,sha256=D8ivCGp5reJyOK7Q6wDiZlv3bKX4-SEchnqocyib1Po,8966
9
+ tests/test_agent_type.py,sha256=hx0FPKhhP-zaT2Z7MYlrZw10srws8VUQgBoZk2-vUxY,5155
10
+ tests/test_api_endpoint.py,sha256=PrfV6kWvq5icm3zLgrse9isBsR6EkwfUtSdz1ADSUUs,5115
11
+ tests/test_bedrock.py,sha256=4qBip3plouQkHTRU01_sYebop6fiVe3Fnx5vjkMl3H4,2003
12
+ tests/test_fallback.py,sha256=LQtnYoK-NohJL3D3pQnlY0yrIGs2B25j6B3gX3wGM1c,3073
13
+ tests/test_gemini.py,sha256=HVTWmwPFxJ-hjketCkbXa_mOyWXpE-1dG9fu47z00bU,1632
14
+ tests/test_groq.py,sha256=BikJ0AV5-k3kvTUbila9bmIKv2iJy3TQm-Kb_Y23kYw,3378
15
+ tests/test_openai.py,sha256=Uc8wPovmeLgmMItV4OOya6rWlSv7Omre1_B11ajpozU,5396
16
+ tests/test_private_llm.py,sha256=O5sQfZ_NgE2S1-YJ6eMRn1Gz17XkRjEk9O0iHGACRu0,2752
17
+ tests/test_react_error_handling.py,sha256=xAozh77qNSvaEzMDHjw2blbDNVUY-5qfvBldD_YHCQQ,11198
18
+ tests/test_react_memory.py,sha256=3YAPhrWAjmDcT2jm2IfxBx2LSWJGkpYUhWQiVt-qXFs,10177
19
+ tests/test_react_streaming.py,sha256=ZM79HTEvv9sln82vTt9uHfTB0aLLs26PkGf3k4swY4Q,5045
20
+ tests/test_react_workflow_events.py,sha256=sd7CZbgaQIEhb7d0E8VMXC-ivKTQzZvZaRt5QAPFUyA,15118
21
+ tests/test_return_direct.py,sha256=ZhcgkRNGqPQFAYm8moY3HLLIpwdFuAyjShE3F6L16lQ,1522
22
+ tests/test_serialization.py,sha256=DJZ2E_K54t8INwZR0Q8gS1wi-MGbLIheOBcbRmZNcro,5383
23
+ tests/test_session_memory.py,sha256=hnADl59agjpXySY-CBjw6sDPn3s6JketIK6XbLZsLzU,9691
24
+ tests/test_streaming.py,sha256=r-kj6DOB7sn2mkEv_8msGgIYeKXEtWgrDF2qTtCqnZY,1828
25
+ tests/test_together.py,sha256=zR06GoFU0549VYKZRZ5z8bbpvQ6l_vLA0bYLp5SokuU,4770
26
+ tests/test_tools.py,sha256=vvi3FC4SDOwpyKJUFOWCWJ5i3Y474FrKFHnZpo4aFQg,13643
27
+ tests/test_vectara_llms.py,sha256=WoswpfPGhQlBXyOijn5EBX0F2NL1Oq3FDB4wxu7mwXs,2485
28
+ tests/test_vhc.py,sha256=jVojp8ZUDF60yJaYp5pBRdAdNYK1hhhPz_RTmlTEm4g,1980
29
+ tests/test_workflow.py,sha256=43YUF-0YDbiiJrTSYjnyqrC4gvHYuHQp7uuzV2jMdTE,3553
30
+ vectara_agentic/__init__.py,sha256=CfS3QR4drKygcTcyH5zUUDuXXQ3WZtTCytz8W4-loeE,1077
31
+ vectara_agentic/_callback.py,sha256=hYbHU_3sMF4-h0YMierZ9EEWspakNixk7wXAAWztlmU,15364
32
+ vectara_agentic/_observability.py,sha256=rApfdndB2R021iM0xG4MumTSDX1Ba6qbNM0N_AOTbR0,4884
33
+ vectara_agentic/_version.py,sha256=DJAlh_N8BRE6skgMsnQl5zW8lCk-U-7BxMIZrymzu58,65
34
+ vectara_agentic/agent.py,sha256=5eC4BkMPWep8c_LIHSB2N1CvsFLdX6qPAhIpgLR08Gc,49125
35
+ vectara_agentic/agent_config.py,sha256=njqEX2qHJjAp2KpNuJglgZhyWXPK74wjIjBPACD6w7w,4074
36
+ vectara_agentic/agent_endpoint.py,sha256=E_AF-YwxaKqd1-p43X62e1e4ugwOWKIyNq4RWOfsO7A,7402
37
+ vectara_agentic/db_tools.py,sha256=nVZkpGdG63ooGngjX9g7YWyBZRtYMDpvzNasbO696nM,11498
38
+ vectara_agentic/llm_utils.py,sha256=-yBCIDV9euEbgUS9DuIxJly5hzxDbV5vl63uVJsqqKM,9290
39
+ vectara_agentic/sub_query_workflow.py,sha256=1y0fBoUem4i-R34QYlSzcMwM8YhmYgj6S_bWynUtL6w,13001
40
+ vectara_agentic/tool_utils.py,sha256=whnQlk9coeIt01sqUnKnzUorefgn96yWqhtRfHxNL84,25921
41
+ vectara_agentic/tools.py,sha256=yF1y7jPR5jLQXvn-orjCYb0vy_o8WStU36WA8A3guEM,37554
42
+ vectara_agentic/tools_catalog.py,sha256=p6eRram-diJyMz5dZI703auSAm97FfW5wLAMyz_2sB0,4634
43
+ vectara_agentic/types.py,sha256=qKkK8vRNiLvEcMInMyOClK2bD7iFlrWGTkl3fGC6Xic,6117
44
+ vectara_agentic/utils.py,sha256=R9HitEG5K3Q_p2M_teosT181OUxkhs1-hnj98qDYGbE,2545
45
+ vectara_agentic/agent_core/__init__.py,sha256=R3KGbSOiY21FOjbeQ_GyIi6uR9Rz7PTfudO9RjSuEZQ,722
46
+ vectara_agentic/agent_core/factory.py,sha256=Nmmhl98r2Op4qJwq9cgfy7DfrWI62JUfxFXHoBxKHBo,14158
47
+ vectara_agentic/agent_core/prompts.py,sha256=al7SF5pNzOG-KK0lCtTS-HCwVStB6yvE34dgHWJQ_bA,9989
48
+ vectara_agentic/agent_core/serialization.py,sha256=Npfcgm9j8B0ck74uIUgqTGljt8HTpcMCdnWV6CKYBZE,11878
49
+ vectara_agentic/agent_core/streaming.py,sha256=OmjTNEJ25SR788ltyvekVpP83hnv6Tw-MixCwOUK9Kc,26452
50
+ vectara_agentic/agent_core/utils/__init__.py,sha256=y5Xf0IH-5TRxMBRA9IyhmWnGZOVIyqV45P6lX4c2Qsc,762
51
+ vectara_agentic/agent_core/utils/hallucination.py,sha256=XmV7tW-MBN9BrzM79zu0T7zaWil7fIkNQjLfDZE43v4,5312
52
+ vectara_agentic/agent_core/utils/logging.py,sha256=-Ll8iUelml92WuhNWScuY6H-RheyZOTBHNxXQ1UGy0M,1701
53
+ vectara_agentic/agent_core/utils/schemas.py,sha256=4sEyQ-_z-eZJzgxCJf62AuBgV7RN1Azc9mLPPlj6IWg,2769
54
+ vectara_agentic/agent_core/utils/tools.py,sha256=k9Gm-UUQ3ZeGxrkjyrjmjcGxOkvnpylcm_Krnr-0fsY,4748
55
+ vectara_agentic-0.4.4.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
56
+ vectara_agentic-0.4.4.dist-info/METADATA,sha256=6hF6sFKTcDT_8Yap4E5ouDXjN3kRtREtXfo3A0EU2Fs,38906
57
+ vectara_agentic-0.4.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
58
+ vectara_agentic-0.4.4.dist-info/top_level.txt,sha256=Y7TQTFdOYGYodQRltUGRieZKIYuzeZj2kHqAUpfCUfg,22
59
+ vectara_agentic-0.4.4.dist-info/RECORD,,
@@ -1,54 +0,0 @@
1
- tests/__init__.py,sha256=vXhQJCyD1Uhx2NP8b8vIUG3RUhkXyvn7oOir2bmctQU,175
2
- tests/benchmark_models.py,sha256=RSdgnGFA7s2mOIRvi50ChZXwk677QMLbJ1glsv1lcDg,38454
3
- tests/conftest.py,sha256=KjX0iDJIjbj7tsCUXLojZg5lA0PXWLTiuo0ij1Ckew8,9308
4
- tests/endpoint.py,sha256=0URgtz8uydhP_rtpGn_59P1LiWkd3idNlI85LzXnlUE,2744
5
- tests/run_tests.py,sha256=HL7JfRtQHBWj44tbs-WL7vEiehIaAynHO1KmhjqLmpw,3337
6
- tests/test_agent.py,sha256=ntnVDATF3b6mRE9edWeLTexAndW09Kje2SYCo1fn56Q,6775
7
- tests/test_agent_fallback_memory.py,sha256=dWk_lFLEwDUE4moeoJB5ecPUKZSiFt4RryCcKgq1XtQ,10878
8
- tests/test_agent_memory_consistency.py,sha256=bnBEpoT1XIVOfd45PVRtRe5ts2kBYKc0Jk0XSjhNMMo,8982
9
- tests/test_agent_type.py,sha256=d5Zs0iM12DxregfwkJ6UxERWcR5eLgy2ona1znwvK3I,5153
10
- tests/test_api_endpoint.py,sha256=I2UDamPMSLLkgw0pZ5QMM0o_8vVga9-F6ql-S3zlMBs,5136
11
- tests/test_bedrock.py,sha256=74M4k4MWFfZV-mD75R_27HQGTfWcPQ40ijLanT54y-E,1979
12
- tests/test_fallback.py,sha256=SA1d8VymYl3d_tJlq-CSezf43PpBEKwnMTBMFFSe1HU,2969
13
- tests/test_gemini.py,sha256=pvCcfTf79-R49H_WVZou1xx-vVmZEY-19zRtxZeUdD4,2581
14
- tests/test_groq.py,sha256=OmO-VBrKfZYUc11QfZH25jT3FySQrSpv_FS488IqSik,1970
15
- tests/test_private_llm.py,sha256=kVwRUR9gHCiQcTNg01zf50GVvGHuniL6D1xvYWGr0eg,2625
16
- tests/test_return_direct.py,sha256=QsCw-ZGp06cutLkyrLh1U1rggoH7iBiFz4SQ9MIx-Xk,1521
17
- tests/test_serialization.py,sha256=wdVRoy6hoPqCF7SGpYbC2TM7iR2o_IKIRKOBZFAChp0,4824
18
- tests/test_session_memory.py,sha256=lw9SNuLSXDG6MNOBu_4kTPP0XgfZH6E8XCOT-Vrs78I,9786
19
- tests/test_streaming.py,sha256=EBihBb_ZQiGCCvv7Us7YqHN4CxDIQy-XsUSDVO1n5wU,3302
20
- tests/test_together.py,sha256=s0ywOxL-XT_iq970ucamVAPR_CIS9OT72vJB7degNdc,1983
21
- tests/test_tools.py,sha256=869Fl54kmLc44ijykO2QpfcXyAWLDqJ9Niq3XNzhzv8,13621
22
- tests/test_vectara_llms.py,sha256=H1M9OaDvD8_GCFRBm6IdvWejYKn-zm3-Rzt_noCBbiQ,2496
23
- tests/test_vhc.py,sha256=MXyFxckQzfdXcULqwoao4taoQ93qLDvkcf-h2LwUQnE,1974
24
- tests/test_workflow.py,sha256=dwQnHSxvRMVqUtFV8O2KvuyaSKJXFDkVhcffn8mSuJs,3555
25
- vectara_agentic/__init__.py,sha256=CfS3QR4drKygcTcyH5zUUDuXXQ3WZtTCytz8W4-loeE,1077
26
- vectara_agentic/_callback.py,sha256=ueckIfLNa9ykmmEyLqrrZwfDNWrEfyZzJeWktpnkwJQ,12970
27
- vectara_agentic/_observability.py,sha256=rApfdndB2R021iM0xG4MumTSDX1Ba6qbNM0N_AOTbR0,4884
28
- vectara_agentic/_version.py,sha256=AO7HR7HGdC4KVBKvdlO8C1VoiedQvDhEZLC7dDHiuJg,65
29
- vectara_agentic/agent.py,sha256=7tXqdrUGZ0bGIpxoiM7K847o0ktiuwMZ-FmCb6N_4n0,47839
30
- vectara_agentic/agent_config.py,sha256=njqEX2qHJjAp2KpNuJglgZhyWXPK74wjIjBPACD6w7w,4074
31
- vectara_agentic/agent_endpoint.py,sha256=E_AF-YwxaKqd1-p43X62e1e4ugwOWKIyNq4RWOfsO7A,7402
32
- vectara_agentic/db_tools.py,sha256=nVZkpGdG63ooGngjX9g7YWyBZRtYMDpvzNasbO696nM,11498
33
- vectara_agentic/llm_utils.py,sha256=Ac14_lHGvog-hYGGX4e7yZMRnp2ZXcPrpOnnUy7oBZE,7604
34
- vectara_agentic/sub_query_workflow.py,sha256=1y0fBoUem4i-R34QYlSzcMwM8YhmYgj6S_bWynUtL6w,13001
35
- vectara_agentic/tool_utils.py,sha256=whnQlk9coeIt01sqUnKnzUorefgn96yWqhtRfHxNL84,25921
36
- vectara_agentic/tools.py,sha256=pb828u-tDps98N_R3U3_bCcnD9L3w5jdmhScduai74I,34852
37
- vectara_agentic/tools_catalog.py,sha256=p6eRram-diJyMz5dZI703auSAm97FfW5wLAMyz_2sB0,4634
38
- vectara_agentic/types.py,sha256=qKkK8vRNiLvEcMInMyOClK2bD7iFlrWGTkl3fGC6Xic,6117
39
- vectara_agentic/utils.py,sha256=R9HitEG5K3Q_p2M_teosT181OUxkhs1-hnj98qDYGbE,2545
40
- vectara_agentic/agent_core/__init__.py,sha256=R3KGbSOiY21FOjbeQ_GyIi6uR9Rz7PTfudO9RjSuEZQ,722
41
- vectara_agentic/agent_core/factory.py,sha256=Nmmhl98r2Op4qJwq9cgfy7DfrWI62JUfxFXHoBxKHBo,14158
42
- vectara_agentic/agent_core/prompts.py,sha256=al7SF5pNzOG-KK0lCtTS-HCwVStB6yvE34dgHWJQ_bA,9989
43
- vectara_agentic/agent_core/serialization.py,sha256=WwV40KGdN_cC6kACjdHuRCmyDBGhV5YOJ5KoHLXpSlg,12053
44
- vectara_agentic/agent_core/streaming.py,sha256=ViCYos_08o-TQZtNORFs8gr5PNkN4X0hBTNVH32tNAw,17665
45
- vectara_agentic/agent_core/utils/__init__.py,sha256=y5Xf0IH-5TRxMBRA9IyhmWnGZOVIyqV45P6lX4c2Qsc,762
46
- vectara_agentic/agent_core/utils/hallucination.py,sha256=XmV7tW-MBN9BrzM79zu0T7zaWil7fIkNQjLfDZE43v4,5312
47
- vectara_agentic/agent_core/utils/logging.py,sha256=-Ll8iUelml92WuhNWScuY6H-RheyZOTBHNxXQ1UGy0M,1701
48
- vectara_agentic/agent_core/utils/schemas.py,sha256=e7xhJBevgK7IM8cRT5hoO67T-Ep_FhNGp72Zo0OC_Jo,2853
49
- vectara_agentic/agent_core/utils/tools.py,sha256=k9Gm-UUQ3ZeGxrkjyrjmjcGxOkvnpylcm_Krnr-0fsY,4748
50
- vectara_agentic-0.4.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
51
- vectara_agentic-0.4.2.dist-info/METADATA,sha256=QeXPh5PCHd76YKrrs7rI6hCYFGEWtJCYhZtPneWM5Gg,35010
52
- vectara_agentic-0.4.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
53
- vectara_agentic-0.4.2.dist-info/top_level.txt,sha256=Y7TQTFdOYGYodQRltUGRieZKIYuzeZj2kHqAUpfCUfg,22
54
- vectara_agentic-0.4.2.dist-info/RECORD,,