File size: 881 Bytes
9806574 b78b5e5 9806574 b78b5e5 7ffe358 a1d0ad2 7ffe358 9806574 a1d0ad2 b78b5e5 a1d0ad2 e742fa6 a1d0ad2 7ffe358 9806574 7ffe358 a1d0ad2 7ffe358 b78b5e5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
"""
Chatbot Nuevo Régimen Académico
"""
from chatbot.ui import ChatbotInterface
from chatbot.llm import GeminiAI
from chatbot.embeddings import init_embeddings
from chatbot.vectorstore import ChromaDB
from langchain.globals import set_verbose, set_debug
def format_docs(docs):
return "\n\n".join(doc.page_content for doc in docs)
def respond(message, history):
docs = retriever.invoke(message)
chain = llm.main_prompt | llm.llm
response = chain.invoke({"context": format_docs(docs), "message": message, "history": history})
return response.content
if __name__ == "__main__":
set_verbose(True)
set_debug(True)
embeddings = init_embeddings()
retriever = ChromaDB(embeddings).db.as_retriever(search_type="similarity", search_kwargs={"k": 3})
llm = GeminiAI("gemini-1.5-flash")
ui = ChatbotInterface(respond)
ui.app.launch()
|