24 lines
843 B
Python
24 lines
843 B
Python
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.") |