openrouter-provider 1.0.5__py3-none-any.whl → 1.0.6__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 +35 -26
- {openrouter_provider-1.0.5.dist-info → openrouter_provider-1.0.6.dist-info}/METADATA +1 -1
- {openrouter_provider-1.0.5.dist-info → openrouter_provider-1.0.6.dist-info}/RECORD +5 -5
- {openrouter_provider-1.0.5.dist-info → openrouter_provider-1.0.6.dist-info}/WHEEL +0 -0
- {openrouter_provider-1.0.5.dist-info → openrouter_provider-1.0.6.dist-info}/top_level.txt +0 -0
openrouter/openrouter.py
CHANGED
|
@@ -82,45 +82,54 @@ class OpenRouterClient:
|
|
|
82
82
|
model: LLMModel,
|
|
83
83
|
query: Message,
|
|
84
84
|
tools: list[tool_model] = None,
|
|
85
|
+
max_tools_loop: int = 3,
|
|
85
86
|
provider: ProviderConfig = None,
|
|
86
87
|
temperature: float = 0.3
|
|
87
88
|
) -> Message:
|
|
88
89
|
tools = tools or []
|
|
89
90
|
self._memory.append(query)
|
|
90
91
|
client = OpenRouterProvider()
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
temperature=temperature,
|
|
94
|
-
system_prompt=self._system_prompt,
|
|
95
|
-
querys=self._memory,
|
|
96
|
-
tools=self.tools + tools,
|
|
97
|
-
provider=provider,
|
|
98
|
-
)
|
|
99
|
-
reply.answered_by = model
|
|
100
|
-
self._memory.append(reply)
|
|
101
|
-
|
|
102
|
-
if reply.tool_calls:
|
|
103
|
-
for requested_tool in reply.tool_calls:
|
|
104
|
-
args = requested_tool.arguments
|
|
105
|
-
if isinstance(args, str):
|
|
106
|
-
args = json.loads(args)
|
|
107
|
-
|
|
108
|
-
for tool in (self.tools + tools):
|
|
109
|
-
if tool.name == requested_tool.name:
|
|
110
|
-
result = tool(**args)
|
|
111
|
-
requested_tool.result = result
|
|
112
|
-
break
|
|
113
|
-
else:
|
|
114
|
-
return reply
|
|
115
|
-
|
|
92
|
+
|
|
93
|
+
for i in range(max_tools_loop):
|
|
116
94
|
reply = client.invoke(
|
|
117
95
|
model=model,
|
|
96
|
+
temperature=temperature,
|
|
118
97
|
system_prompt=self._system_prompt,
|
|
119
98
|
querys=self._memory,
|
|
120
99
|
tools=self.tools + tools,
|
|
121
|
-
provider=provider
|
|
100
|
+
provider=provider,
|
|
122
101
|
)
|
|
102
|
+
reply.answered_by = model
|
|
103
|
+
self._memory.append(reply)
|
|
104
|
+
|
|
105
|
+
# Execute tools
|
|
106
|
+
if reply.tool_calls:
|
|
107
|
+
for requested_tool in reply.tool_calls:
|
|
108
|
+
args = requested_tool.arguments
|
|
109
|
+
if isinstance(args, str):
|
|
110
|
+
args = json.loads(args)
|
|
111
|
+
|
|
112
|
+
for tool in (self.tools + tools):
|
|
113
|
+
if tool.name == requested_tool.name:
|
|
114
|
+
result = tool(**args)
|
|
115
|
+
requested_tool.result = result
|
|
116
|
+
break
|
|
117
|
+
else:
|
|
118
|
+
return reply
|
|
123
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
|
+
)
|
|
124
133
|
reply.answered_by = model
|
|
125
134
|
self._memory.append(reply)
|
|
126
135
|
|
|
@@ -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=J74xqt3ycpD_RUhScEzX3vKc4zfwaJE6Wq3SLGDO6Kc,8368
|
|
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.6.dist-info/METADATA,sha256=92TvxKqv7j2j3s0kahWhQKe3pc6VUv5t6-h7gH4onrs,11503
|
|
8
|
+
openrouter_provider-1.0.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
+
openrouter_provider-1.0.6.dist-info/top_level.txt,sha256=0jnlCcRirGeYZLm5ZbWQRUonIp4tTPl_9mq-ds_1SEo,11
|
|
10
|
+
openrouter_provider-1.0.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|