Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,20 +21,20 @@ db_name = 'sample_mflix'
|
|
| 21 |
collection_name = 'embedded_movies'
|
| 22 |
collection = client[db_name][collection_name]
|
| 23 |
|
| 24 |
-
try:
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
|
| 33 |
|
| 34 |
-
except:
|
| 35 |
# If open ai key is wrong
|
| 36 |
-
|
| 37 |
-
|
| 38 |
|
| 39 |
def get_movies(message, history):
|
| 40 |
|
|
|
|
| 21 |
collection_name = 'embedded_movies'
|
| 22 |
collection = client[db_name][collection_name]
|
| 23 |
|
| 24 |
+
#try:
|
| 25 |
+
vector_store = MongoDBAtlasVectorSearch(embedding=OpenAIEmbeddings(), collection=collection, index_name='vector_index', text_key='plot', embedding_key='plot_embedding')
|
| 26 |
+
llm = ChatOpenAI()
|
| 27 |
+
prompt = ChatPromptTemplate.from_messages([
|
| 28 |
+
("system", "You are a movie recommendation engine please elaborate on movies."),
|
| 29 |
+
("user", "List of movies: {input}")
|
| 30 |
+
])
|
| 31 |
+
chain = prompt | llm
|
| 32 |
|
| 33 |
|
| 34 |
+
#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 |
|