llm-dialog-manager 0.4.1__py3-none-any.whl → 0.4.2__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- llm_dialog_manager/__init__.py +1 -1
- llm_dialog_manager/agent.py +11 -6
- {llm_dialog_manager-0.4.1.dist-info → llm_dialog_manager-0.4.2.dist-info}/METADATA +1 -1
- llm_dialog_manager-0.4.2.dist-info/RECORD +9 -0
- llm_dialog_manager-0.4.1.dist-info/RECORD +0 -9
- {llm_dialog_manager-0.4.1.dist-info → llm_dialog_manager-0.4.2.dist-info}/LICENSE +0 -0
- {llm_dialog_manager-0.4.1.dist-info → llm_dialog_manager-0.4.2.dist-info}/WHEEL +0 -0
- {llm_dialog_manager-0.4.1.dist-info → llm_dialog_manager-0.4.2.dist-info}/top_level.txt +0 -0
llm_dialog_manager/__init__.py
CHANGED
llm_dialog_manager/agent.py
CHANGED
@@ -74,7 +74,10 @@ def completion(model: str, messages: List[Dict[str, Union[str, List[Union[str, I
|
|
74
74
|
"""
|
75
75
|
try:
|
76
76
|
service = ""
|
77
|
-
if "
|
77
|
+
if "openai" in model:
|
78
|
+
service = "openai"
|
79
|
+
model
|
80
|
+
elif "claude" in model:
|
78
81
|
service = "anthropic"
|
79
82
|
elif "gemini" in model:
|
80
83
|
service = "gemini"
|
@@ -92,7 +95,7 @@ def completion(model: str, messages: List[Dict[str, Union[str, List[Union[str, I
|
|
92
95
|
|
93
96
|
def format_messages_for_api(model, messages):
|
94
97
|
"""Convert ChatHistory messages to the format required by the specific API."""
|
95
|
-
if "claude" in model:
|
98
|
+
if "claude" in model and "openai" not in model:
|
96
99
|
formatted = []
|
97
100
|
system_msg = ""
|
98
101
|
if messages and messages[0]["role"] == "system":
|
@@ -141,7 +144,7 @@ def completion(model: str, messages: List[Dict[str, Union[str, List[Union[str, I
|
|
141
144
|
formatted.append({"role": msg["role"], "content": combined_content})
|
142
145
|
return system_msg, formatted
|
143
146
|
|
144
|
-
elif "gemini" in model or "gpt" in model or "grok" in model:
|
147
|
+
elif ("gemini" in model or "gpt" in model or "grok" in model) and "openai" not in model:
|
145
148
|
formatted = []
|
146
149
|
for msg in messages:
|
147
150
|
content = msg["content"]
|
@@ -191,7 +194,7 @@ def completion(model: str, messages: List[Dict[str, Union[str, List[Union[str, I
|
|
191
194
|
|
192
195
|
system_msg, formatted_messages = format_messages_for_api(model, messages.copy())
|
193
196
|
|
194
|
-
if "claude" in model:
|
197
|
+
if "claude" in model and "openai" not in model:
|
195
198
|
# Check for Vertex configuration
|
196
199
|
vertex_project_id = os.getenv('VERTEX_PROJECT_ID')
|
197
200
|
vertex_region = os.getenv('VERTEX_REGION')
|
@@ -232,7 +235,7 @@ def completion(model: str, messages: List[Dict[str, Union[str, List[Union[str, I
|
|
232
235
|
|
233
236
|
return response.completion
|
234
237
|
|
235
|
-
elif "gemini" in model:
|
238
|
+
elif "gemini" in model and "openai" not in model:
|
236
239
|
try:
|
237
240
|
# First try OpenAI-style API
|
238
241
|
client = openai.OpenAI(
|
@@ -284,7 +287,7 @@ def completion(model: str, messages: List[Dict[str, Union[str, List[Union[str, I
|
|
284
287
|
|
285
288
|
return response.text
|
286
289
|
|
287
|
-
elif "grok" in model:
|
290
|
+
elif "grok" in model and "openai" not in model:
|
288
291
|
# Randomly choose between OpenAI and Anthropic SDK
|
289
292
|
use_anthropic = random.choice([True, False])
|
290
293
|
|
@@ -326,6 +329,8 @@ def completion(model: str, messages: List[Dict[str, Union[str, List[Union[str, I
|
|
326
329
|
return response.choices[0].message.content
|
327
330
|
|
328
331
|
else: # OpenAI models
|
332
|
+
if model.endswith("-openai"):
|
333
|
+
model = model[:-7] # Remove last 7 characters ("-openai")
|
329
334
|
client = openai.OpenAI(api_key=api_key, base_url=base_url)
|
330
335
|
# Set response_format based on json_format
|
331
336
|
response_format = {"type": "json_object"} if json_format else {"type": "plain_text"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
llm_dialog_manager/__init__.py,sha256=JfEU5PUkn2YXXKa6yCMjGd6usEpf6Yp9r7FPwhaZzAs,86
|
2
|
+
llm_dialog_manager/agent.py,sha256=sV3RhZFlNCdTuOyCxJ3pRdUv5mwk4xFEfKs68LXAalg,24261
|
3
|
+
llm_dialog_manager/chat_history.py,sha256=DKKRnj_M6h-4JncnH6KekMTghX7vMgdN3J9uOwXKzMU,10347
|
4
|
+
llm_dialog_manager/key_manager.py,sha256=shvxmn4zUtQx_p-x1EFyOmnk-WlhigbpKtxTKve-zXk,4421
|
5
|
+
llm_dialog_manager-0.4.2.dist-info/LICENSE,sha256=vWGbYgGuWpWrXL8-xi6pNcX5UzD6pWoIAZmcetyfbus,1064
|
6
|
+
llm_dialog_manager-0.4.2.dist-info/METADATA,sha256=p40WrWZheemV-4rWErChIXZGFAcdx1bZHcw1DD3lF7o,4194
|
7
|
+
llm_dialog_manager-0.4.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
8
|
+
llm_dialog_manager-0.4.2.dist-info/top_level.txt,sha256=u2EQEXW0NGAt0AAHT7jx1odXZ4rZfjcgbmJhvKFuMkI,19
|
9
|
+
llm_dialog_manager-0.4.2.dist-info/RECORD,,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
llm_dialog_manager/__init__.py,sha256=hTHvsXzvD5geKgv2XERYcp2f-T3LoVVc3arXfPtNS1k,86
|
2
|
-
llm_dialog_manager/agent.py,sha256=ZKO3eKHTKcbmYpVRRIpzDy7Tlp_VgQ90ewr1758Ozgs,23931
|
3
|
-
llm_dialog_manager/chat_history.py,sha256=DKKRnj_M6h-4JncnH6KekMTghX7vMgdN3J9uOwXKzMU,10347
|
4
|
-
llm_dialog_manager/key_manager.py,sha256=shvxmn4zUtQx_p-x1EFyOmnk-WlhigbpKtxTKve-zXk,4421
|
5
|
-
llm_dialog_manager-0.4.1.dist-info/LICENSE,sha256=vWGbYgGuWpWrXL8-xi6pNcX5UzD6pWoIAZmcetyfbus,1064
|
6
|
-
llm_dialog_manager-0.4.1.dist-info/METADATA,sha256=LER5FN6lFQFPs_8A-fIM7VYmqN-fh0nCD6Dt8vslsiY,4194
|
7
|
-
llm_dialog_manager-0.4.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
8
|
-
llm_dialog_manager-0.4.1.dist-info/top_level.txt,sha256=u2EQEXW0NGAt0AAHT7jx1odXZ4rZfjcgbmJhvKFuMkI,19
|
9
|
-
llm_dialog_manager-0.4.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|