This PySide6 desktop companion keeps a LangChain-driven duck named Pixel floating on your desktop. The translucent duck glides left and right with a looping GIF, and a click on the pet pops open the chat window where you can trade messages powered by LangChain. The codebase targets Python 3.14+ and leans on its modern typing + dataclass ergonomics.
-
Install dependencies
uv pip install -r <(uv pip compile pyproject.toml)or with regular pip:
pip install -e . -
Configure your Grok credentials
Create a
.envfile (or export env vars) with the deployment you want the agent to call:GROK_BASE_URL=https://example.com GROK_AUTH_TOKEN=sk-your-token
The PySide agent and the CLI tester both load these values automatically via
python-dotenv. -
Run the pet
python main.py
A frameless duck overlay will appear immediately. Click the duck any time you want to summon or re-focus the chat window.
Populate .env with your deployment details:
GROK_BASE_URL=https://example.com
GROK_AUTH_TOKEN=sk-your-tokenThen exercise the endpoint:
python scripts/test_grok_api.py "Tell me a cat fact" --model grok-betaAdd --raw to inspect the full JSON response, or adjust the --endpoint, --temperature, and timeout flags as needed.
d1.prompts.SYSTEM_PROMPTcentralizes the pet tone so both local and remote LLMs stay in sync.d1.models.ChatModelSettings+d1.models.create_chat_model()decide betweenlangchain-openaiand the offlineLocalPetChatModel.d1.agents.PetAgentis a dataclass that wires prompts, history, and the runnable chain.PetAgent.reset()now returnsSelffor fluent usage.d1.ui.DuckOverlayWindowrenders the animated desktop pet, whiled1.ui.DesktopPetWindowandd1.ui.AgentWorkerown the chat experience.d1.app.run_app()wires the overlay click signal to the chat window.
Feel free to remix the prompt, drop in another LangChain-compatible model, or customize the PySide widgets to make Pixel your own.