0.34.1 - Openrouter reasoning model fixes (#241)

fix openrouter reasoning model issues
This commit is contained in:
veguAI
2025-12-19 23:44:52 +02:00
committed by GitHub
parent c179fcd3eb
commit 20af2a9f4b
7 changed files with 50 additions and 11 deletions

View File

@@ -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"}

View File

@@ -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

View File

@@ -1,3 +1,3 @@
__all__ = ["VERSION"]
VERSION = "0.34.0"
VERSION = "0.34.1"

View File

@@ -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",

View File

@@ -1,6 +1,6 @@
{
"name": "talemate_frontend",
"version": "0.34.0",
"version": "0.34.1",
"private": true,
"type": "module",
"scripts": {

View File

@@ -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",

2
uv.lock generated
View File

@@ -5227,7 +5227,7 @@ wheels = [
[[package]]
name = "talemate"
version = "0.34.0"
version = "0.34.1"
source = { editable = "." }
dependencies = [
{ name = "aiofiles" },