imdb_bot / app.py
Matt Carroll
IMDB chat bot works locally with 'chainlit run app.py'
fc67742
raw
history blame contribute delete
631 Bytes
import os
import chainlit as cl
import build_db as db
import chat_bot as bot
@cl.on_chat_start
async def onStart():
global embedding_model
(embedder, embedding_model) = db.create_embedder(openai_api_key)
global vector_store
vector_store = db.load_vector_store(embedder)
@cl.on_message
async def onMessage(message: cl.Message):
response = bot.query_movie_critic(message.content, vector_store, openai_api_key)
msg = cl.Message(content="")
async for chunk in response:
await msg.stream_token(f"{chunk}")
openai_api_key = os.getenv("openai_api_key")
embedding_model = None
vector_store = None