Skip to content

feat: LLM chat backend with tool-use loop and AG-UI streaming#26

Draft
cdgaete wants to merge 1 commit into
PyPSA:mainfrom
open-energy-transition:dev-llm
Draft

feat: LLM chat backend with tool-use loop and AG-UI streaming#26
cdgaete wants to merge 1 commit into
PyPSA:mainfrom
open-energy-transition:dev-llm

Conversation

@cdgaete
Copy link
Copy Markdown

@cdgaete cdgaete commented May 15, 2026

Summary

Adds an LLM chat backend to pypsa-app with provider-agnostic configuration (OpenRouter, Ollama, or any OpenAI-compatible API).

What's included

  • llm/ package: LiteLLM client, chat service with multi-step tool-use loop, AG-UI SSE event streaming, system prompts
  • LLM tools: list_networks, get_network_detail, get_network_statistics
  • Chat API: POST /chat/stream (SSE), GET /chat/health
  • LLMSettings: provider-agnostic config via env vars (LLM_PROVIDER, LLM_API_KEY, LLM_API_BASE, LLM_MODEL)
  • Feature flag: CHAT_ENABLED wired through /version endpoint
  • Dependency: litellm>=1.83 added to pyproject.toml

Not included (future PRs)

  • Frontend chat UI
  • Conversation persistence
  • Stop/interrupt cleanup for partial messages

@cdgaete cdgaete force-pushed the dev-llm branch 2 times, most recently from 89b5f84 to 375f07e Compare May 15, 2026 18:13
Adds the AI integration backend on top of upstream PyPSA: feature-flagged
chat service using LiteLLM, AG-UI SSE streaming, tool-use loop with three
network analysis tools (list_networks, get_network_detail,
get_network_statistics), Network.is_solved/objective surfacing, and the
`pypsa_app.llm` package wiring.

This is a re-baselining of dev-llm onto upstream PyPSA/pypsa-app main.
The pre-reset history is preserved at tag archive/main-pre-reset-2026-05-22.
@cdgaete cdgaete force-pushed the dev-llm branch 2 times, most recently from fbf4748 to 35ae6a2 Compare May 22, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant