Pash1986 commited on
Commit
2dbbcec
·
verified ·
1 Parent(s): ea009c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -38,19 +38,19 @@ except:
38
 
39
  def get_movies(message, history):
40
 
41
- try:
42
- movies = vector_store.similarity_search(message, 3)
43
- retrun_text = ''
44
- for movie in movies:
45
- retrun_text = retrun_text + 'Title : ' + movie.metadata['title'] + '\n------------\n' + 'Plot: ' + movie.page_content + '\n\n'
46
-
47
- print_llm_text = chain.invoke({"input": retrun_text})
48
- print(print_llm_text)
49
- for i in range(len(print_llm_text)):
50
- time.sleep(0.05)
51
- yield "Found: " + "\n\n" + print_llm_text[: i+1]
52
- except:
53
- 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"
54
 
55
 
56
  demo = gr.ChatInterface(get_movies, examples=["What movies are scary?", "Find me a comedy", "Movies for kids"], title="Movies Atlas Vector Search",description="This small chat uses a similarity search to find relevant movies, it uses an MongoDB Atlase Vector Search read more here: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-tutorial",submit_btn="Search").queue()
 
38
 
39
  def get_movies(message, history):
40
 
41
+ # try:
42
+ movies = vector_store.similarity_search(message, 3)
43
+ retrun_text = ''
44
+ for movie in movies:
45
+ retrun_text = retrun_text + 'Title : ' + movie.metadata['title'] + '\n------------\n' + 'Plot: ' + movie.page_content + '\n\n'
46
+
47
+ print_llm_text = chain.invoke({"input": retrun_text})
48
+ print(print_llm_text)
49
+ for i in range(len(print_llm_text)):
50
+ time.sleep(0.05)
51
+ yield "Found: " + "\n\n" + print_llm_text[: i+1]
52
+ # except:
53
+ # 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"
54
 
55
 
56
  demo = gr.ChatInterface(get_movies, examples=["What movies are scary?", "Find me a comedy", "Movies for kids"], title="Movies Atlas Vector Search",description="This small chat uses a similarity search to find relevant movies, it uses an MongoDB Atlase Vector Search read more here: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-tutorial",submit_btn="Search").queue()