Cleaned and improved

This commit is contained in:
2025-11-28 22:09:26 +01:00
parent 4d2cfb5db1
commit c07527c6c9
21 changed files with 1431 additions and 365 deletions
+3 -9
View File
@@ -7,10 +7,9 @@ from typing import Any, Dict
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse, StreamingResponse
from agent.llm import DeepSeekClient
from agent.llm.deepseek import DeepSeekClient
from agent.memory import Memory
from agent.agent import Agent
from agent.commands import CommandRegistry
app = FastAPI(
title="LibreChat Agent Backend",
@@ -20,7 +19,6 @@ app = FastAPI(
llm = DeepSeekClient()
memory = Memory()
agent = Agent(llm=llm, memory=memory)
commands_registry = CommandRegistry(memory=memory)
def extract_last_user_content(messages: list[Dict[str, Any]]) -> str:
@@ -42,12 +40,8 @@ async def chat_completions(request: Request):
user_input = extract_last_user_content(messages)
print("Received chat completion request, stream =", stream, "input:", user_input)
# 🔹 1) Si c'est une commande, on ne fait PAS intervenir le LLM
if user_input.strip().startswith("/"):
answer = commands_registry.handle(user_input)
else:
# 🔹 2) Sinon, logique agent + LLM comme avant
answer = agent.step(user_input)
# Process user input through the agent
answer = agent.step(user_input)
# Ensuite = même logique de réponse (non-stream ou stream)
created_ts = int(time.time())