vectara-agentic 0.2.14__tar.gz → 0.2.16__tar.gz

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

Potentially problematic release.


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

Files changed (41) hide show
  1. {vectara_agentic-0.2.14/vectara_agentic.egg-info → vectara_agentic-0.2.16}/PKG-INFO +5 -5
  2. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/requirements.txt +4 -4
  3. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/tests/test_agent.py +2 -2
  4. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/tests/test_agent_planning.py +1 -1
  5. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/tests/test_groq.py +3 -1
  6. vectara_agentic-0.2.16/tests/test_return_direct.py +49 -0
  7. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/tests/test_tools.py +120 -18
  8. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/tests/test_vectara_llms.py +4 -1
  9. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/vectara_agentic/_observability.py +43 -21
  10. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/vectara_agentic/_prompts.py +5 -3
  11. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/vectara_agentic/_version.py +1 -1
  12. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/vectara_agentic/agent.py +114 -49
  13. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/vectara_agentic/db_tools.py +2 -2
  14. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/vectara_agentic/llm_utils.py +10 -6
  15. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/vectara_agentic/tool_utils.py +182 -133
  16. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/vectara_agentic/tools.py +19 -9
  17. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/vectara_agentic/tools_catalog.py +2 -1
  18. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16/vectara_agentic.egg-info}/PKG-INFO +5 -5
  19. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/vectara_agentic.egg-info/SOURCES.txt +1 -0
  20. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/vectara_agentic.egg-info/requires.txt +4 -4
  21. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/LICENSE +0 -0
  22. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/MANIFEST.in +0 -0
  23. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/README.md +0 -0
  24. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/setup.cfg +0 -0
  25. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/setup.py +0 -0
  26. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/tests/__init__.py +0 -0
  27. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/tests/endpoint.py +0 -0
  28. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/tests/test_agent_type.py +0 -0
  29. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/tests/test_fallback.py +0 -0
  30. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/tests/test_private_llm.py +0 -0
  31. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/tests/test_serialization.py +0 -0
  32. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/tests/test_workflow.py +0 -0
  33. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/vectara_agentic/__init__.py +0 -0
  34. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/vectara_agentic/_callback.py +0 -0
  35. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/vectara_agentic/agent_config.py +0 -0
  36. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/vectara_agentic/agent_endpoint.py +0 -0
  37. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/vectara_agentic/sub_query_workflow.py +0 -0
  38. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/vectara_agentic/types.py +0 -0
  39. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/vectara_agentic/utils.py +0 -0
  40. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/vectara_agentic.egg-info/dependency_links.txt +0 -0
  41. {vectara_agentic-0.2.14 → vectara_agentic-0.2.16}/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.2.14
3
+ Version: 0.2.16
4
4
  Summary: A Python package for creating AI Assistants and AI Agents with Vectara
5
5
  Home-page: https://github.com/vectara/py-vectara-agentic
6
6
  Author: Ofer Mendelevitch
@@ -16,18 +16,18 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
16
  Requires-Python: >=3.10
17
17
  Description-Content-Type: text/markdown
18
18
  License-File: LICENSE
19
- Requires-Dist: llama-index==0.12.33
20
- Requires-Dist: llama-index-indices-managed-vectara==0.4.4
19
+ Requires-Dist: llama-index==0.12.34
20
+ Requires-Dist: llama-index-indices-managed-vectara==0.4.5
21
21
  Requires-Dist: llama-index-agent-llm-compiler==0.3.0
22
22
  Requires-Dist: llama-index-agent-lats==0.3.0
23
- Requires-Dist: llama-index-agent-openai==0.4.6
23
+ Requires-Dist: llama-index-agent-openai==0.4.7
24
24
  Requires-Dist: llama-index-llms-openai==0.3.38
25
25
  Requires-Dist: llama-index-llms-anthropic==0.6.10
26
26
  Requires-Dist: llama-index-llms-together==0.3.1
27
27
  Requires-Dist: llama-index-llms-groq==0.3.1
28
28
  Requires-Dist: llama-index-llms-fireworks==0.3.2
29
29
  Requires-Dist: llama-index-llms-cohere==0.4.1
30
- Requires-Dist: llama-index-llms-google-genai==0.1.8
30
+ Requires-Dist: llama-index-llms-google-genai==0.1.12
31
31
  Requires-Dist: llama-index-llms-bedrock==0.3.8
32
32
  Requires-Dist: llama-index-tools-yahoo-finance==0.3.0
33
33
  Requires-Dist: llama-index-tools-arxiv==0.3.0
@@ -1,15 +1,15 @@
1
- llama-index==0.12.33
2
- llama-index-indices-managed-vectara==0.4.4
1
+ llama-index==0.12.34
2
+ llama-index-indices-managed-vectara==0.4.5
3
3
  llama-index-agent-llm-compiler==0.3.0
4
4
  llama-index-agent-lats==0.3.0
5
- llama-index-agent-openai==0.4.6
5
+ llama-index-agent-openai==0.4.7
6
6
  llama-index-llms-openai==0.3.38
7
7
  llama-index-llms-anthropic==0.6.10
8
8
  llama-index-llms-together==0.3.1
9
9
  llama-index-llms-groq==0.3.1
10
10
  llama-index-llms-fireworks==0.3.2
11
11
  llama-index-llms-cohere==0.4.1
12
- llama-index-llms-google-genai ==0.1.8
12
+ llama-index-llms-google-genai ==0.1.12
13
13
  llama-index-llms-bedrock==0.3.8
14
14
  llama-index-tools-yahoo-finance==0.3.0
15
15
  llama-index-tools-arxiv==0.3.0
@@ -124,7 +124,7 @@ class TestAgentPackage(unittest.TestCase):
124
124
  self.assertEqual(res.response, "1050")
125
125
 
126
126
  def test_custom_general_instruction(self):
127
- general_instructions = "Always respond with 'I DIDNT DO IT'"
127
+ general_instructions = "Always respond with: I DIDN'T DO IT"
128
128
  agent = Agent.from_corpus(
129
129
  tool_name="RAG Tool",
130
130
  vectara_corpus_key="corpus_key",
@@ -135,7 +135,7 @@ class TestAgentPackage(unittest.TestCase):
135
135
  )
136
136
 
137
137
  res = agent.chat("What is the meaning of the universe?")
138
- self.assertEqual(res.response, "I DIDNT DO IT")
138
+ self.assertEqual(res.response, "I DIDN'T DO IT")
139
139
 
140
140
 
141
141
  if __name__ == "__main__":
@@ -4,7 +4,7 @@ from vectara_agentic.agent_config import AgentConfig
4
4
  from vectara_agentic.agent import Agent
5
5
  from vectara_agentic.tools import VectaraToolFactory
6
6
 
7
- # SETUP speical test account credentials for vectara
7
+ # SETUP special test account credentials for vectara
8
8
  # It's okay to expose these credentials in the test code
9
9
  vectara_corpus_key = "vectara-docs_1"
10
10
  vectara_api_key = 'zqt_UXrBcnI2UXINZkrv4g1tQPhzj02vfdtqYJIDiA'
@@ -113,7 +113,9 @@ class TestGROQ(unittest.TestCase):
113
113
  agent_config=fc_config_groq,
114
114
  )
115
115
  res = agent.chat("What is the stock price?")
116
- self.assertIn("I don't know", str(res))
116
+ self.assertTrue(
117
+ any(sub in str(res) for sub in ["I don't know", "I do not have"])
118
+ )
117
119
 
118
120
 
119
121
  if __name__ == "__main__":
@@ -0,0 +1,49 @@
1
+ import unittest
2
+
3
+ from vectara_agentic.agent import Agent
4
+ from vectara_agentic.tools import VectaraToolFactory
5
+
6
+ vectara_corpus_key = "vectara-docs_1"
7
+ vectara_api_key = "zqt_UXrBcnI2UXINZkrv4g1tQPhzj02vfdtqYJIDiA"
8
+
9
+
10
+ class TestAgentPackage(unittest.TestCase):
11
+
12
+ def test_return_direct1(self):
13
+ vec_factory = VectaraToolFactory(vectara_corpus_key, vectara_api_key)
14
+
15
+ query_tool = vec_factory.create_rag_tool(
16
+ tool_name="rag_tool",
17
+ tool_description="""
18
+ A dummy tool for testing return_direct.
19
+ """,
20
+ return_direct=True,
21
+ )
22
+
23
+ agent = Agent(
24
+ tools=[query_tool],
25
+ topic="Sample topic",
26
+ custom_instructions="You are a helpful assistant.",
27
+ )
28
+ res = agent.chat("What is Vectara?")
29
+ self.assertIn("Response:", str(res))
30
+ self.assertIn("fcs_score", str(res))
31
+ self.assertIn("References:", str(res))
32
+
33
+ def test_from_corpus(self):
34
+ agent = Agent.from_corpus(
35
+ tool_name="rag_tool",
36
+ vectara_corpus_key=vectara_corpus_key,
37
+ vectara_api_key=vectara_api_key,
38
+ data_description="stuff about Vectara",
39
+ assistant_specialty="question answering",
40
+ return_direct=True,
41
+ )
42
+ res = agent.chat("What is Vectara?")
43
+ self.assertIn("Response:", str(res))
44
+ self.assertIn("fcs_score", str(res))
45
+ self.assertIn("References:", str(res))
46
+
47
+
48
+ if __name__ == "__main__":
49
+ unittest.main()
@@ -1,6 +1,7 @@
1
1
  import unittest
2
2
  from pydantic import Field, BaseModel
3
-
3
+ from unittest.mock import patch, MagicMock
4
+ import requests
4
5
  from vectara_agentic.tools import (
5
6
  VectaraTool,
6
7
  VectaraToolFactory,
@@ -17,6 +18,7 @@ from llama_index.core.tools import FunctionTool
17
18
  vectara_corpus_key = "vectara-docs_1"
18
19
  vectara_api_key = "zqt_UXrBcnI2UXINZkrv4g1tQPhzj02vfdtqYJIDiA"
19
20
 
21
+ from typing import Optional
20
22
 
21
23
  class TestToolsPackage(unittest.TestCase):
22
24
 
@@ -89,7 +91,7 @@ class TestToolsPackage(unittest.TestCase):
89
91
  description="The ticker symbol for the company",
90
92
  examples=["AAPL", "GOOG"],
91
93
  )
92
- year: int | str = Field(
94
+ year: Optional[int | str] = Field(
93
95
  default=None,
94
96
  description="The year this query relates to. An integer between 2015 and 2024 or a string specifying a condition on the year",
95
97
  examples=[
@@ -109,6 +111,7 @@ class TestToolsPackage(unittest.TestCase):
109
111
  tool_args_schema=QueryToolArgs,
110
112
  )
111
113
 
114
+ # test an invalid argument name
112
115
  res = query_tool(
113
116
  query="What is the stock price?",
114
117
  the_year=2023,
@@ -126,6 +129,86 @@ class TestToolsPackage(unittest.TestCase):
126
129
  )
127
130
  self.assertIn("got an unexpected keyword argument 'the_year'", str(res))
128
131
 
132
+ @patch.object(requests.Session, "post")
133
+ def test_vectara_tool_ranges(self, mock_post):
134
+ # Configure the mock to return a dummy response.
135
+ response_text = "ALL GOOD"
136
+ mock_response = MagicMock()
137
+ mock_response.status_code = 200
138
+ mock_response.json.return_value = {
139
+ 'summary': response_text,
140
+ 'search_results': [
141
+ {'text': 'ALL GOOD', 'document_id': '12345', 'score': 0.9},
142
+ ]
143
+ }
144
+ mock_post.return_value = mock_response
145
+
146
+ vec_factory = VectaraToolFactory(vectara_corpus_key, vectara_api_key)
147
+
148
+ class QueryToolArgs(BaseModel):
149
+ ticker: str = Field(
150
+ description="The ticker symbol for the company",
151
+ examples=["AAPL", "GOOG"],
152
+ )
153
+ year: int | str = Field(
154
+ default=None,
155
+ description="The year this query relates to. An integer between 2015 and 2024 or a string specifying a condition on the year",
156
+ examples=[
157
+ 2020,
158
+ ">2021",
159
+ "<2023",
160
+ ">=2021",
161
+ "<=2023",
162
+ "[2021, 2023]",
163
+ "[2021, 2023)",
164
+ ],
165
+ )
166
+
167
+ query_tool = vec_factory.create_rag_tool(
168
+ tool_name="rag_tool",
169
+ tool_description="Returns a response (str) to the user query based on the data in this corpus.",
170
+ tool_args_schema=QueryToolArgs,
171
+ )
172
+
173
+ # test an invalid argument name
174
+ res = query_tool(
175
+ query="What is the stock price?",
176
+ year=">2023"
177
+ )
178
+ self.assertIn(response_text, str(res))
179
+
180
+ # Test a valid range
181
+ res = query_tool(
182
+ query="What is the stock price?",
183
+ year="[2021, 2023]",
184
+ )
185
+ self.assertIn(response_text, str(res))
186
+
187
+ # Test a valid half closed range
188
+ res = query_tool(
189
+ query="What is the stock price?",
190
+ year="[2020, 2023)",
191
+ )
192
+ self.assertIn(response_text, str(res))
193
+
194
+ # Test an operator
195
+ res = query_tool(
196
+ query="What is the stock price?",
197
+ year=">2022",
198
+ )
199
+ self.assertIn(response_text, str(res))
200
+
201
+ search_tool = vec_factory.create_search_tool(
202
+ tool_name="search_tool",
203
+ tool_description="Returns a list of documents (str) that match the user query.",
204
+ tool_args_schema=QueryToolArgs,
205
+ )
206
+ res = search_tool(
207
+ query="What is the stock price?",
208
+ the_year=2023,
209
+ )
210
+ self.assertIn("got an unexpected keyword argument 'the_year'", str(res))
211
+
129
212
  def test_tool_factory(self):
130
213
  def mult(x: float, y: float) -> float:
131
214
  return x * y
@@ -152,8 +235,6 @@ class TestToolsPackage(unittest.TestCase):
152
235
  self.assertEqual(tool.metadata.tool_type, ToolType.QUERY)
153
236
 
154
237
  def test_tool_with_many_arguments(self):
155
- vectara_corpus_key = "corpus_key"
156
- vectara_api_key = "api_key"
157
238
  vec_factory = VectaraToolFactory(vectara_corpus_key, vectara_api_key)
158
239
 
159
240
  class QueryToolArgs(BaseModel):
@@ -169,24 +250,18 @@ class TestToolsPackage(unittest.TestCase):
169
250
  arg10: str = Field(description="the tenth argument", examples=["val10"])
170
251
  arg11: str = Field(description="the eleventh argument", examples=["val11"])
171
252
  arg12: str = Field(description="the twelfth argument", examples=["val12"])
172
- arg13: str = Field(
173
- description="the thirteenth argument", examples=["val13"]
174
- )
175
- arg14: str = Field(
176
- description="the fourteenth argument", examples=["val14"]
177
- )
178
- arg15: str = Field(description="the fifteenth argument", examples=["val15"])
253
+ arg13: str = Field(description="the thirteenth argument", examples=["val13"])
179
254
 
180
255
  query_tool_1 = vec_factory.create_rag_tool(
181
256
  tool_name="rag_tool",
182
257
  tool_description="""
183
- A dummy tool that takes 15 arguments and returns a response (str) to the user query based on the data in this corpus.
258
+ A dummy tool that takes 13 arguments and returns a response (str) to the user query based on the data in this corpus.
184
259
  We are using this tool to test the tool factory works and does not crash with OpenAI.
185
260
  """,
186
261
  tool_args_schema=QueryToolArgs,
187
262
  )
188
263
 
189
- # Test with 15 arguments which go over the 1024 limit.
264
+ # Test with 13 arguments which go over the 1024 limit.
190
265
  config = AgentConfig(
191
266
  agent_type=AgentType.OPENAI
192
267
  )
@@ -196,7 +271,7 @@ class TestToolsPackage(unittest.TestCase):
196
271
  custom_instructions="Call the tool with 15 arguments for OPENAI",
197
272
  agent_config=config,
198
273
  )
199
- res = agent.chat("What is the stock price?")
274
+ res = agent.chat("What is the stock price for Yahoo on 12/31/22?")
200
275
  self.assertIn("maximum length of 1024 characters", str(res))
201
276
 
202
277
  # Same test but with GROQ
@@ -208,7 +283,7 @@ class TestToolsPackage(unittest.TestCase):
208
283
  agent = Agent(
209
284
  tools=[query_tool_1],
210
285
  topic="Sample topic",
211
- custom_instructions="Call the tool with 15 arguments for GROQ",
286
+ custom_instructions="Call the tool with 13 arguments for GROQ",
212
287
  agent_config=config,
213
288
  )
214
289
  res = agent.chat("What is the stock price?")
@@ -223,14 +298,14 @@ class TestToolsPackage(unittest.TestCase):
223
298
  agent = Agent(
224
299
  tools=[query_tool_1],
225
300
  topic="Sample topic",
226
- custom_instructions="Call the tool with 15 arguments for ANTHROPIC",
301
+ custom_instructions="Call the tool with 13 arguments for ANTHROPIC",
227
302
  agent_config=config,
228
303
  )
229
304
  res = agent.chat("What is the stock price?")
230
305
  # ANTHROPIC does not have that 1024 limit
231
306
  self.assertIn("stock price", str(res))
232
307
 
233
- # But using Compact_docstring=True, we can pass 15 arguments successfully.
308
+ # But using Compact_docstring=True, we can pass 13 arguments successfully.
234
309
  vec_factory = VectaraToolFactory(
235
310
  vectara_corpus_key, vectara_api_key, compact_docstring=True
236
311
  )
@@ -251,7 +326,9 @@ class TestToolsPackage(unittest.TestCase):
251
326
  agent_config=config,
252
327
  )
253
328
  res = agent.chat("What is the stock price?")
254
- self.assertIn("stock price", str(res))
329
+ self.assertTrue(
330
+ any(sub in str(res) for sub in ["I don't know", "stock price"])
331
+ )
255
332
 
256
333
  def test_public_repo(self):
257
334
  vectara_corpus_key = "vectara-docs_1"
@@ -297,6 +374,31 @@ class TestToolsPackage(unittest.TestCase):
297
374
  "50",
298
375
  )
299
376
 
377
+ def test_vectara_tool_docstring(self):
378
+ class DummyArgs(BaseModel):
379
+ foo: int = Field(..., description="how many foos", examples=[1, 2, 3])
380
+ bar: str = Field(
381
+ "baz",
382
+ description="what bar to use",
383
+ examples=["x", "y"],
384
+ )
385
+
386
+ vec_factory = VectaraToolFactory(vectara_corpus_key, vectara_api_key)
387
+ dummy_tool = vec_factory.create_rag_tool(
388
+ tool_name="dummy_tool",
389
+ tool_description="A dummy tool.",
390
+ tool_args_schema=DummyArgs,
391
+ )
392
+
393
+ doc = dummy_tool.metadata.description
394
+ self.assertTrue(doc.startswith("dummy_tool(query: str, foo: int, bar: str) -> dict[str, Any]"))
395
+ self.assertIn("Args:", doc)
396
+ self.assertIn("query (str): The search query to perform, in the form of a question", doc)
397
+ self.assertIn("foo (int): how many foos (e.g., 1, 2, 3)", doc)
398
+ self.assertIn("bar (str, default='baz'): what bar to use (e.g., 'x', 'y')", doc)
399
+ self.assertIn("Returns:", doc)
400
+ self.assertIn("dict[str, Any]: A dictionary containing the result data.", doc)
401
+
300
402
 
301
403
  if __name__ == "__main__":
302
404
  unittest.main()
@@ -15,7 +15,10 @@ vectara_api_key = "zqt_UXrBcnI2UXINZkrv4g1tQPhzj02vfdtqYJIDiA"
15
15
  class TestLLMPackage(unittest.TestCase):
16
16
 
17
17
  def test_vectara_openai(self):
18
- vec_factory = VectaraToolFactory(vectara_corpus_key, vectara_api_key)
18
+ vec_factory = VectaraToolFactory(
19
+ vectara_corpus_key=vectara_corpus_key,
20
+ vectara_api_key=vectara_api_key
21
+ )
19
22
 
20
23
  self.assertEqual(vectara_corpus_key, vec_factory.vectara_corpus_key)
21
24
  self.assertEqual(vectara_api_key, vec_factory.vectara_api_key)
@@ -12,28 +12,50 @@ def setup_observer(config: AgentConfig, verbose: bool) -> bool:
12
12
  '''
13
13
  Setup the observer.
14
14
  '''
15
- import phoenix as px
16
- from openinference.instrumentation.llama_index import LlamaIndexInstrumentor
17
- from phoenix.otel import register
18
- if config.observer == ObserverType.ARIZE_PHOENIX:
19
- phoenix_endpoint = os.getenv("PHOENIX_ENDPOINT", None)
20
- if not phoenix_endpoint:
21
- px.launch_app()
22
- tracer_provider = register(endpoint='http://localhost:6006/v1/traces', project_name="vectara-agentic")
23
- elif 'app.phoenix.arize.com' in phoenix_endpoint: # hosted on Arize
24
- phoenix_api_key = os.getenv("PHOENIX_API_KEY", None)
25
- if not phoenix_api_key:
26
- raise ValueError("Arize Phoenix API key not set. Please set PHOENIX_API_KEY environment variable.")
27
- os.environ["PHOENIX_CLIENT_HEADERS"] = f"api_key={phoenix_api_key}"
28
- os.environ["PHOENIX_COLLECTOR_ENDPOINT"] = "https://app.phoenix.arize.com"
29
- tracer_provider = register(endpoint=phoenix_endpoint, project_name="vectara-agentic")
30
- else: # Self hosted Phoenix
31
- tracer_provider = register(endpoint=phoenix_endpoint, project_name="vectara-agentic")
32
- LlamaIndexInstrumentor().instrument(tracer_provider=tracer_provider)
33
- return True
15
+ if config.observer != ObserverType.ARIZE_PHOENIX:
16
+ if verbose:
17
+ print("No Phoenix observer set.")
18
+ return False
19
+
20
+ try:
21
+ import phoenix as px
22
+ from openinference.instrumentation.llama_index import LlamaIndexInstrumentor
23
+ from phoenix.otel import register
24
+ except ImportError:
25
+ print(
26
+ (
27
+ "Phoenix libraries not found. Please install with"
28
+ "'pip install arize-phoenix openinference-instrumentation-llama-index'"
29
+ )
30
+ )
31
+ return False
32
+
33
+ phoenix_endpoint = os.getenv("PHOENIX_ENDPOINT", None)
34
+ if not phoenix_endpoint:
35
+ print("Phoenix endpoint not set. Attempting to launch local Phoenix UI...")
36
+ px.launch_app()
37
+ print("Local Phoenix UI launched. You can view traces at the UI address (usually http://localhost:6006).")
38
+
39
+ if phoenix_endpoint and 'app.phoenix.arize.com' in phoenix_endpoint:
40
+ phoenix_api_key = os.getenv("PHOENIX_API_KEY")
41
+ if not phoenix_api_key:
42
+ raise ValueError(
43
+ "Arize Phoenix API key not set. Please set PHOENIX_API_KEY."
44
+ )
45
+ os.environ["PHOENIX_CLIENT_HEADERS"] = f"api_key={phoenix_api_key}"
46
+ os.environ["PHOENIX_COLLECTOR_ENDPOINT"] = "https://app.phoenix.arize.com"
47
+
48
+ reg_kwargs = {
49
+ "endpoint": phoenix_endpoint or 'http://localhost:6006/v1/traces',
50
+ "project_name": "vectara-agentic",
51
+ "batch": False,
52
+ "set_global_tracer_provider": False,
53
+ }
54
+ tracer_provider = register(**reg_kwargs)
55
+ LlamaIndexInstrumentor().instrument(tracer_provider=tracer_provider)
34
56
  if verbose:
35
- print("No observer set.")
36
- return False
57
+ print(f"Phoenix observer configured for project 'vectara-agentic' at endpoint: {reg_kwargs['endpoint']}")
58
+ return True
37
59
 
38
60
 
39
61
  def _extract_fcs_value(output: Union[str, dict]) -> Optional[float]:
@@ -4,11 +4,13 @@ This file contains the prompt templates for the different types of agents.
4
4
 
5
5
  # General (shared) instructions
6
6
  GENERAL_INSTRUCTIONS = """
7
- - Use tools as your main source of information, do not respond without using a tool. Do not respond based on pre-trained knowledge.
8
- - Use the 'get_bad_topics' tool to determine the topics you are not allowed to discuss or respond to.
7
+ - Use tools as your main source of information, do not respond without using a tool at least once.
8
+ - Do not respond based on pre-trained knowledge, unless repeated calls to the tools fail or do not provide the information needed.
9
+ - Use the 'get_bad_topics' (if it exists) tool to determine the topics you are not allowed to discuss or respond to.
9
10
  - Before responding to a user query that requires knowledge of the current date, call the 'get_current_date' tool to get the current date.
10
11
  Never rely on previous knowledge of the current date.
11
12
  Example queries that require the current date: "What is the revenue of Apple last october?" or "What was the stock price 5 days ago?".
13
+ Never call 'get_current_date' more than once for the same user query.
12
14
  - When using a tool with arguments, simplify the query as much as possible if you use the tool with arguments.
13
15
  For example, if the original query is "revenue for apple in 2021", you can use the tool with a query "revenue" with arguments year=2021 and company=apple.
14
16
  - If a tool responds with "I do not have enough information", try one or more of the following strategies:
@@ -24,7 +26,7 @@ GENERAL_INSTRUCTIONS = """
24
26
  - If a tool provides citations or references in markdown as part of its response, include the references in your response.
25
27
  - Ensure that every URL in your response includes descriptive anchor text that clearly explains what the user can expect from the linked content.
26
28
  Avoid using generic terms like “source” or “reference”, or the full URL, as the anchor text.
27
- - If a tool returns in the metadata a valid URL pointing to a PDF file, along with page number - then combine the URL and page number in the response.
29
+ - If a tool returns in the metadata a valid URL pointing to a PDF file, along with page number - then combine the URL and page number in your response.
28
30
  For example, if the URL returned from the tool is "https://example.com/doc.pdf" and "page=5", then the combined URL would be "https://example.com/doc.pdf#page=5".
29
31
  If a tool returns in the metadata invalid URLs or an URL empty (e.g. "[[1]()]"), ignore it and do not include that citation or reference in your response.
30
32
  - All URLs provided in your response must be obtained from tool output, and cannot be "https://example.com" or empty strings, and should open in a new tab.
@@ -1,4 +1,4 @@
1
1
  """
2
2
  Define the version of the package.
3
3
  """
4
- __version__ = "0.2.14"
4
+ __version__ = "0.2.16"