Files
socweb/backend/app/graph/nodes.py
T
gongzhiyongandClaude Opus 4.6 efb3c53623 feat: add backend service and Azure deployment workflow
- Add complete Python backend (Litestar + LangGraph) with chat, conversations, tickets APIs
- Add GitHub Actions workflow for auto-deploying backend to Azure Web App (soc-backend)
- Add gunicorn to requirements.txt for production serving
- Update CLAUDE.md and EXTERNAL_SERVICES.md with latest config
- Remove obsolete claudehd.md (merged into gpthd.md)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 13:31:00 +08:00

37 lines
1.1 KiB
Python

"""LangGraph node functions."""
from __future__ import annotations
from langchain_openai import AzureChatOpenAI
from app.config import settings
from app.graph.state import ChatState
# Model parameter presets
MODEL_PARAMS: dict[str, dict] = {
"flash": {"max_tokens": 500, "temperature": 0.2},
"pro": {"max_tokens": 4096, "temperature": 0.3},
}
def _get_llm(model: str) -> AzureChatOpenAI:
"""Create an AzureChatOpenAI instance with preset parameters."""
params = MODEL_PARAMS.get(model, MODEL_PARAMS["flash"])
return AzureChatOpenAI(
azure_endpoint=settings.azure_openai_endpoint,
api_key=settings.azure_openai_api_key,
api_version=settings.azure_openai_api_version,
azure_deployment=settings.azure_openai_deployment,
max_tokens=params["max_tokens"],
temperature=params["temperature"],
streaming=True,
)
async def call_model(state: ChatState) -> dict:
"""Invoke the LLM with the current message history."""
model = state.get("model", "flash")
llm = _get_llm(model)
response = await llm.ainvoke(state["messages"])
return {"messages": [response]}