vectara-agentic 0.1.8__tar.gz → 0.1.9__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 (22) hide show
  1. {vectara_agentic-0.1.8/vectara_agentic.egg-info → vectara_agentic-0.1.9}/PKG-INFO +22 -2
  2. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/README.md +20 -1
  3. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/requirements.txt +1 -0
  4. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/setup.py +1 -1
  5. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/vectara_agentic/__init__.py +1 -1
  6. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/vectara_agentic/_prompts.py +4 -3
  7. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/vectara_agentic/agent.py +17 -9
  8. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/vectara_agentic/tools.py +13 -10
  9. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9/vectara_agentic.egg-info}/PKG-INFO +22 -2
  10. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/vectara_agentic.egg-info/requires.txt +1 -0
  11. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/LICENSE +0 -0
  12. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/MANIFEST.in +0 -0
  13. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/setup.cfg +0 -0
  14. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/tests/test_agent.py +0 -0
  15. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/tests/test_tools.py +0 -0
  16. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/vectara_agentic/_callback.py +0 -0
  17. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/vectara_agentic/tools_catalog.py +0 -0
  18. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/vectara_agentic/types.py +0 -0
  19. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/vectara_agentic/utils.py +0 -0
  20. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/vectara_agentic.egg-info/SOURCES.txt +0 -0
  21. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/vectara_agentic.egg-info/dependency_links.txt +0 -0
  22. {vectara_agentic-0.1.8 → vectara_agentic-0.1.9}/vectara_agentic.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vectara_agentic
3
- Version: 0.1.8
3
+ Version: 0.1.9
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
@@ -31,6 +31,7 @@ Requires-Dist: llama-index-tools-arxiv==0.2.0
31
31
  Requires-Dist: llama-index-tools-database==0.2.0
32
32
  Requires-Dist: llama-index-tools-google==0.2.0
33
33
  Requires-Dist: llama-index-tools-tavily_research==0.2.0
34
+ Requires-Dist: llama-index-callbacks-arize-phoenix==0.2.1
34
35
  Requires-Dist: pydantic==2.8.2
35
36
  Requires-Dist: retrying==1.3.4
36
37
  Requires-Dist: pymongo==4.6.1
@@ -63,7 +64,7 @@ Requires-Dist: tiktoken==0.7.0
63
64
  - [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)
64
65
  - A Vectara corpus with an [API key](https://docs.vectara.com/docs/api-keys)
65
66
  - [Python 3.10 or higher](https://www.python.org/downloads/)
66
- - OpenAI API key (or API keys for Anthropic, TOGETHER.AI, Fireworks AI, Cohere, or GROQ)
67
+ - OpenAI API key (or API keys for Anthropic, TOGETHER.AI, Fireworks AI, Cohere or GROQ)
67
68
 
68
69
  ## Installation
69
70
 
@@ -181,6 +182,25 @@ The `Agent` class defines a few helpful methods to help you understand the inter
181
182
  * The `report()` method prints out the agent object’s type, the tools, and the LLMs used for the main agent and tool calling.
182
183
  * The `token_counts()` method tells you how many tokens you have used in the current session for both the main agent and tool calling LLMs. This can be helpful if you want to track spend by token.
183
184
 
185
+ ## Observability
186
+
187
+ vectara-agentic supports observability via the existing integration of LlamaIndex and Arize Phoenix.
188
+ To enable tracing of your vectara-agentic assistant, follow these steps (adapted from [here](https://docs.llamaindex.ai/en/stable/module_guides/observability/)):
189
+ 1. Go to `https://llamatrace.com/login` an create an account, then create an API key and put it in the `PHOENIX_API_KEY` variable
190
+ 2. `os["VECTARA_AGENTIC_OBSERVER_TYPE"] = "ARIZE_PHOENIX"`: to enable Arize Phoenix observability
191
+ 3. `os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"api_key={PHOENIX_API_KEY}"`
192
+
193
+ Now when you run your agent, all metrics are sent to LlamaTrace and recorded. You can view them at `https://llamatrace.com`.
194
+ If you do not include the `OTEL_EXPORTER_OTLP_HEADERS` a local instance of Arize Phoenix will be setup instead and you can view it at `http://localhost:6006`
195
+
196
+ ## About Custom Instructions
197
+
198
+ The custom instructions you provide to the agent guide its behavior.
199
+ Here are some guidelines when creating your instructions:
200
+ - Write precise and clear instructions, without overcomplicating.
201
+ - Consider edge cases and unusual or atypical scenarios.
202
+ - Be cautious to not over-specify behavior based on your primary use-case, as it may limit the agent's ability to behave properly in others.
203
+
184
204
  ## Examples
185
205
 
186
206
  Check out our example AI assistants:
@@ -24,7 +24,7 @@
24
24
  - [Vectara account](https://console.vectara.com/signup/?utm_source=github&utm_medium=code&utm_term=DevRel&utm_content=vectara-agentic&utm_campaign=github-code-DevRel-vectara-agentic)
25
25
  - A Vectara corpus with an [API key](https://docs.vectara.com/docs/api-keys)
26
26
  - [Python 3.10 or higher](https://www.python.org/downloads/)
27
- - OpenAI API key (or API keys for Anthropic, TOGETHER.AI, Fireworks AI, Cohere, or GROQ)
27
+ - OpenAI API key (or API keys for Anthropic, TOGETHER.AI, Fireworks AI, Cohere or GROQ)
28
28
 
29
29
  ## Installation
30
30
 
@@ -142,6 +142,25 @@ The `Agent` class defines a few helpful methods to help you understand the inter
142
142
  * The `report()` method prints out the agent object’s type, the tools, and the LLMs used for the main agent and tool calling.
143
143
  * The `token_counts()` method tells you how many tokens you have used in the current session for both the main agent and tool calling LLMs. This can be helpful if you want to track spend by token.
144
144
 
145
+ ## Observability
146
+
147
+ vectara-agentic supports observability via the existing integration of LlamaIndex and Arize Phoenix.
148
+ To enable tracing of your vectara-agentic assistant, follow these steps (adapted from [here](https://docs.llamaindex.ai/en/stable/module_guides/observability/)):
149
+ 1. Go to `https://llamatrace.com/login` an create an account, then create an API key and put it in the `PHOENIX_API_KEY` variable
150
+ 2. `os["VECTARA_AGENTIC_OBSERVER_TYPE"] = "ARIZE_PHOENIX"`: to enable Arize Phoenix observability
151
+ 3. `os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"api_key={PHOENIX_API_KEY}"`
152
+
153
+ Now when you run your agent, all metrics are sent to LlamaTrace and recorded. You can view them at `https://llamatrace.com`.
154
+ If you do not include the `OTEL_EXPORTER_OTLP_HEADERS` a local instance of Arize Phoenix will be setup instead and you can view it at `http://localhost:6006`
155
+
156
+ ## About Custom Instructions
157
+
158
+ The custom instructions you provide to the agent guide its behavior.
159
+ Here are some guidelines when creating your instructions:
160
+ - Write precise and clear instructions, without overcomplicating.
161
+ - Consider edge cases and unusual or atypical scenarios.
162
+ - Be cautious to not over-specify behavior based on your primary use-case, as it may limit the agent's ability to behave properly in others.
163
+
145
164
  ## Examples
146
165
 
147
166
  Check out our example AI assistants:
@@ -13,6 +13,7 @@ llama-index-tools-arxiv==0.2.0
13
13
  llama-index-tools-database==0.2.0
14
14
  llama-index-tools-google==0.2.0
15
15
  llama-index-tools-tavily_research==0.2.0
16
+ llama-index-callbacks-arize-phoenix==0.2.1
16
17
  pydantic==2.8.2
17
18
  retrying==1.3.4
18
19
  pymongo==4.6.1
@@ -8,7 +8,7 @@ def read_requirements():
8
8
 
9
9
  setup(
10
10
  name="vectara_agentic",
11
- version="0.1.8",
11
+ version="0.1.9",
12
12
  author="Ofer Mendelevitch",
13
13
  author_email="ofer@vectara.com",
14
14
  description="A Python package for creating AI Assistants and AI Agents with Vectara",
@@ -3,7 +3,7 @@ vectara_agentic package.
3
3
  """
4
4
 
5
5
  # Define the package version
6
- __version__ = "0.1.8"
6
+ __version__ = "0.1.9"
7
7
 
8
8
  # Import classes and functions from modules
9
9
  # from .module1 import Class1, function1
@@ -88,16 +88,17 @@ If this format is used, the user will respond in the following format:
88
88
  Observation: tool response
89
89
  ```
90
90
 
91
- You should keep repeating the above format till you have enough information to answer the question without using any more tools. At that point, you MUST respond in the one of the following two formats:
91
+ You should keep repeating the above format till you have enough information to answer the question without using any more tools.
92
+ At that point, you MUST respond in the one of the following two formats (and do not include any Action):
92
93
 
93
94
  ```
94
95
  Thought: I can answer without using any more tools. I'll use the user's language to answer
95
- Answer: [your answer here (In the same language as the user's question)]
96
+ Answer: [your answer here (In the same language as the user's question, and maintain any references/citations)]
96
97
  ```
97
98
 
98
99
  ```
99
100
  Thought: I cannot answer the question with the provided tools.
100
- Answer: [your answer here (In the same language as the user's question)]
101
+ Answer: [your answer here (In the same language as the user's question, and maintain any references/citations)]
101
102
  ```
102
103
 
103
104
  ## Current Conversation
@@ -1,16 +1,18 @@
1
1
  """
2
2
  This module contains the Agent class for handling different types of agents and their interactions.
3
3
  """
4
-
5
4
  from typing import List, Callable, Optional
6
5
  import os
7
6
  from datetime import date
8
7
  import time
9
8
 
9
+ import logging
10
+ logger = logging.getLogger('opentelemetry.exporter.otlp.proto.http.trace_exporter')
11
+ logger.setLevel(logging.CRITICAL)
12
+
10
13
  from retrying import retry
11
14
  from pydantic import Field, create_model
12
15
 
13
-
14
16
  from llama_index.core.tools import FunctionTool
15
17
  from llama_index.core.agent import ReActAgent
16
18
  from llama_index.core.agent.react.formatter import ReActChatFormatter
@@ -21,6 +23,7 @@ from llama_index.agent.openai import OpenAIAgent
21
23
  from llama_index.core.memory import ChatMemoryBuffer
22
24
  from llama_index.core import set_global_handler
23
25
 
26
+ import phoenix as px
24
27
 
25
28
  from dotenv import load_dotenv
26
29
 
@@ -113,7 +116,7 @@ class Agent:
113
116
  memory=memory,
114
117
  verbose=verbose,
115
118
  react_chat_formatter=ReActChatFormatter(system_header=prompt),
116
- max_iterations=20,
119
+ max_iterations=30,
117
120
  callable_manager=callback_manager,
118
121
  )
119
122
  elif self.agent_type == AgentType.OPENAI:
@@ -124,7 +127,7 @@ class Agent:
124
127
  memory=memory,
125
128
  verbose=verbose,
126
129
  callable_manager=callback_manager,
127
- max_function_calls=10,
130
+ max_function_calls=20,
128
131
  system_prompt=prompt,
129
132
  )
130
133
  elif self.agent_type == AgentType.LLMCOMPILER:
@@ -139,8 +142,13 @@ class Agent:
139
142
 
140
143
  observer = ObserverType(os.getenv("VECTARA_AGENTIC_OBSERVER_TYPE", "NO_OBSERVER"))
141
144
  if observer == ObserverType.ARIZE_PHOENIX:
142
- set_global_handler("arize_phoenix", endpoint="https://llamatrace.com/v1/traces")
143
- print("Arize Phoenix observer set.")
145
+ if os.environ.get("OTEL_EXPORTER_OTLP_HEADERS", None):
146
+ set_global_handler("arize_phoenix", endpoint="https://llamatrace.com/v1/traces")
147
+ print("Arize Phoenix observer set. https://llamatrace.com")
148
+ else:
149
+ px.launch_app()
150
+ set_global_handler("arize_phoenix", endpoint="http://localhost:6006/v1/traces")
151
+ print("Arize Phoenix observer set. http://localhost:6006/.")
144
152
  else:
145
153
  print("No observer set.")
146
154
 
@@ -174,11 +182,11 @@ class Agent:
174
182
  def from_corpus(
175
183
  cls,
176
184
  tool_name: str,
177
- vectara_customer_id: str,
178
- vectara_corpus_id: str,
179
- vectara_api_key: str,
180
185
  data_description: str,
181
186
  assistant_specialty: str,
187
+ vectara_customer_id: str = str(os.environ.get("VECTARA_CUSTOMER_ID", "")),
188
+ vectara_corpus_id: str = str(os.environ.get("VECTARA_CORPUS_ID", "")),
189
+ vectara_api_key: str = str(os.environ.get("VECTARA_API_KEY", "")),
182
190
  verbose: bool = False,
183
191
  vectara_filter_fields: list[dict] = [],
184
192
  vectara_lambda_val: float = 0.005,
@@ -5,6 +5,7 @@ This module contains the ToolsFactory class for creating agent tools.
5
5
  import inspect
6
6
  import re
7
7
  import importlib
8
+ import os
8
9
 
9
10
  from typing import Callable, List, Any, Optional, Type
10
11
  from pydantic import BaseModel, Field
@@ -94,9 +95,9 @@ class VectaraToolFactory:
94
95
 
95
96
  def __init__(
96
97
  self,
97
- vectara_customer_id: str,
98
- vectara_corpus_id: str,
99
- vectara_api_key: str,
98
+ vectara_customer_id: str = str(os.environ.get("VECTARA_CUSTOMER_ID", "")),
99
+ vectara_corpus_id: str = str(os.environ.get("VECTARA_CORPUS_ID", "")),
100
+ vectara_api_key: str = str(os.environ.get("VECTARA_API_KEY", "")),
100
101
  ) -> None:
101
102
  """
102
103
  Initialize the VectaraToolFactory
@@ -154,6 +155,7 @@ class VectaraToolFactory:
154
155
  vectara_api_key=self.vectara_api_key,
155
156
  vectara_customer_id=self.vectara_customer_id,
156
157
  vectara_corpus_id=self.vectara_corpus_id,
158
+ x_source_str="vectara-agentic"
157
159
  )
158
160
 
159
161
  def _build_filter_string(kwargs):
@@ -233,17 +235,18 @@ class VectaraToolFactory:
233
235
  raw_output={'response': msg}
234
236
  )
235
237
 
236
-
237
238
  res = {
238
239
  "response": response.response,
239
240
  "references_metadata": citation_metadata,
240
241
  }
241
-
242
- tool_output = f"""
243
- Response: '''{res['response']}'''
244
- References:
245
- {res['references_metadata']}
246
- """
242
+ if len(citation_metadata) > 0:
243
+ tool_output = f"""
244
+ Response: '''{res['response']}'''
245
+ References:
246
+ {res['references_metadata']}
247
+ """
248
+ else:
249
+ tool_output = f"Response: '''{res['response']}'''"
247
250
  out = ToolOutput(
248
251
  tool_name=rag_function.__name__,
249
252
  content=tool_output,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vectara_agentic
3
- Version: 0.1.8
3
+ Version: 0.1.9
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
@@ -31,6 +31,7 @@ Requires-Dist: llama-index-tools-arxiv==0.2.0
31
31
  Requires-Dist: llama-index-tools-database==0.2.0
32
32
  Requires-Dist: llama-index-tools-google==0.2.0
33
33
  Requires-Dist: llama-index-tools-tavily_research==0.2.0
34
+ Requires-Dist: llama-index-callbacks-arize-phoenix==0.2.1
34
35
  Requires-Dist: pydantic==2.8.2
35
36
  Requires-Dist: retrying==1.3.4
36
37
  Requires-Dist: pymongo==4.6.1
@@ -63,7 +64,7 @@ Requires-Dist: tiktoken==0.7.0
63
64
  - [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)
64
65
  - A Vectara corpus with an [API key](https://docs.vectara.com/docs/api-keys)
65
66
  - [Python 3.10 or higher](https://www.python.org/downloads/)
66
- - OpenAI API key (or API keys for Anthropic, TOGETHER.AI, Fireworks AI, Cohere, or GROQ)
67
+ - OpenAI API key (or API keys for Anthropic, TOGETHER.AI, Fireworks AI, Cohere or GROQ)
67
68
 
68
69
  ## Installation
69
70
 
@@ -181,6 +182,25 @@ The `Agent` class defines a few helpful methods to help you understand the inter
181
182
  * The `report()` method prints out the agent object’s type, the tools, and the LLMs used for the main agent and tool calling.
182
183
  * The `token_counts()` method tells you how many tokens you have used in the current session for both the main agent and tool calling LLMs. This can be helpful if you want to track spend by token.
183
184
 
185
+ ## Observability
186
+
187
+ vectara-agentic supports observability via the existing integration of LlamaIndex and Arize Phoenix.
188
+ To enable tracing of your vectara-agentic assistant, follow these steps (adapted from [here](https://docs.llamaindex.ai/en/stable/module_guides/observability/)):
189
+ 1. Go to `https://llamatrace.com/login` an create an account, then create an API key and put it in the `PHOENIX_API_KEY` variable
190
+ 2. `os["VECTARA_AGENTIC_OBSERVER_TYPE"] = "ARIZE_PHOENIX"`: to enable Arize Phoenix observability
191
+ 3. `os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"api_key={PHOENIX_API_KEY}"`
192
+
193
+ Now when you run your agent, all metrics are sent to LlamaTrace and recorded. You can view them at `https://llamatrace.com`.
194
+ If you do not include the `OTEL_EXPORTER_OTLP_HEADERS` a local instance of Arize Phoenix will be setup instead and you can view it at `http://localhost:6006`
195
+
196
+ ## About Custom Instructions
197
+
198
+ The custom instructions you provide to the agent guide its behavior.
199
+ Here are some guidelines when creating your instructions:
200
+ - Write precise and clear instructions, without overcomplicating.
201
+ - Consider edge cases and unusual or atypical scenarios.
202
+ - Be cautious to not over-specify behavior based on your primary use-case, as it may limit the agent's ability to behave properly in others.
203
+
184
204
  ## Examples
185
205
 
186
206
  Check out our example AI assistants:
@@ -13,6 +13,7 @@ llama-index-tools-arxiv==0.2.0
13
13
  llama-index-tools-database==0.2.0
14
14
  llama-index-tools-google==0.2.0
15
15
  llama-index-tools-tavily_research==0.2.0
16
+ llama-index-callbacks-arize-phoenix==0.2.1
16
17
  pydantic==2.8.2
17
18
  retrying==1.3.4
18
19
  pymongo==4.6.1
File without changes