Spaces:
Running
Running
Rename openai_embedding.py to openai_.py
Browse files
openai_embedding.py → openai_.py
RENAMED
@@ -21,9 +21,9 @@ def get_embedding(text):
|
|
21 |
print(f"Error in get_embedding: {e}")
|
22 |
return None
|
23 |
|
24 |
-
def
|
25 |
# Assuming vector_search returns a list of dictionaries with keys 'title' and 'plot'
|
26 |
-
get_knowledge = vector_search(
|
27 |
|
28 |
# Check if there are any results
|
29 |
if not get_knowledge:
|
@@ -47,7 +47,7 @@ def handle_user_query(query, db, collection):
|
|
47 |
"content": "You are a airbnb listing recommendation system."},
|
48 |
{
|
49 |
"role": "user",
|
50 |
-
"content": f"Answer this user
|
51 |
}
|
52 |
]
|
53 |
)
|
@@ -55,7 +55,7 @@ def handle_user_query(query, db, collection):
|
|
55 |
system_response = completion.choices[0].message.content
|
56 |
|
57 |
# Print User Question, System Response, and Source Information
|
58 |
-
print(f"- User Question:\n{
|
59 |
print(f"- System Response:\n{system_response}\n")
|
60 |
|
61 |
# Display the DataFrame as an HTML table
|
|
|
21 |
print(f"Error in get_embedding: {e}")
|
22 |
return None
|
23 |
|
24 |
+
def handle_user_prompt(prompt, db, collection):
|
25 |
# Assuming vector_search returns a list of dictionaries with keys 'title' and 'plot'
|
26 |
+
get_knowledge = vector_search(prompt, db, collection)
|
27 |
|
28 |
# Check if there are any results
|
29 |
if not get_knowledge:
|
|
|
47 |
"content": "You are a airbnb listing recommendation system."},
|
48 |
{
|
49 |
"role": "user",
|
50 |
+
"content": f"Answer this user prompt: {prompt} with the following context:\n{search_results_df}"
|
51 |
}
|
52 |
]
|
53 |
)
|
|
|
55 |
system_response = completion.choices[0].message.content
|
56 |
|
57 |
# Print User Question, System Response, and Source Information
|
58 |
+
print(f"- User Question:\n{prompt}\n")
|
59 |
print(f"- System Response:\n{system_response}\n")
|
60 |
|
61 |
# Display the DataFrame as an HTML table
|