Add DeepSeek API adapter, UTF-8 encoding fixes, and session timeline#2
Add DeepSeek API adapter, UTF-8 encoding fixes, and session timeline#2owlmeng wants to merge 4 commits into
Conversation
Since my AI agent environment cannot use Ollama to proxy DeepSeek requests, I wrote a standalone adapter that connects to the official DeepSeek API directly using the OpenAI SDK — no proxy needed. - Add play_with_deepseek.py: DeepSeek API adapter. Default model: deepseek-v4-flash, supports --pro and --think. Uses extra_body for thinking mode, preserves reasoning_content. - Fix game_engine.py: add encoding='utf-8' to all open() calls, preventing UnicodeDecodeError on Chinese Windows (GBK default). - Fix game_engine.py: preserve thinking/reasoning_content in assistant messages, required by DeepSeek thinking mode.
- Add DeepSeek to prerequisites, backend table, and launch commands - DeepSeek API is OpenAI-compatible, no proxy required
On Chinese Windows, Python defaults to GBK encoding, causing UnicodeDecodeError when reading UTF-8 files (YAML configs, JSON player data, spell database, world .wwf files). Fix all open() calls in: - forge/config_loader.py (5 YAML reads) - forge/character_creator.py (spells.yml read) - forge/formatter.py (JSON/WWF writes) - dice_server.py (JSON/YAML reads) - game_engine.py (text reads + JSON write) Also add session timeline system to game_engine.py: - Timeline auto-loaded from .wwf basename + .timeline.md - Every 5 rounds, GM summarizes recent events into structured entries - Cache-friendly: new entries appended as separate system messages
- Add session timeline to feature list and output file list - Document .timeline.md auto-creation and cache-friendly injection - Add GBK/UTF-8 encoding note for Chinese Windows users
|
Thank you for your contribution to the project. The support for the UTF-8 encoding fix is a nice touch. I didn't have the time lately to look carefully on how the .timeline.md works, but I'm sure it works. It would be more precise in remembering the history of the game, than only the reputation system. |
Hey @electronistu — Project Infinity is amazing. The dice engine / AI DM separation is brilliant, and the campaign has been a blast.
Running on Chinese Windows, I added a few things:
play_with_deepseek.py — DeepSeek API adapter via OpenAI SDK, no proxy needed. Default deepseek-v4-flash.
UTF-8 encoding fix — Chinese Windows defaults to GBK, breaking YAML/JSON reads. Added encoding="utf-8" to all open() calls (12 places, 5 files).
Session timeline — Every 5 rounds, GM auto-summarizes into .timeline.md with same-name binding to .wwf. Persists across sessions, cache-friendly.
README — Updated with timeline + encoding note.
Tested: 15 rounds error-free, all tool calls (combat/healing/AoE), world forge, timeline checkpoints. Other backends untouched.
Happy to iterate!