Spaces:
Running
Running
Update custom_utils.py
Browse files- custom_utils.py +7 -3
custom_utils.py
CHANGED
@@ -26,7 +26,7 @@ def rag_ingestion(collection):
|
|
26 |
listings = process_records(dataset_df)
|
27 |
collection.delete_many({})
|
28 |
collection.insert_many(listings)
|
29 |
-
|
30 |
|
31 |
def rag_retrieval(openai_api_key, prompt, db, collection, stages=[], vector_index="vector_index"):
|
32 |
# Assuming vector_search returns a list of dictionaries with keys 'title' and 'plot'
|
@@ -45,6 +45,10 @@ def rag_retrieval(openai_api_key, prompt, db, collection, stages=[], vector_inde
|
|
45 |
# Convert search results into a DataFrame for better rendering in Jupyter
|
46 |
search_results_df = pd.DataFrame([item.dict() for item in search_results_models])
|
47 |
|
|
|
|
|
|
|
|
|
48 |
return search_results_df
|
49 |
|
50 |
def rag_inference(openai_api_key, prompt, search_results_df):
|
@@ -69,9 +73,9 @@ def rag_inference(openai_api_key, prompt, search_results_df):
|
|
69 |
result = completion.choices[0].message.content
|
70 |
|
71 |
print("###")
|
72 |
-
print(
|
73 |
print("###")
|
74 |
-
print(
|
75 |
print("###")
|
76 |
|
77 |
return result
|
|
|
26 |
listings = process_records(dataset_df)
|
27 |
collection.delete_many({})
|
28 |
collection.insert_many(listings)
|
29 |
+
return "Manually create a vector search index (in free tier, this feature is not available via SDK)"
|
30 |
|
31 |
def rag_retrieval(openai_api_key, prompt, db, collection, stages=[], vector_index="vector_index"):
|
32 |
# Assuming vector_search returns a list of dictionaries with keys 'title' and 'plot'
|
|
|
45 |
# Convert search results into a DataFrame for better rendering in Jupyter
|
46 |
search_results_df = pd.DataFrame([item.dict() for item in search_results_models])
|
47 |
|
48 |
+
print("###")
|
49 |
+
print(search_results_df)
|
50 |
+
print("###")
|
51 |
+
|
52 |
return search_results_df
|
53 |
|
54 |
def rag_inference(openai_api_key, prompt, search_results_df):
|
|
|
73 |
result = completion.choices[0].message.content
|
74 |
|
75 |
print("###")
|
76 |
+
print(content)
|
77 |
print("###")
|
78 |
+
print(result)
|
79 |
print("###")
|
80 |
|
81 |
return result
|