Files
task_6a02e23da6fe2e4ac16acf…/agent.py
T
2026-05-28 13:58:52 +00:00

24 lines
843 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from langchain import ChatPromptTemplate
from langchain.agents import create_agent
from langchain.tools import tool
from .tools import add_content, search_content
import os
# LLM configuration use Ollama via langchain-ollama
MODEL = os.getenv("OLLAMA_MODEL", "llama3.1")
BASE_URL = os.getenv("OLLAMA_BASE_URL", "http://localhost:11434/v1")
from langchain_ollama import ChatOllama
llm = ChatOllama(model=MODEL, base_url=BASE_URL)
# System prompt for the agent
SYSTEM_PROMPT = """You are an assistant that answers user queries using a knowledge base. Use the provided tools to search and add content."""
prompt = ChatPromptTemplate.from_messages([
("system", SYSTEM_PROMPT),
])
tools = [add_content, search_content]
agent = create_agent(llm=llm, prompt=prompt, tools=tools)
if __name__ == "__main__":
print("Agent initialized.")