dm-aioaiagent 0.4.2__py3-none-any.whl → 0.4.5__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.
- dm_aioaiagent/ai_agent.py +16 -11
- dm_aioaiagent/async_ai_agent.py +3 -1
- {dm_aioaiagent-0.4.2.dist-info → dm_aioaiagent-0.4.5.dist-info}/METADATA +4 -4
- dm_aioaiagent-0.4.5.dist-info/RECORD +9 -0
- dm_aioaiagent-0.4.2.dist-info/RECORD +0 -9
- {dm_aioaiagent-0.4.2.dist-info → dm_aioaiagent-0.4.5.dist-info}/WHEEL +0 -0
- {dm_aioaiagent-0.4.2.dist-info → dm_aioaiagent-0.4.5.dist-info}/top_level.txt +0 -0
dm_aioaiagent/ai_agent.py
CHANGED
|
@@ -33,6 +33,7 @@ class DMAIAgent:
|
|
|
33
33
|
max_memory_messages: int = MAX_MEMORY_MESSAGES,
|
|
34
34
|
save_tools_responses_in_memory: bool = True,
|
|
35
35
|
llm_provider_api_key: str = "",
|
|
36
|
+
llm_provider_base_url: str = "",
|
|
36
37
|
response_if_request_fail: str = "I can't provide a response right now. Please try again later.",
|
|
37
38
|
response_if_invalid_image: str = "The image is unavailable or the link is incorrect."
|
|
38
39
|
):
|
|
@@ -46,6 +47,7 @@ class DMAIAgent:
|
|
|
46
47
|
self._temperature = int(temperature)
|
|
47
48
|
self._parallel_tool_calls = bool(parallel_tool_calls)
|
|
48
49
|
self._llm_provider_api_key = str(llm_provider_api_key)
|
|
50
|
+
self._llm_provider_base_url = str(llm_provider_base_url)
|
|
49
51
|
|
|
50
52
|
self._memory_messages = []
|
|
51
53
|
self._is_memory_enabled = bool(is_memory_enabled)
|
|
@@ -125,7 +127,9 @@ class DMAIAgent:
|
|
|
125
127
|
self._logger.error(e)
|
|
126
128
|
if second_attempt:
|
|
127
129
|
response = self._response_if_invalid_image if "invalid_image_url" in str(e) else self._response_if_request_fail
|
|
128
|
-
|
|
130
|
+
ai_response = AIMessage(content=response)
|
|
131
|
+
state["messages"].append(ai_response)
|
|
132
|
+
state["new_messages"].append(ai_response)
|
|
129
133
|
return state
|
|
130
134
|
return self._invoke_llm_node(state, second_attempt=True)
|
|
131
135
|
state["messages"].append(ai_response)
|
|
@@ -189,21 +193,22 @@ class DMAIAgent:
|
|
|
189
193
|
return route
|
|
190
194
|
|
|
191
195
|
def _init_agent(self) -> None:
|
|
196
|
+
base_kwargs = {
|
|
197
|
+
"model": self._model,
|
|
198
|
+
"temperature": self._temperature,
|
|
199
|
+
"base_url": self._llm_provider_base_url if self._llm_provider_base_url else None
|
|
200
|
+
}
|
|
192
201
|
if self._llm_provider_api_key:
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if self._model.startswith("gpt"):
|
|
196
|
-
from langchain_openai import ChatOpenAI
|
|
202
|
+
base_kwargs["api_key"] = SecretStr(self._llm_provider_api_key)
|
|
197
203
|
|
|
198
|
-
|
|
199
|
-
llm = ChatOpenAI(model_name=self._model, temperature=self._temperature, openai_api_key=api_key)
|
|
200
|
-
elif self._model.startswith("claude"):
|
|
204
|
+
if self._model.startswith("claude"):
|
|
201
205
|
from langchain_anthropic import ChatAnthropic
|
|
202
206
|
|
|
203
|
-
|
|
204
|
-
llm = ChatAnthropic(model=self._model, temperature=self._temperature, anthropic_api_key=api_key)
|
|
207
|
+
llm = ChatAnthropic(**base_kwargs)
|
|
205
208
|
else:
|
|
206
|
-
|
|
209
|
+
from langchain_openai import ChatOpenAI
|
|
210
|
+
|
|
211
|
+
llm = ChatOpenAI(**base_kwargs)
|
|
207
212
|
|
|
208
213
|
if self._is_tools_exists:
|
|
209
214
|
self._tool_map = {t.name: t for t in self._tools}
|
dm_aioaiagent/async_ai_agent.py
CHANGED
|
@@ -51,7 +51,9 @@ class DMAioAIAgent(DMAIAgent):
|
|
|
51
51
|
self._logger.error(e)
|
|
52
52
|
if second_attempt:
|
|
53
53
|
response = self._response_if_invalid_image if "invalid_image_url" in str(e) else self._response_if_request_fail
|
|
54
|
-
|
|
54
|
+
ai_response = AIMessage(content=response)
|
|
55
|
+
state["messages"].append(ai_response)
|
|
56
|
+
state["new_messages"].append(ai_response)
|
|
55
57
|
return state
|
|
56
58
|
return await self._invoke_llm_node(state, second_attempt=True)
|
|
57
59
|
state["messages"].append(ai_response)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: dm-aioaiagent
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.5
|
|
4
4
|
Summary: This is my custom aioaiagent client
|
|
5
5
|
Home-page: https://pypi.org/project/dm-aioaiagent
|
|
6
6
|
Author: dimka4621
|
|
@@ -17,12 +17,12 @@ Requires-Dist: python-dotenv>=1.0.0
|
|
|
17
17
|
Requires-Dist: pydantic<3.0.0,>=2.9.2
|
|
18
18
|
Requires-Dist: langchain~=0.3.0
|
|
19
19
|
Requires-Dist: langchain-core~=0.3.5
|
|
20
|
+
Requires-Dist: langchain-community~=0.3.0
|
|
21
|
+
Requires-Dist: langchain-openai~=0.3.0
|
|
22
|
+
Requires-Dist: langchain-anthropic~=0.3.0
|
|
20
23
|
Requires-Dist: langgraph~=0.2.23
|
|
21
24
|
Requires-Dist: langsmith~=0.1.144
|
|
22
25
|
Requires-Dist: grandalf>=0.8
|
|
23
|
-
Requires-Dist: langchain-community~=0.3.0
|
|
24
|
-
Requires-Dist: langchain-openai~=0.2.0
|
|
25
|
-
Requires-Dist: langchain-anthropic~=0.3.0
|
|
26
26
|
Dynamic: author
|
|
27
27
|
Dynamic: author-email
|
|
28
28
|
Dynamic: classifier
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
dm_aioaiagent/__init__.py,sha256=4Lkfntw5JnPyWvCppc-NbRznB2LRA2J-afJK8T4mGQs,186
|
|
2
|
+
dm_aioaiagent/ai_agent.py,sha256=o8GRFwYYEFJYBAyWAQkSZQT0Ou73TcrL-AKZlAQmuZE,11112
|
|
3
|
+
dm_aioaiagent/async_ai_agent.py,sha256=DArXNs2FEMHgZA7sURpnuPmujbsoDA1zSpPkKT0HQW4,3674
|
|
4
|
+
dm_aioaiagent/openai_image_message_content.py,sha256=EP_i0ERCz7c4KOM8UXp2-AI91ntGC7PGQBc5MMNspcs,434
|
|
5
|
+
dm_aioaiagent/types.py,sha256=ZUfC7eEh7iHSceFy1EscM7D4OohZ-QkdfOAgKP4EaJk,663
|
|
6
|
+
dm_aioaiagent-0.4.5.dist-info/METADATA,sha256=1ceoqrZwa5BdjLD2QMNNkc2akhjpFvt_hDXFhRcNymI,5141
|
|
7
|
+
dm_aioaiagent-0.4.5.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
8
|
+
dm_aioaiagent-0.4.5.dist-info/top_level.txt,sha256=CbasLH0KI7zA77XwT6JDCnmRascxKNGvUVV9MgYjHAU,14
|
|
9
|
+
dm_aioaiagent-0.4.5.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
dm_aioaiagent/__init__.py,sha256=4Lkfntw5JnPyWvCppc-NbRznB2LRA2J-afJK8T4mGQs,186
|
|
2
|
-
dm_aioaiagent/ai_agent.py,sha256=AbUx8VdznO5irFT3t0Fk1PenPqVIiJgKfZReTx9IS4Y,11157
|
|
3
|
-
dm_aioaiagent/async_ai_agent.py,sha256=egaK2CtHE66bxbPzounseDZgJYsfTg3DAPi1zcmc6RQ,3574
|
|
4
|
-
dm_aioaiagent/openai_image_message_content.py,sha256=EP_i0ERCz7c4KOM8UXp2-AI91ntGC7PGQBc5MMNspcs,434
|
|
5
|
-
dm_aioaiagent/types.py,sha256=ZUfC7eEh7iHSceFy1EscM7D4OohZ-QkdfOAgKP4EaJk,663
|
|
6
|
-
dm_aioaiagent-0.4.2.dist-info/METADATA,sha256=sExdT6znaLzX6AvSfNsc6So-Zn-XAOJJ9BdnH5ScahU,5141
|
|
7
|
-
dm_aioaiagent-0.4.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
8
|
-
dm_aioaiagent-0.4.2.dist-info/top_level.txt,sha256=CbasLH0KI7zA77XwT6JDCnmRascxKNGvUVV9MgYjHAU,14
|
|
9
|
-
dm_aioaiagent-0.4.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|