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] [project]
name = "talemate" name = "talemate"
version = "0.34.0" version = "0.34.1"
description = "AI-backed roleplay and narrative tools" description = "AI-backed roleplay and narrative tools"
authors = [{name = "VeguAITools"}] authors = [{name = "VeguAITools"}]
license = {text = "GNU Affero General Public License v3.0"} license = {text = "GNU Affero General Public License v3.0"}

View File

@@ -256,6 +256,10 @@ class OpenRouterClient(ClientBase):
def openrouter_api_key(self): def openrouter_api_key(self):
return self.config.openrouter.api_key return self.config.openrouter.api_key
@property
def requires_reasoning_pattern(self) -> bool:
return False
@property @property
def supported_parameters(self): def supported_parameters(self):
return [ return [
@@ -364,6 +368,9 @@ class OpenRouterClient(ClientBase):
payload = { payload = {
"model": self.model_name, "model": self.model_name,
"messages": messages, "messages": messages,
"reasoning": {
"max_tokens": self.validated_reason_tokens,
},
"stream": True, "stream": True,
**parameters, **parameters,
} }
@@ -376,6 +383,7 @@ class OpenRouterClient(ClientBase):
) )
response_text = "" response_text = ""
reasoning_text = ""
buffer = "" buffer = ""
completion_tokens = 0 completion_tokens = 0
prompt_tokens = 0 prompt_tokens = 0
@@ -410,14 +418,21 @@ class OpenRouterClient(ClientBase):
try: try:
data_obj = json.loads(data) data_obj = json.loads(data)
content = data_obj["choices"][0]["delta"].get( delta = data_obj["choices"][0]["delta"]
"content" content = delta.get("content")
) reasoning = delta.get("reasoning")
usage = data_obj.get("usage", {}) usage = data_obj.get("usage", {})
completion_tokens += usage.get( completion_tokens += usage.get(
"completion_tokens", 0 "completion_tokens", 0
) )
prompt_tokens += usage.get("prompt_tokens", 0) prompt_tokens += usage.get("prompt_tokens", 0)
if reasoning:
reasoning_text += reasoning
self.update_request_tokens(
self.count_tokens(reasoning)
)
if content: if content:
response_text += content response_text += content
# Update tokens as content streams in # Update tokens as content streams in
@@ -432,6 +447,15 @@ class OpenRouterClient(ClientBase):
response_content = response_text response_content = response_text
self._returned_prompt_tokens = prompt_tokens self._returned_prompt_tokens = prompt_tokens
self._returned_response_tokens = completion_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 return response_content

View File

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

View File

@@ -1,12 +1,12 @@
{ {
"name": "talemate_frontend", "name": "talemate_frontend",
"version": "0.34.0", "version": "0.34.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "talemate_frontend", "name": "talemate_frontend",
"version": "0.34.0", "version": "0.34.1",
"dependencies": { "dependencies": {
"@codemirror/lang-json": "^6.0.1", "@codemirror/lang-json": "^6.0.1",
"@codemirror/lang-markdown": "^6.2.5", "@codemirror/lang-markdown": "^6.2.5",

View File

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

View File

@@ -76,10 +76,25 @@ export default {
data() { data() {
return { return {
expand: false, expand: false,
selected: "0.34.0", selected: "0.34.1",
whatsNew: [ 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: [ items: [
{ {
title: "Visual Agent Refactor", title: "Visual Agent Refactor",

2
uv.lock generated
View File

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