Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -332,17 +332,33 @@ def rag_workflow(query):
|
|
332 |
rewritten_query_response = llm.invoke("Hello")
|
333 |
rewritten_query = rewritten_query_response.content.strip()
|
334 |
|
335 |
-
kadi_apy_docs = retrieve_within_kadiApy_docs (vector_store, query, k = 5)
|
336 |
-
kadi_apy_library_docs = retrieve_within_kadiApy_library (vector_store, query, k = 10)
|
337 |
|
338 |
-
doc_context = format_kadi_api_doc_context(kadi_apy_docs)
|
339 |
#print(doc_context)
|
340 |
-
code_context = format_kadi_apy_library_context(kadi_apy_library_docs)
|
341 |
#print("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA:",code_context)
|
342 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
343 |
|
344 |
|
345 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
346 |
|
347 |
prompt = f"""You are an expert python developer. You are assisting in generating code for users who wants to make use of "kadi-apy", an API library.
|
348 |
"Doc-context:" provides you with information how to use this API library by givnig code examples and code documentation.
|
|
|
332 |
rewritten_query_response = llm.invoke("Hello")
|
333 |
rewritten_query = rewritten_query_response.content.strip()
|
334 |
|
335 |
+
#kadi_apy_docs = retrieve_within_kadiApy_docs (vector_store, query, k = 5)
|
336 |
+
#kadi_apy_library_docs = retrieve_within_kadiApy_library (vector_store, query, k = 10)
|
337 |
|
|
|
338 |
#print(doc_context)
|
|
|
339 |
#print("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA:",code_context)
|
340 |
|
341 |
+
|
342 |
+
prompt = f"The query is: '{query}'. What type of metadata applies to this query? Options: python library, python cli library, command line interface.")
|
343 |
+
metadata_prediction = llm.predict(prompt)
|
344 |
+
print(metadata_prediction)
|
345 |
+
|
346 |
+
kadi_apy_docs = retrieve_within_kadiApy_docs (vector_store, query, k = 5)
|
347 |
+
kadi_apy_library_docs = vectorstore.similarity_search(query, filter={"usage": metadata_prediction})
|
348 |
+
|
349 |
+
doc_context = format_kadi_api_doc_context(kadi_apy_docs)
|
350 |
+
code_context = format_kadi_apy_library_context(kadi_apy_library_docs)
|
351 |
|
352 |
|
353 |
+
# Assuming kadi_apy_library_docs is a list of Document objects
|
354 |
+
for idx, doc in enumerate(kadi_apy_library_docs, start=1):
|
355 |
+
# Access the "source" metadata
|
356 |
+
source_value = doc.metadata.get("source", "No source found")
|
357 |
+
# Print the formatted output
|
358 |
+
print(f"=== Document {idx} ===")
|
359 |
+
print(f"Source: {source_value}")
|
360 |
+
print("======================\n")
|
361 |
+
|
362 |
|
363 |
prompt = f"""You are an expert python developer. You are assisting in generating code for users who wants to make use of "kadi-apy", an API library.
|
364 |
"Doc-context:" provides you with information how to use this API library by givnig code examples and code documentation.
|