Refactor agent API structure and add core functionality with FastAPI integration

This commit is contained in:
2026-05-10 13:09:58 +02:00
parent 58250d22a3
commit 4c758f7733
10 changed files with 63 additions and 51 deletions
View File
View File
+7
View File
@@ -0,0 +1,7 @@
from dotenv import load_dotenv
from pathlib import Path
import os
load_dotenv(Path(__file__).resolve().parent.parent.parent / ".env")
DEEPSEEK_API_KEY = os.getenv("DEEPSEEK_API_KEY")
+7
View File
@@ -0,0 +1,7 @@
from openai import OpenAI
from .config import DEEPSEEK_API_KEY
client = OpenAI(
api_key=DEEPSEEK_API_KEY,
base_url="https://api.deepseek.com"
)
+32
View File
@@ -0,0 +1,32 @@
from fastapi import FastAPI
from pydantic import BaseModel
from .core.llm import client
app = FastAPI()
# ---- request model ----
class ChatRequest(BaseModel):
message: str
# ---- basic health check ----
@app.get("/")
def root():
return {"status": "ok"}
# ---- test LLM endpoint ----
@app.post("/chat")
def chat(req: ChatRequest):
response = client.chat.completions.create(
model="deepseek-chat",
messages=[
{"role": "user", "content": req.message}
]
)
return {
"response": response.choices[0].message.content
}