Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -45,25 +45,33 @@ def util_bot(question: str) -> Optional[str]:
|
|
45 |
|
46 |
# Perform vector search in the "util-bot" collection
|
47 |
response = qdrant_client.search(
|
48 |
-
collection_name="util-bot",
|
49 |
query_vector=query_result,
|
50 |
limit=3 # Retrieve top 3 closest vectors
|
51 |
)
|
52 |
|
53 |
# Construct the prompt template for the LLM
|
54 |
prompt=PromptTemplate(
|
55 |
-
template=""""
|
56 |
-
|
57 |
-
answer is not in the context, answer using your knowledge.
|
58 |
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
{context}
|
61 |
-
|
62 |
|
63 |
Question: {question}
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
67 |
|
68 |
# Initialize LLM and the chain for generating the response
|
69 |
llm = ChatOpenAI(model='gpt-3.5-turbo-0125',openai_api_key=os.environ['openai_api_key'])
|
|
|
45 |
|
46 |
# Perform vector search in the "util-bot" collection
|
47 |
response = qdrant_client.search(
|
48 |
+
collection_name="util-bot-quantized",
|
49 |
query_vector=query_result,
|
50 |
limit=3 # Retrieve top 3 closest vectors
|
51 |
)
|
52 |
|
53 |
# Construct the prompt template for the LLM
|
54 |
prompt=PromptTemplate(
|
55 |
+
template=""""
|
56 |
+
Given the context from the utility bills document, answer the following question. The document includes general text, definitions, formulas, and charts related to utility bills. Use the information provided in the document to construct your answer. If the answer is not explicitly found in the document, it's okay to say "The context does not include any reference for the question asked" instead of guessing.
|
|
|
57 |
|
58 |
+
Example:
|
59 |
+
Question: What is the formula for calculating the monthly electricity bill?
|
60 |
+
Answer:
|
61 |
+
```
|
62 |
+
The monthly electricity bill is calculated using the formula: Bill = Rate per kWh * Number of kWh consumed. This formula takes into account the rate charged per kilowatt-hour (kWh) and the total energy consumption in kWh.
|
63 |
+
```
|
64 |
+
|
65 |
+
<utility_bills_document>
|
66 |
{context}
|
67 |
+
</utility_bills_document>
|
68 |
|
69 |
Question: {question}
|
70 |
+
|
71 |
+
Helpful Answer:Formatted as per the requirement
|
72 |
+
""",
|
73 |
+
input_variables=["context", "question"]
|
74 |
+
)
|
75 |
|
76 |
# Initialize LLM and the chain for generating the response
|
77 |
llm = ChatOpenAI(model='gpt-3.5-turbo-0125',openai_api_key=os.environ['openai_api_key'])
|