UniversityAI / chatbot.py
Alsmwal's picture
Upload 28 files
18ad9a9 verified
raw
history blame
657 Bytes
from dotenv import load_dotenv
import os
load_dotenv()
QDRANT_URL = os.getenv("QDRANT_URL")
QDRANT_API_KEY = os.getenv("QDRANT_API_KEY")
from langchain_ollama import OllamaLLM
def rag_answer(question, context):
prompt = f"""
You are an AI assistant. Use ONLY the context below to answer the user's question.
Reply in English only.
Context:
{context}
Question:
{question}
Answer:
"""
llm = OllamaLLM(model="llama3:latest")
return llm.invoke(prompt)
if __name__ == "__main__":
user_q = input("Enter your question: ")
answer = rag_answer(user_q, "No context loaded here yet.")
print("\nAI:", answer)