mirror of
https://github.com/vegu-ai/talemate.git
synced 2025-12-21 14:09:29 +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]
|
[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"}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
__all__ = ["VERSION"]
|
__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",
|
"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",
|
||||||
|
|||||||
@@ -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": {
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
Reference in New Issue
Block a user