openrouter-provider 1.0.6__py3-none-any.whl → 1.0.7__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 openrouter-provider might be problematic. Click here for more details.
- openrouter/openrouter.py +23 -41
- {openrouter_provider-1.0.6.dist-info → openrouter_provider-1.0.7.dist-info}/METADATA +1 -1
- {openrouter_provider-1.0.6.dist-info → openrouter_provider-1.0.7.dist-info}/RECORD +5 -5
- {openrouter_provider-1.0.6.dist-info → openrouter_provider-1.0.7.dist-info}/WHEEL +0 -0
- {openrouter_provider-1.0.6.dist-info → openrouter_provider-1.0.7.dist-info}/top_level.txt +0 -0
openrouter/openrouter.py
CHANGED
|
@@ -82,7 +82,6 @@ class OpenRouterClient:
|
|
|
82
82
|
model: LLMModel,
|
|
83
83
|
query: Message,
|
|
84
84
|
tools: list[tool_model] = None,
|
|
85
|
-
max_tools_loop: int = 3,
|
|
86
85
|
provider: ProviderConfig = None,
|
|
87
86
|
temperature: float = 0.3
|
|
88
87
|
) -> Message:
|
|
@@ -90,48 +89,31 @@ class OpenRouterClient:
|
|
|
90
89
|
self._memory.append(query)
|
|
91
90
|
client = OpenRouterProvider()
|
|
92
91
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
self._memory.append(reply)
|
|
92
|
+
reply = client.invoke(
|
|
93
|
+
model=model,
|
|
94
|
+
temperature=temperature,
|
|
95
|
+
system_prompt=self._system_prompt,
|
|
96
|
+
querys=self._memory,
|
|
97
|
+
tools=self.tools + tools,
|
|
98
|
+
provider=provider,
|
|
99
|
+
)
|
|
100
|
+
reply.answered_by = model
|
|
101
|
+
self._memory.append(reply)
|
|
104
102
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
103
|
+
# Execute tools
|
|
104
|
+
if reply.tool_calls:
|
|
105
|
+
for requested_tool in reply.tool_calls:
|
|
106
|
+
args = requested_tool.arguments
|
|
107
|
+
if isinstance(args, str):
|
|
108
|
+
args = json.loads(args)
|
|
111
109
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
# If normal reply, do nothing
|
|
121
|
-
else:
|
|
122
|
-
break
|
|
123
|
-
|
|
124
|
-
# If over max execution, send message without tools
|
|
125
|
-
else:
|
|
126
|
-
reply = client.invoke(
|
|
127
|
-
model=model,
|
|
128
|
-
temperature=temperature,
|
|
129
|
-
system_prompt=self._system_prompt,
|
|
130
|
-
querys=self._memory,
|
|
131
|
-
provider=provider,
|
|
132
|
-
)
|
|
133
|
-
reply.answered_by = model
|
|
134
|
-
self._memory.append(reply)
|
|
110
|
+
for tool in (self.tools + tools):
|
|
111
|
+
if tool.name == requested_tool.name:
|
|
112
|
+
result = tool(**args)
|
|
113
|
+
requested_tool.result = result
|
|
114
|
+
break
|
|
115
|
+
else:
|
|
116
|
+
return reply
|
|
135
117
|
|
|
136
118
|
return reply
|
|
137
119
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
openrouter/__init__.py,sha256=xuIzdm8-l3Tmc-zrNIXTicv05c9HCMxTS9xynKpWK-Q,123
|
|
2
2
|
openrouter/llms.py,sha256=zmujFW5BmQA0Fm6z8skuO3ipLpaUMy1VBZxYkPE9OcM,3391
|
|
3
3
|
openrouter/message.py,sha256=0q0OYdTl3f1TOx79TJRwPYyFuTxoYI9tSCpQN-N8G-A,2870
|
|
4
|
-
openrouter/openrouter.py,sha256=
|
|
4
|
+
openrouter/openrouter.py,sha256=jywShAm6oALzaNxrw5K6Jd7XizDpyEhVc_pJnJ0KIjI,7695
|
|
5
5
|
openrouter/openrouter_provider.py,sha256=w6isS1VX7iMf71zwQ5tMv7v5X0yeMbLF6vqimOrB724,8567
|
|
6
6
|
openrouter/tool.py,sha256=tUUNLosz1XhzPIwY1zHXWNM3ePs7hcVD1a_W5hWTCWk,1975
|
|
7
|
-
openrouter_provider-1.0.
|
|
8
|
-
openrouter_provider-1.0.
|
|
9
|
-
openrouter_provider-1.0.
|
|
10
|
-
openrouter_provider-1.0.
|
|
7
|
+
openrouter_provider-1.0.7.dist-info/METADATA,sha256=rwtcuUZFVUe7unjlVEfjIKZ4Mk1weMyT3GJiLATGg9w,11503
|
|
8
|
+
openrouter_provider-1.0.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
+
openrouter_provider-1.0.7.dist-info/top_level.txt,sha256=0jnlCcRirGeYZLm5ZbWQRUonIp4tTPl_9mq-ds_1SEo,11
|
|
10
|
+
openrouter_provider-1.0.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|