Spaces:
Sleeping
Sleeping
arjunanand13
commited on
Commit
•
bab91e6
1
Parent(s):
6af3380
Update app.py
Browse files
app.py
CHANGED
@@ -54,6 +54,7 @@ class DocumentRetrievalAndGeneration:
|
|
54 |
def split_documents(self):
|
55 |
text_splitter = RecursiveCharacterTextSplitter(chunk_size=5000, chunk_overlap=250)
|
56 |
all_splits = text_splitter.split_documents(self.documents)
|
|
|
57 |
return all_splits
|
58 |
|
59 |
def query_and_generate_response(self, query):
|
@@ -66,8 +67,25 @@ class DocumentRetrievalAndGeneration:
|
|
66 |
content += self.all_splits[idx].page_content + "\n"
|
67 |
print(self.all_splits[idx].page_content)
|
68 |
print("############################")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
-
|
|
|
|
|
|
|
|
|
71 |
|
72 |
# Encode and prepare inputs
|
73 |
messages = [{"role": "user", "content": prompt}]
|
|
|
54 |
def split_documents(self):
|
55 |
text_splitter = RecursiveCharacterTextSplitter(chunk_size=5000, chunk_overlap=250)
|
56 |
all_splits = text_splitter.split_documents(self.documents)
|
57 |
+
print("LEN of all_splits", all_splits)
|
58 |
return all_splits
|
59 |
|
60 |
def query_and_generate_response(self, query):
|
|
|
67 |
content += self.all_splits[idx].page_content + "\n"
|
68 |
print(self.all_splits[idx].page_content)
|
69 |
print("############################")
|
70 |
+
prompt=f"""
|
71 |
+
You are a knowledgeable assistant with access to a comprehensive database.
|
72 |
+
I need you to answer my question and provide related information in a specific format.
|
73 |
+
I have provided five relatable json files {content}, choose the most suitable chunks for answering the query
|
74 |
+
Here's what I need:
|
75 |
+
Include a final answer without additional comments, sign-offs, or extra phrases. Be direct and to the point.
|
76 |
+
content
|
77 |
+
Here's my question:
|
78 |
+
Query:{query}
|
79 |
+
Solution==>
|
80 |
+
Example1
|
81 |
+
Query: "How to use IPU1_0 instead of A15_0 to process NDK in TDA2x-EVM",
|
82 |
+
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'.",
|
83 |
|
84 |
+
Example2
|
85 |
+
Query: "Can BQ25896 support I2C interface?",
|
86 |
+
Solution: "Yes, the BQ25896 charger supports the I2C interface for communication.",
|
87 |
+
"""
|
88 |
+
# prompt = f"Query: {query}\nSolution: {content}\n"
|
89 |
|
90 |
# Encode and prepare inputs
|
91 |
messages = [{"role": "user", "content": prompt}]
|