Spaces:
Runtime error
Runtime error
arjunanand13
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -59,8 +59,25 @@ class DocumentRetrievalAndGeneration:
|
|
59 |
content += self.documents[idx].page_content + "\n"
|
60 |
print(self.documents[idx].page_content)
|
61 |
print("############################")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
-
|
|
|
|
|
|
|
|
|
64 |
|
65 |
# Encode and prepare inputs
|
66 |
messages = [{"role": "user", "content": prompt}]
|
@@ -79,7 +96,7 @@ class DocumentRetrievalAndGeneration:
|
|
79 |
print("Time elapsed:", elapsed_time)
|
80 |
print("Device in use:", self.llm.device)
|
81 |
|
82 |
-
return generated_response
|
83 |
|
84 |
def qa_infer_gradio(self, query):
|
85 |
response = self.query_and_generate_response(query)
|
@@ -130,7 +147,7 @@ if __name__ == "__main__":
|
|
130 |
allow_flagging='never',
|
131 |
examples=EXAMPLES,
|
132 |
cache_examples=False,
|
133 |
-
outputs=gr.Textbox(label="SOLUTION"),
|
134 |
css=css_code
|
135 |
)
|
136 |
|
|
|
59 |
content += self.documents[idx].page_content + "\n"
|
60 |
print(self.documents[idx].page_content)
|
61 |
print("############################")
|
62 |
+
prompt=f"""
|
63 |
+
You are a knowledgeable assistant with access to a comprehensive database.
|
64 |
+
I need you to answer my question and provide related information in a specific format.
|
65 |
+
I have provided five relatable json files {content}, choose the most suitable chunks for answering the query
|
66 |
+
Here's what I need:
|
67 |
+
Include a final answer without additional comments, sign-offs, or extra phrases. Be direct and to the point.
|
68 |
+
content
|
69 |
+
Here's my question:
|
70 |
+
Query:{query}
|
71 |
+
Solution==>
|
72 |
+
Example1
|
73 |
+
Query: "How to use IPU1_0 instead of A15_0 to process NDK in TDA2x-EVM",
|
74 |
+
Solution: "To use IPU1_0 instead of A15_0 to process NDK in TDA2x-EVM, you need to modify the configuration file of the NDK application. Specifically, change the processor reference from 'A15_0' to 'IPU1_0'.",
|
75 |
|
76 |
+
Example2
|
77 |
+
Query: "Can BQ25896 support I2C interface?",
|
78 |
+
Solution: "Yes, the BQ25896 charger supports the I2C interface for communication.",
|
79 |
+
"""
|
80 |
+
# prompt = f"Query: {query}\nSolution: {content}\n"
|
81 |
|
82 |
# Encode and prepare inputs
|
83 |
messages = [{"role": "user", "content": prompt}]
|
|
|
96 |
print("Time elapsed:", elapsed_time)
|
97 |
print("Device in use:", self.llm.device)
|
98 |
|
99 |
+
return generated_response,content
|
100 |
|
101 |
def qa_infer_gradio(self, query):
|
102 |
response = self.query_and_generate_response(query)
|
|
|
147 |
allow_flagging='never',
|
148 |
examples=EXAMPLES,
|
149 |
cache_examples=False,
|
150 |
+
outputs=[gr.Textbox(label="SOLUTION"), gr.Textbox(label="RELATED QUERIES")],
|
151 |
css=css_code
|
152 |
)
|
153 |
|