vectara-agentic 0.1.1__tar.gz → 0.1.2__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.
- {vectara_agentic-0.1.1/vectara_agentic.egg-info → vectara_agentic-0.1.2}/PKG-INFO +4 -4
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/README.md +2 -3
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/requirements.txt +1 -0
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/setup.py +1 -1
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/vectara_agentic/_callback.py +4 -2
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/vectara_agentic/agent.py +25 -15
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/vectara_agentic/tools.py +9 -7
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/vectara_agentic/tools_catalog.py +41 -10
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2/vectara_agentic.egg-info}/PKG-INFO +4 -4
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/vectara_agentic.egg-info/requires.txt +1 -0
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/LICENSE +0 -0
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/MANIFEST.in +0 -0
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/setup.cfg +0 -0
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/tests/test_agent.py +0 -0
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/tests/test_tools.py +0 -0
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/vectara_agentic/__init__.py +0 -0
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/vectara_agentic/_prompts.py +0 -0
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/vectara_agentic/types.py +0 -0
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/vectara_agentic/utils.py +0 -0
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/vectara_agentic.egg-info/SOURCES.txt +0 -0
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/vectara_agentic.egg-info/dependency_links.txt +0 -0
- {vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/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.
|
|
3
|
+
Version: 0.1.2
|
|
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: mypy==1.11.0
|
|
|
31
31
|
Requires-Dist: pylint==3.2.6
|
|
32
32
|
Requires-Dist: flake8==7.1.0
|
|
33
33
|
Requires-Dist: pymongo==4.6.1
|
|
34
|
+
Requires-Dist: python-dotenv==1.0.1
|
|
34
35
|
|
|
35
36
|
# vectara-agentic
|
|
36
37
|
|
|
@@ -138,15 +139,12 @@ mult_tool = ToolsFactory().create_tool(mult_func)
|
|
|
138
139
|
|
|
139
140
|
```python
|
|
140
141
|
agent = Agent(
|
|
141
|
-
agent_type = agent_type,
|
|
142
142
|
tools = tools,
|
|
143
143
|
topic = topic_of_expertise
|
|
144
144
|
custom_instructions = financial_bot_instructions,
|
|
145
145
|
update_func = update_func
|
|
146
146
|
)
|
|
147
147
|
```
|
|
148
|
-
|
|
149
|
-
- `agent_type` is one of `AgentType.REACT` or `AgentTypeOpenAI`
|
|
150
148
|
- `tools` is the list of tools you want to provide to the agent
|
|
151
149
|
- `topic` is a string that defines the expertise you want the agent to specialize in.
|
|
152
150
|
- `custom_instructions` is an optional string that defines special instructions to the agent
|
|
@@ -154,6 +152,8 @@ agent = Agent(
|
|
|
154
152
|
The inputs to this function you provide are `status_type` of type AgentStatusType and
|
|
155
153
|
`msg` which is a string.
|
|
156
154
|
|
|
155
|
+
Note that the Agent type (`OPENAI` or `REACT`) is defined as an environment variables `VECTARA_AGENTIC_AGENT_TYPE`.
|
|
156
|
+
|
|
157
157
|
For example, for a financial agent we can use:
|
|
158
158
|
|
|
159
159
|
```python
|
|
@@ -104,15 +104,12 @@ mult_tool = ToolsFactory().create_tool(mult_func)
|
|
|
104
104
|
|
|
105
105
|
```python
|
|
106
106
|
agent = Agent(
|
|
107
|
-
agent_type = agent_type,
|
|
108
107
|
tools = tools,
|
|
109
108
|
topic = topic_of_expertise
|
|
110
109
|
custom_instructions = financial_bot_instructions,
|
|
111
110
|
update_func = update_func
|
|
112
111
|
)
|
|
113
112
|
```
|
|
114
|
-
|
|
115
|
-
- `agent_type` is one of `AgentType.REACT` or `AgentTypeOpenAI`
|
|
116
113
|
- `tools` is the list of tools you want to provide to the agent
|
|
117
114
|
- `topic` is a string that defines the expertise you want the agent to specialize in.
|
|
118
115
|
- `custom_instructions` is an optional string that defines special instructions to the agent
|
|
@@ -120,6 +117,8 @@ agent = Agent(
|
|
|
120
117
|
The inputs to this function you provide are `status_type` of type AgentStatusType and
|
|
121
118
|
`msg` which is a string.
|
|
122
119
|
|
|
120
|
+
Note that the Agent type (`OPENAI` or `REACT`) is defined as an environment variables `VECTARA_AGENTIC_AGENT_TYPE`.
|
|
121
|
+
|
|
123
122
|
For example, for a financial agent we can use:
|
|
124
123
|
|
|
125
124
|
```python
|
|
@@ -11,13 +11,15 @@ from .types import AgentStatusType
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class AgentCallbackHandler(BaseCallbackHandler):
|
|
14
|
-
"""
|
|
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
|
-
|
|
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:
|
|
@@ -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
|
-
"""
|
|
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
|
-
"""
|
|
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
|
-
"""
|
|
66
|
+
"""
|
|
67
|
+
Initialize the agent with the specified type, tools, topic, and system message.
|
|
63
68
|
|
|
64
69
|
Args:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
"""
|
|
119
|
+
"""
|
|
120
|
+
Create an agent from tools, agent type, and language model.
|
|
114
121
|
|
|
115
122
|
Args:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
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
|
-
"""
|
|
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
|
-
"""
|
|
156
|
+
"""
|
|
157
|
+
Interact with the agent using a chat prompt.
|
|
148
158
|
|
|
149
159
|
Args:
|
|
150
160
|
prompt (str): The chat prompt.
|
|
@@ -51,7 +51,7 @@ LI_packages = {
|
|
|
51
51
|
|
|
52
52
|
class VectaraTool:
|
|
53
53
|
"""
|
|
54
|
-
A wrapper of
|
|
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
|
-
"""
|
|
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
|
-
|
|
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]:
|
|
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
|
-
|
|
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.
|
|
34
|
-
Use this tool to summarize text
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: vectara_agentic
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
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: mypy==1.11.0
|
|
|
31
31
|
Requires-Dist: pylint==3.2.6
|
|
32
32
|
Requires-Dist: flake8==7.1.0
|
|
33
33
|
Requires-Dist: pymongo==4.6.1
|
|
34
|
+
Requires-Dist: python-dotenv==1.0.1
|
|
34
35
|
|
|
35
36
|
# vectara-agentic
|
|
36
37
|
|
|
@@ -138,15 +139,12 @@ mult_tool = ToolsFactory().create_tool(mult_func)
|
|
|
138
139
|
|
|
139
140
|
```python
|
|
140
141
|
agent = Agent(
|
|
141
|
-
agent_type = agent_type,
|
|
142
142
|
tools = tools,
|
|
143
143
|
topic = topic_of_expertise
|
|
144
144
|
custom_instructions = financial_bot_instructions,
|
|
145
145
|
update_func = update_func
|
|
146
146
|
)
|
|
147
147
|
```
|
|
148
|
-
|
|
149
|
-
- `agent_type` is one of `AgentType.REACT` or `AgentTypeOpenAI`
|
|
150
148
|
- `tools` is the list of tools you want to provide to the agent
|
|
151
149
|
- `topic` is a string that defines the expertise you want the agent to specialize in.
|
|
152
150
|
- `custom_instructions` is an optional string that defines special instructions to the agent
|
|
@@ -154,6 +152,8 @@ agent = Agent(
|
|
|
154
152
|
The inputs to this function you provide are `status_type` of type AgentStatusType and
|
|
155
153
|
`msg` which is a string.
|
|
156
154
|
|
|
155
|
+
Note that the Agent type (`OPENAI` or `REACT`) is defined as an environment variables `VECTARA_AGENTIC_AGENT_TYPE`.
|
|
156
|
+
|
|
157
157
|
For example, for a financial agent we can use:
|
|
158
158
|
|
|
159
159
|
```python
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{vectara_agentic-0.1.1 → vectara_agentic-0.1.2}/vectara_agentic.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|