feat: agent files

This commit is contained in:
2026-03-19 21:40:26 -05:00
parent f35d28cca6
commit 10aa90bcc8
15 changed files with 2295 additions and 0 deletions

0
core/agent/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

32
core/agent/agent.py Normal file
View File

@@ -0,0 +1,32 @@
from langchain_core.messages import HumanMessage, AIMessage
from langgraph.graph import StateGraph, MessagesState, START, END
from ..backend import llm
def call_llama_server(state: MessagesState):
"""Call the local llama-server with the configured model using LangChain."""
# Get the last user message
messages = state["messages"]
if not messages:
return {"messages": [AIMessage(content="No message provided")]}
# Get the content of the last message
last_message = messages[-1]
user_content = last_message.content
# Invoke the LLM with the user message
response = llm.invoke(user_content)
return {"messages": [response]}
def create_agent_graph():
"""Create a simple agent graph that processes messages and calls the llama server."""
# Build the LangGraph workflow
graph = StateGraph(MessagesState)
graph.add_node(call_llama_server)
graph.add_edge(START, "call_llama_server")
graph.add_edge("call_llama_server", END)
graph = graph.compile()
return graph