Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -126,16 +126,22 @@ def rag_workflow(query):
|
|
126 |
rag_chain = RAGChain(llm, vector_store)
|
127 |
|
128 |
# Step 1: Predict which library usage is relevant
|
129 |
-
|
|
|
130 |
print(f"Predicted library usage: {library_usage_prediction}")
|
131 |
|
|
|
132 |
# Step 2: Retrieve contexts (documents and code snippets)
|
133 |
-
|
134 |
print("Retrieved Document Contexts:", doc_contexts)
|
135 |
print("Retrieved Code Contexts:", code_contexts)
|
136 |
|
|
|
|
|
|
|
|
|
137 |
# Step 4: Generate the final response
|
138 |
-
response = rag_chain.generate_response(query,
|
139 |
print("Generated Response:", response)
|
140 |
|
141 |
return response
|
|
|
126 |
rag_chain = RAGChain(llm, vector_store)
|
127 |
|
128 |
# Step 1: Predict which library usage is relevant
|
129 |
+
# predict which python library to search in: (standard) kadiAPY-library or kadiAPY-cli-library
|
130 |
+
code_library_usage_prediction = rag_chain.predict_library_usage(query)
|
131 |
print(f"Predicted library usage: {library_usage_prediction}")
|
132 |
|
133 |
+
|
134 |
# Step 2: Retrieve contexts (documents and code snippets)
|
135 |
+
kadiAPY_doc_documents, kadiAPY_code_documents = rag_chain.retrieve_contexts(query, library_usage_prediction)
|
136 |
print("Retrieved Document Contexts:", doc_contexts)
|
137 |
print("Retrieved Code Contexts:", code_contexts)
|
138 |
|
139 |
+
|
140 |
+
formatted_doc_snippets = rag_chain.format_documents(kadiAPY_doc_documents)
|
141 |
+
formatted_code_snippets = rag_chain.format_documents(kadiAPY_code_documents)
|
142 |
+
|
143 |
# Step 4: Generate the final response
|
144 |
+
response = rag_chain.generate_response(query, formatted_doc_snippets, formatted_code_snippets)
|
145 |
print("Generated Response:", response)
|
146 |
|
147 |
return response
|