bupa1018 commited on
Commit
84e6b4c
·
1 Parent(s): 0a4582b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -26
app.py CHANGED
@@ -326,34 +326,10 @@ def format_kadi_api_doc_context(docs):
326
 
327
  def rag_workflow(query):
328
 
329
- rewrite_prompt = f"""You are an intelligent assistant that helps users rewrite their queries.
330
- The vectorstore consists of the source code and documentation of a Python library, which enables users to
331
- programmatically interact with a REST-like API of a software system. The library methods have descriptive
332
- docstrings. Your task is to rewrite the query in a way that aligns with the language and structure of the
333
- library's methods and documentation, ensuring optimal retrieval of relevant information.
334
-
335
- Guidelines for rewriting the query:
336
- 1. Identify the main action the user wants to perform (e.g., "Upload a file to a record," "Get users of a group").
337
- 2. Remove conversational elements like greetings or pleasantries (e.g., "Hello Chatbot", "I need you to help me with").
338
- 3. Exclude specific variable values (e.g., "ID of my record is '31'") unless essential to the intent.
339
- 4. Rephrase the query to match the format and keywords used in the docstrings, focusing on verbs and objects relevant to the action (e.g., "Add a record to a collection").
340
- 5. Given the query the user might need more than one method to achieve his goal.
341
-
342
- Examples:
343
- - User query: "Create a Python script with a method that facilitates the creation of records. This method should accept an array of identifiers as a parameter and allow metadata to be added to each record."
344
- - Rewritten query: "create records, add metadata to record"
345
- - User query: "Hi, can you help me write Python code to add a record to a collection? The record ID is '45', and the collection ID is '12'."
346
- Rewritten query: "add a record to a collection"
347
- - User query: "I have a folder with files in my local disc and i need a python script with which i can upload the files to a record. The id of the record is 324. The path to the folder is: r"C:\Users\Anwender\Documents\League of Legends"
348
- Rewritten query: "upload files to a record"
349
-
350
- Based on these examples and guidelines, rewrite the following user query to align more effectively with the keywords used in the docstrings.
351
- Original query:
352
- {query}
353
- """
354
 
355
 
356
- rewritten_query_response = llm.invoke(rewrite_prompt)
357
  rewritten_query = rewritten_query_response.content.strip()
358
 
359
  kadi_apy_docs = retrieve_within_kadiApy_docs (vector_store, query, k = 5)
 
326
 
327
  def rag_workflow(query):
328
 
329
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
 
331
 
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)