Spaces:
Sleeping
Sleeping
Upload generator.py
Browse files- generator.py +16 -16
generator.py
CHANGED
@@ -11,23 +11,23 @@ def generate_response_from_document(query, retrieved_docs):
|
|
11 |
|
12 |
# context = " ".join([doc.page_content for doc in retrieved_docs]) # Now iterates over Document objects
|
13 |
context = " ".join([doc for doc in retrieved_docs])
|
14 |
-
prompt = """
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
"""
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
|
32 |
try:
|
33 |
response = openai.chat.completions.create( # Use the new chat completions API
|
|
|
11 |
|
12 |
# context = " ".join([doc.page_content for doc in retrieved_docs]) # Now iterates over Document objects
|
13 |
context = " ".join([doc for doc in retrieved_docs])
|
14 |
+
# prompt = """
|
15 |
+
# "You are an accurate and reliable AI assistant that can answer questions with the help of external documents.
|
16 |
+
# Please note that external documents may contain noisy or factually incorrect information.
|
17 |
+
# If the information in the document contains the correct answer, you will give an accurate answer.
|
18 |
+
# If the information in the document does not contain the answer, you will generate ’I can not answer the question because of the insufficient information in documents.‘.
|
19 |
+
# If there are inconsistencies with the facts in some of the documents, please generate the response 'There are factual errors in the provided documents.' and provide the correct answer."
|
20 |
|
21 |
+
# Context or Document: {context}
|
22 |
+
# Query: {query}
|
23 |
+
# """
|
24 |
+
prompt = (
|
25 |
+
"You are a highly intelligent assistant tasked with answering a question based strictly on the provided context. "
|
26 |
+
f"Given Question: {query} \n\n"
|
27 |
+
f"Context: {context} \n"
|
28 |
+
f"Answer the question directly and concisely using only the information available in the context."
|
29 |
+
"Do not include any other information which is not there in the context."
|
30 |
+
)
|
31 |
|
32 |
try:
|
33 |
response = openai.chat.completions.create( # Use the new chat completions API
|