Tweaks of gitignore, LLM block strip, config template

This commit is contained in:
Dejvino 2026-06-25 23:07:19 +02:00
parent 52f590d432
commit 18ae3be428
4 changed files with 17 additions and 9 deletions

2
.gitignore vendored
View File

@ -1,5 +1,7 @@
__pycache__/
*.pyc
*.swp
.env
session/audio/
llm.log
config.json

View File

@ -1,8 +0,0 @@
{
"llm": {
"model": "openai/deepseek-r1",
"api_key": null,
"api_base": "http://localhost:8080/v1",
"temperature": 0.7
}
}

View File

@ -0,0 +1,8 @@
{
"llm": {
"model": "openrouter/free",
"api_key": "YOUR_API_KEY",
"api_base": "https://openrouter.ai/api/v1",
"temperature": 0.8
}
}

View File

@ -1076,8 +1076,14 @@ class GameEngine:
if matches:
json_str = matches[-1].strip()
# Remove the JSON block from narrative
narrative = text[: text.rfind("```json")]
narrative = narrative.strip()
# Also strip any stray "book_log:" lines that may appear before the JSON block
narrative_lines = []
for line in narrative.splitlines():
if not line.lstrip().startswith('book_log:'):
narrative_lines.append(line)
narrative = "\n".join(narrative_lines).strip()
try:
data = json.loads(json_str)
except json.JSONDecodeError: