File size: 778 Bytes
a81b6c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2aa218b
a81b6c4
 
 
 
 
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
import gradio as gr
from utils.env import load_env
from utils.database import initialize_database
from utils.chatbot import create_conversation_chain

MODEL = "gpt-4o-mini"
db_name = "vector_db"

# Load secrets
load_env()

# Initialze DB for RAG
vector_store = initialize_database(db_name)

# Create LangChain conversation chain
conversation_chain = create_conversation_chain(MODEL, vector_store)

# Chat function for UI to invoke the conversation chain
def chat(message, history):
    result = conversation_chain.invoke({"question": message})
    return result["answer"]

# Simple chat UI
demo = gr.ChatInterface(
    chat,
    title="Eric Dodson Resume Chat Assistant",
    textbox=gr.Textbox(placeholder="Ask me anything..."),
)

if __name__ == "__main__":
    demo.launch()