Pash1986 commited on
Commit
336bda4
·
verified ·
1 Parent(s): 02dae87

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import time
 
2
  import gradio as gr
3
  import os
4
  import asyncio
@@ -23,7 +24,7 @@ collection_name = 'embedded_movies'
23
  collection = client[db_name][collection_name]
24
 
25
  try:
26
- vector_store = MongoDBAtlasVectorSearch(embedding=OpenAIEmbeddings(), collection=collection, index_name='vector_index', text_key='plot', embedding_key='plot_embedding')
27
  llm = ChatOpenAI(temperature=0)
28
  prompt = ChatPromptTemplate.from_messages([
29
  ("system", "You are a movie recommendation engine which post a concise and short summary on relevant movies."),
@@ -35,6 +36,7 @@ except:
35
  #If open ai key is wrong
36
  print ('Open AI key is wrong')
37
  vector_store = None
 
38
 
39
  def get_movies(message, history):
40
 
@@ -51,7 +53,7 @@ def get_movies(message, history):
51
  yield "Found: " + "\n\n" + print_llm_text[: i+1]
52
  except Exception as e:
53
  error_message = traceback.format_exc()
54
- yield "An error occurred: \n" + error_message
55
  yield "Please clone the repo and add your open ai key as well as your MongoDB Atlas UR in the Secret Section of you Space\n OPENAI_API_KEY (your Open AI key) and MONGODB_ATLAS_CLUSTER_URI (0.0.0.0/0 whitelisted instance with Vector index created) \n\n For more information : https://mongodb.com/products/platform/atlas-vector-search"
56
 
57
 
 
1
  import time
2
+ import traceback
3
  import gradio as gr
4
  import os
5
  import asyncio
 
24
  collection = client[db_name][collection_name]
25
 
26
  try:
27
+ vector_store = MongoDBAtlasVectorSearch(embedding=OpenAIEmbeddings(disallowed_special=()), collection=collection, index_name='vector_index', text_key='plot', embedding_key='plot_embedding')
28
  llm = ChatOpenAI(temperature=0)
29
  prompt = ChatPromptTemplate.from_messages([
30
  ("system", "You are a movie recommendation engine which post a concise and short summary on relevant movies."),
 
36
  #If open ai key is wrong
37
  print ('Open AI key is wrong')
38
  vector_store = None
39
+ print("An error occurred: \n" + error_message)
40
 
41
  def get_movies(message, history):
42
 
 
53
  yield "Found: " + "\n\n" + print_llm_text[: i+1]
54
  except Exception as e:
55
  error_message = traceback.format_exc()
56
+ print("An error occurred: \n" + error_message)
57
  yield "Please clone the repo and add your open ai key as well as your MongoDB Atlas UR in the Secret Section of you Space\n OPENAI_API_KEY (your Open AI key) and MONGODB_ATLAS_CLUSTER_URI (0.0.0.0/0 whitelisted instance with Vector index created) \n\n For more information : https://mongodb.com/products/platform/atlas-vector-search"
58
 
59