mirror of
https://github.com/vegu-ai/talemate.git
synced 2025-12-20 13:39:28 +01:00
0.34.1 - Openrouter reasoning model fixes (#241)
fix openrouter reasoning model issues
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "talemate"
|
||||
version = "0.34.0"
|
||||
version = "0.34.1"
|
||||
description = "AI-backed roleplay and narrative tools"
|
||||
authors = [{name = "VeguAITools"}]
|
||||
license = {text = "GNU Affero General Public License v3.0"}
|
||||
|
||||
@@ -256,6 +256,10 @@ class OpenRouterClient(ClientBase):
|
||||
def openrouter_api_key(self):
|
||||
return self.config.openrouter.api_key
|
||||
|
||||
@property
|
||||
def requires_reasoning_pattern(self) -> bool:
|
||||
return False
|
||||
|
||||
@property
|
||||
def supported_parameters(self):
|
||||
return [
|
||||
@@ -364,6 +368,9 @@ class OpenRouterClient(ClientBase):
|
||||
payload = {
|
||||
"model": self.model_name,
|
||||
"messages": messages,
|
||||
"reasoning": {
|
||||
"max_tokens": self.validated_reason_tokens,
|
||||
},
|
||||
"stream": True,
|
||||
**parameters,
|
||||
}
|
||||
@@ -376,6 +383,7 @@ class OpenRouterClient(ClientBase):
|
||||
)
|
||||
|
||||
response_text = ""
|
||||
reasoning_text = ""
|
||||
buffer = ""
|
||||
completion_tokens = 0
|
||||
prompt_tokens = 0
|
||||
@@ -410,14 +418,21 @@ class OpenRouterClient(ClientBase):
|
||||
|
||||
try:
|
||||
data_obj = json.loads(data)
|
||||
content = data_obj["choices"][0]["delta"].get(
|
||||
"content"
|
||||
)
|
||||
delta = data_obj["choices"][0]["delta"]
|
||||
content = delta.get("content")
|
||||
reasoning = delta.get("reasoning")
|
||||
usage = data_obj.get("usage", {})
|
||||
completion_tokens += usage.get(
|
||||
"completion_tokens", 0
|
||||
)
|
||||
prompt_tokens += usage.get("prompt_tokens", 0)
|
||||
|
||||
if reasoning:
|
||||
reasoning_text += reasoning
|
||||
self.update_request_tokens(
|
||||
self.count_tokens(reasoning)
|
||||
)
|
||||
|
||||
if content:
|
||||
response_text += content
|
||||
# Update tokens as content streams in
|
||||
@@ -432,6 +447,15 @@ class OpenRouterClient(ClientBase):
|
||||
response_content = response_text
|
||||
self._returned_prompt_tokens = prompt_tokens
|
||||
self._returned_response_tokens = completion_tokens
|
||||
self._reasoning_response = reasoning_text
|
||||
|
||||
self.log.debug(
|
||||
"generated response",
|
||||
response=response_content[:128] + " ..."
|
||||
if len(response_content) > 128
|
||||
else response_content,
|
||||
reasoning_length=len(reasoning_text),
|
||||
)
|
||||
|
||||
return response_content
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
__all__ = ["VERSION"]
|
||||
|
||||
VERSION = "0.34.0"
|
||||
VERSION = "0.34.1"
|
||||
|
||||
4
talemate_frontend/package-lock.json
generated
4
talemate_frontend/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "talemate_frontend",
|
||||
"version": "0.34.0",
|
||||
"version": "0.34.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "talemate_frontend",
|
||||
"version": "0.34.0",
|
||||
"version": "0.34.1",
|
||||
"dependencies": {
|
||||
"@codemirror/lang-json": "^6.0.1",
|
||||
"@codemirror/lang-markdown": "^6.2.5",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "talemate_frontend",
|
||||
"version": "0.34.0",
|
||||
"version": "0.34.1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -76,10 +76,25 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
expand: false,
|
||||
selected: "0.34.0",
|
||||
selected: "0.34.1",
|
||||
whatsNew: [
|
||||
{
|
||||
version: '0.34.0',
|
||||
version: '0.34.1',
|
||||
items: [
|
||||
{
|
||||
title: "OpenRouter Reasoning Model Fixes",
|
||||
description: "Fixed issues with OpenRouter reasoning models.",
|
||||
items: [
|
||||
"Fix empty responses from reasoning models",
|
||||
"Fix reasoning token not found errors",
|
||||
"Let OpenRouter handle reasoning token collection",
|
||||
"Configure reasoning effort correctly"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
version: '0.34.1',
|
||||
items: [
|
||||
{
|
||||
title: "Visual Agent Refactor",
|
||||
|
||||
Reference in New Issue
Block a user