vectara-agentic 0.1.1__py3-none-any.whl → 0.1.3__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.

@@ -11,13 +11,15 @@ from .types import AgentStatusType
11
11
 
12
12
 
13
13
  class AgentCallbackHandler(BaseCallbackHandler):
14
- """Callback handler to track agent status
14
+ """
15
+ Callback handler to track agent status
15
16
 
16
17
  This handler simply keeps track of event starts/ends, separated by event types.
17
18
  You can use this callback handler to keep track of agent progress.
18
19
 
19
20
  Args:
20
- - fn: callable function agent will call back to report on agent progress
21
+
22
+ fn: callable function agent will call back to report on agent progress
21
23
  """
22
24
 
23
25
  def __init__(self, fn: Callable = None) -> None:
vectara_agentic/agent.py CHANGED
@@ -26,9 +26,11 @@ load_dotenv(override=True)
26
26
 
27
27
 
28
28
  def get_prompt(prompt_template: str, topic: str, custom_instructions: str):
29
- """Generate a prompt by replacing placeholders with topic and date.
29
+ """
30
+ Generate a prompt by replacing placeholders with topic and date.
30
31
 
31
32
  Args:
33
+
32
34
  prompt_template (str): The template for the prompt.
33
35
  topic (str): The topic to be included in the prompt.
34
36
 
@@ -50,7 +52,9 @@ def retry_if_exception(exception):
50
52
 
51
53
 
52
54
  class Agent:
53
- """Agent class for handling different types of agents and their interactions."""
55
+ """
56
+ Agent class for handling different types of agents and their interactions.
57
+ """
54
58
 
55
59
  def __init__(
56
60
  self,
@@ -59,13 +63,15 @@ class Agent:
59
63
  custom_instructions: str = "",
60
64
  update_func: Optional[Callable[[AgentStatusType, str], None]] = None,
61
65
  ):
62
- """Initialize the agent with the specified type, tools, topic, and system message.
66
+ """
67
+ Initialize the agent with the specified type, tools, topic, and system message.
63
68
 
64
69
  Args:
65
- - tools (list[FunctionTool]): A list of tools to be used by the agent.
66
- - topic (str, optional): The topic for the agent. Defaults to 'general'.
67
- - custom_instructions (str, optional): custom instructions for the agent. Defaults to ''.
68
- - update_func (Callable): a callback function the code calls on any agent updates
70
+
71
+ tools (list[FunctionTool]): A list of tools to be used by the agent.
72
+ topic (str, optional): The topic for the agent. Defaults to 'general'.
73
+ custom_instructions (str, optional): custom instructions for the agent. Defaults to ''.
74
+ update_func (Callable): a callback function the code calls on any agent updates.
69
75
  """
70
76
  self.agent_type = AgentType(os.getenv("VECTARA_AGENTIC_AGENT_TYPE", "OPENAI"))
71
77
  self.tools = tools
@@ -110,21 +116,24 @@ class Agent:
110
116
  custom_instructions: str = "",
111
117
  update_func: Optional[Callable[[AgentStatusType, str], None]] = None,
112
118
  ) -> "Agent":
113
- """Create an agent from tools, agent type, and language model.
119
+ """
120
+ Create an agent from tools, agent type, and language model.
114
121
 
115
122
  Args:
116
- - tools (list[FunctionTool]): A list of tools to be used by the agent.
117
- - topic (str, optional): The topic for the agent. Defaults to 'general'.
118
- - custom_instructions (str, optional): custom instructions for the agent. Defaults to ''.
119
- - llm (LLM): The language model to be used by the agent.
123
+
124
+ tools (list[FunctionTool]): A list of tools to be used by the agent.
125
+ topic (str, optional): The topic for the agent. Defaults to 'general'.
126
+ custom_instructions (str, optional): custom instructions for the agent. Defaults to ''.
127
+ llm (LLM): The language model to be used by the agent.
120
128
 
121
129
  Returns:
122
- - Agent: An instance of the Agent class.
130
+ Agent: An instance of the Agent class.
123
131
  """
124
132
  return cls(tools, topic, custom_instructions, update_func)
125
133
 
126
134
  def report(self) -> str:
127
- """Get a report from the agent.
135
+ """
136
+ Get a report from the agent.
128
137
 
129
138
  Returns:
130
139
  str: The report from the agent.
@@ -144,7 +153,8 @@ class Agent:
144
153
  wait_fixed=2000,
145
154
  )
146
155
  def chat(self, prompt: str) -> str:
147
- """Interact with the agent using a chat prompt.
156
+ """
157
+ Interact with the agent using a chat prompt.
148
158
 
149
159
  Args:
150
160
  prompt (str): The chat prompt.
vectara_agentic/tools.py CHANGED
@@ -51,7 +51,7 @@ LI_packages = {
51
51
 
52
52
  class VectaraTool:
53
53
  """
54
- A wrapper of FunctionTOol class for Vectara tools, adding the tool_type attribute.
54
+ A wrapper of FunctionTool class for Vectara tools, adding the tool_type attribute.
55
55
  """
56
56
 
57
57
  def __init__(self, function_tool: FunctionTool, tool_type: ToolType) -> None:
@@ -137,7 +137,9 @@ class VectaraToolFactory:
137
137
 
138
138
  # Dynamically generate the RAG function
139
139
  def rag_function(*args, **kwargs) -> dict[str, Any]:
140
- """Dynamically generated function for RAG query with Vectara"""
140
+ """
141
+ Dynamically generated function for RAG query with Vectara.
142
+ """
141
143
  # Convert args to kwargs using the function signature
142
144
  sig = inspect.signature(rag_function)
143
145
  bound_args = sig.bind_partial(*args, **kwargs)
@@ -253,7 +255,7 @@ class VectaraToolFactory:
253
255
 
254
256
  class ToolsFactory:
255
257
  """
256
- A factory class for creating agent tools
258
+ A factory class for creating agent tools.
257
259
  """
258
260
 
259
261
  def create_tool(
@@ -267,7 +269,7 @@ class ToolsFactory:
267
269
  tool_type (ToolType): the type of tool.
268
270
 
269
271
  Returns:
270
- list[FunctionTool]: a list of FunctionTool objects.
272
+ List[FunctionTool]: A list of FunctionTool objects.
271
273
  """
272
274
  return VectaraTool(FunctionTool.from_defaults(function), tool_type)
273
275
 
@@ -288,7 +290,7 @@ class ToolsFactory:
288
290
  kwargs (dict): The keyword arguments to pass to the tool constructor (see Hub for tool specific details).
289
291
 
290
292
  Returns:
291
- list[FunctionTool]: a list of FunctionTool objects
293
+ list[FunctionTool]: A list of FunctionTool objects.
292
294
  """
293
295
  # Dynamically install and import the module
294
296
  if tool_package_name not in LI_packages.keys():
@@ -351,7 +353,7 @@ class ToolsFactory:
351
353
  text: str = Field(description="the original text."),
352
354
  ) -> str:
353
355
  """
354
- critique the legal document.
356
+ Critique the legal document.
355
357
  """
356
358
  return critique_text(
357
359
  text,
@@ -395,7 +397,7 @@ class ToolsFactory:
395
397
  You must specify either the sql_database object or the scheme, host, port, user, password, and dbname.
396
398
 
397
399
  Returns:
398
- List[FunctionTool]: A list of FunctionTool objects
400
+ List[FunctionTool]: A list of FunctionTool objects.
399
401
  """
400
402
  if sql_database:
401
403
  tools = self.get_llama_index_tools(
@@ -22,7 +22,6 @@ get_headers = {
22
22
  #
23
23
  # Standard Tools
24
24
  #
25
-
26
25
  def summarize_text(
27
26
  text: str = Field(description="the original text."),
28
27
  expertise: str = Field(
@@ -30,9 +29,16 @@ def summarize_text(
30
29
  ),
31
30
  ) -> str:
32
31
  """
33
- This is a helper tool. It does not provide new information.
34
- Use this tool to summarize text with no more than summary_max_length
35
- characters.
32
+ This is a helper tool.
33
+ Use this tool to summarize text using a given expertise
34
+ with no more than summary_max_length characters.
35
+
36
+ Args:
37
+ text (str): The original text.
38
+ expertise (str): The expertise to apply to the summarization.
39
+
40
+ Returns:
41
+ str: The summarized text.
36
42
  """
37
43
  expertise = "general" if len(expertise) < 3 else expertise.lower()
38
44
  prompt = f"As an expert in {expertise}, summarize the provided text"
@@ -50,9 +56,16 @@ def rephrase_text(
50
56
  ),
51
57
  ) -> str:
52
58
  """
53
- This is a helper tool. It does not provide new information.
59
+ This is a helper tool.
54
60
  Use this tool to rephrase the text according to the provided instructions.
55
61
  For example, instructions could be "as a 5 year old would say it."
62
+
63
+ Args:
64
+ text (str): The original text.
65
+ instructions (str): The specific instructions for how to rephrase the text.
66
+
67
+ Returns:
68
+ str: The rephrased text.
56
69
  """
57
70
  prompt = f"""
58
71
  Rephrase the provided text according to the following instructions: {instructions}.
@@ -75,8 +88,16 @@ def critique_text(
75
88
  ),
76
89
  ) -> str:
77
90
  """
78
- This is a helper tool. It does not provide new information.
91
+ This is a helper tool.
79
92
  Critique the text from the specified point of view.
93
+
94
+ Args:
95
+ text (str): The original text.
96
+ role (str): The role of the person providing critique.
97
+ point_of_view (str): The point of view with which to provide critique.
98
+
99
+ Returns:
100
+ str: The critique of the text.
80
101
  """
81
102
  if role:
82
103
  prompt = f"As a {role}, critique the provided text from the point of view of {point_of_view}."
@@ -94,12 +115,16 @@ def critique_text(
94
115
  #
95
116
  # Guardrails tools
96
117
  #
97
-
98
-
99
118
  def guardrails_no_politics(text: str = Field(description="the original text.")) -> str:
100
119
  """
101
120
  A guardrails tool.
102
- Can be used to rephrase text so that it does not have political content.
121
+ Given the input text, rephrases the text to ensure that the response avoids any specific political content.
122
+
123
+ Args:
124
+ text (str): The original text.
125
+
126
+ Returns:
127
+ str: The rephrased text.
103
128
  """
104
129
  return rephrase_text(text, "avoid any specific political content.")
105
130
 
@@ -107,6 +132,12 @@ def guardrails_no_politics(text: str = Field(description="the original text."))
107
132
  def guardrails_be_polite(text: str = Field(description="the original text.")) -> str:
108
133
  """
109
134
  A guardrails tool.
110
- Can be used to rephrase the text so that the response is in a polite tone.
135
+ Given the input text, rephrases the text to ensure that the response is polite.
136
+
137
+ Args:
138
+ text (str): The original text.
139
+
140
+ Returns:
141
+ str: The rephrased text.
111
142
  """
112
143
  return rephrase_text(text, "Ensure the response is super polite.")
@@ -1,13 +1,19 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vectara_agentic
3
- Version: 0.1.1
3
+ Version: 0.1.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
7
7
  Author-email: ofer@vectara.com
8
+ License: Apache-2.0
9
+ Project-URL: Documentation, https://vectara.github.io/vectara-agentic-docs/
10
+ Keywords: LLM,NLP,RAG,Agentic-RAG
8
11
  Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: License :: OSI Approved :: Apache Software License
10
13
  Classifier: Operating System :: OS Independent
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
11
17
  Requires-Python: >=3.10
12
18
  Description-Content-Type: text/markdown
13
19
  License-File: LICENSE
@@ -31,6 +37,7 @@ Requires-Dist: mypy ==1.11.0
31
37
  Requires-Dist: pylint ==3.2.6
32
38
  Requires-Dist: flake8 ==7.1.0
33
39
  Requires-Dist: pymongo ==4.6.1
40
+ Requires-Dist: python-dotenv ==1.0.1
34
41
 
35
42
  # vectara-agentic
36
43
 
@@ -138,15 +145,12 @@ mult_tool = ToolsFactory().create_tool(mult_func)
138
145
 
139
146
  ```python
140
147
  agent = Agent(
141
- agent_type = agent_type,
142
148
  tools = tools,
143
149
  topic = topic_of_expertise
144
150
  custom_instructions = financial_bot_instructions,
145
151
  update_func = update_func
146
152
  )
147
153
  ```
148
-
149
- - `agent_type` is one of `AgentType.REACT` or `AgentTypeOpenAI`
150
154
  - `tools` is the list of tools you want to provide to the agent
151
155
  - `topic` is a string that defines the expertise you want the agent to specialize in.
152
156
  - `custom_instructions` is an optional string that defines special instructions to the agent
@@ -154,6 +158,8 @@ agent = Agent(
154
158
  The inputs to this function you provide are `status_type` of type AgentStatusType and
155
159
  `msg` which is a string.
156
160
 
161
+ Note that the Agent type (`OPENAI` or `REACT`) is defined as an environment variables `VECTARA_AGENTIC_AGENT_TYPE`.
162
+
157
163
  For example, for a financial agent we can use:
158
164
 
159
165
  ```python
@@ -0,0 +1,13 @@
1
+ vectara_agentic/__init__.py,sha256=CRKtLZdGj_s9ynKBOVkT_Qqhm7WwxGpZGzyeHZG-1aI,432
2
+ vectara_agentic/_callback.py,sha256=3phD394HQICg5BWpMTE3a7DUUVl5NWVIkdgCDytS0gc,3564
3
+ vectara_agentic/_prompts.py,sha256=u8HqpfV42fdBUf3ZNjDm5kPJXNncLSTWU-4Js7-ipEA,4152
4
+ vectara_agentic/agent.py,sha256=PXKsFe3IKHkypkErzQZclxgRVI_d_kRwy1KsBTjIhKc,5846
5
+ vectara_agentic/tools.py,sha256=79dZX2BBJeML9KglFlXiGxzfyUaoyX63DLwuexAQ8NE,16250
6
+ vectara_agentic/tools_catalog.py,sha256=Wc-j7p6LG4420KmM8SUKFtgI2b1IwryXqbALGDEvmAI,4266
7
+ vectara_agentic/types.py,sha256=CFjjxaYhflsFDsE2ZNrZgWqman_r2HJQ-nOvuUiX3IY,804
8
+ vectara_agentic/utils.py,sha256=8YqxRqgm6qbjoH-LotpeHRjKWRejn9VJoqM5BbsD0NU,2408
9
+ vectara_agentic-0.1.3.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
10
+ vectara_agentic-0.1.3.dist-info/METADATA,sha256=jZ20-5zARCJKjGZjAacoT1huYgbx0hewsMzysObIa7w,10512
11
+ vectara_agentic-0.1.3.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
12
+ vectara_agentic-0.1.3.dist-info/top_level.txt,sha256=qT7JB9Xz7byehzlPd_rY4WWEAvPMhs63WMWgPsFthxU,16
13
+ vectara_agentic-0.1.3.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- vectara_agentic/__init__.py,sha256=CRKtLZdGj_s9ynKBOVkT_Qqhm7WwxGpZGzyeHZG-1aI,432
2
- vectara_agentic/_callback.py,sha256=JQbkAnbhLOreTNkWXXhqr6aery-HxjXhlYUy9EotIC8,3552
3
- vectara_agentic/_prompts.py,sha256=u8HqpfV42fdBUf3ZNjDm5kPJXNncLSTWU-4Js7-ipEA,4152
4
- vectara_agentic/agent.py,sha256=LOQS2e6-HbtLcazeVd1w-71p6PrkwLSdRBfFpSHJUcM,5773
5
- vectara_agentic/tools.py,sha256=WEgib78mBp00sPifqeGy-T22G6JbFDoLrPN9PqJFXOU,16220
6
- vectara_agentic/tools_catalog.py,sha256=b5EYKs65v9ykZAPiSDzY3o6t5FMyt088Li0_FSCdx0Y,3518
7
- vectara_agentic/types.py,sha256=CFjjxaYhflsFDsE2ZNrZgWqman_r2HJQ-nOvuUiX3IY,804
8
- vectara_agentic/utils.py,sha256=8YqxRqgm6qbjoH-LotpeHRjKWRejn9VJoqM5BbsD0NU,2408
9
- vectara_agentic-0.1.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
10
- vectara_agentic-0.1.1.dist-info/METADATA,sha256=4tvMtGfXCVSuwfg-YIYMnZhv4rfFvvsofbOQVBSXLwE,10123
11
- vectara_agentic-0.1.1.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
12
- vectara_agentic-0.1.1.dist-info/top_level.txt,sha256=qT7JB9Xz7byehzlPd_rY4WWEAvPMhs63WMWgPsFthxU,16
13
- vectara_agentic-0.1.1.dist-info/RECORD,,