Update app.py
Browse files
app.py
CHANGED
@@ -106,10 +106,10 @@ def ask_ds(message, history):
|
|
106 |
similar_documents.append((file, similarity))
|
107 |
|
108 |
similar_documents.sort(key=lambda x: x[1], reverse=False)
|
109 |
-
|
110 |
|
111 |
similar_content = ''
|
112 |
-
for file, _ in
|
113 |
similar_content += extractions[file]['content'] + '\n'
|
114 |
|
115 |
# Invoke
|
@@ -119,13 +119,25 @@ def ask_ds(message, history):
|
|
119 |
{
|
120 |
"anthropic_version": "bedrock-2023-05-31",
|
121 |
"max_tokens": 4096,
|
122 |
-
"system": f"""
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
Your task is to review the provided relevant information and answer the user's question to the best of your ability.
|
125 |
-
|
|
|
126 |
|
127 |
-
Format your output nicely with sentences that are not too long. You should prefer lists or
|
128 |
-
Begin by thanking the user for their question, and at the end of your answer, say "Thank you for using Ask Dane Street!"
|
|
|
|
|
129 |
</Task>
|
130 |
|
131 |
<Relevant Information>
|
@@ -163,7 +175,7 @@ def ask_ds(message, history):
|
|
163 |
|
164 |
# Print relevant files
|
165 |
output = '\n\nCheck out the following documents for more information:\n'
|
166 |
-
for file, sim in
|
167 |
output += f"\n{file.replace('.txt', '.pdf')}"
|
168 |
|
169 |
yield all_text + output
|
@@ -174,5 +186,5 @@ bedrock_client = create_bedrock_client()
|
|
174 |
s3_client = create_s3_client()
|
175 |
extractions = read_json_from_s3()
|
176 |
|
177 |
-
demo = gr.ChatInterface(fn=ask_ds, title="
|
178 |
demo.launch()
|
|
|
106 |
similar_documents.append((file, similarity))
|
107 |
|
108 |
similar_documents.sort(key=lambda x: x[1], reverse=False)
|
109 |
+
top_docs = similar_documents[:5]
|
110 |
|
111 |
similar_content = ''
|
112 |
+
for file, _ in top_docs:
|
113 |
similar_content += extractions[file]['content'] + '\n'
|
114 |
|
115 |
# Invoke
|
|
|
119 |
{
|
120 |
"anthropic_version": "bedrock-2023-05-31",
|
121 |
"max_tokens": 4096,
|
122 |
+
"system": f"""Here is some relevant information that may help answer the user's upcoming question:
|
123 |
+
|
124 |
+
<relevant_information>
|
125 |
+
{similar_content}
|
126 |
+
</relevant_information>
|
127 |
+
|
128 |
+
The user's question is:
|
129 |
+
<question>{question}</question>
|
130 |
+
|
131 |
+
Please carefully review the relevant information provided above.
|
132 |
+
|
133 |
Your task is to review the provided relevant information and answer the user's question to the best of your ability.
|
134 |
+
Aim to use information from the relevant information section to directly address the question asked, and refrain from saying
|
135 |
+
things like 'According to the relevant information provided'.
|
136 |
|
137 |
+
Format your output nicely with sentences that are not too long, in a professional and kind tone. You should prefer lists or
|
138 |
+
bullet points when applicable. Begin by thanking the user for their question, and at the end of your answer, say "Thank you for using Ask Dane Street!"
|
139 |
+
Remember, aim to only use information from the relevant information section in your response, without explicitly referring
|
140 |
+
to that section. Return your answer immediately and without preamble.
|
141 |
</Task>
|
142 |
|
143 |
<Relevant Information>
|
|
|
175 |
|
176 |
# Print relevant files
|
177 |
output = '\n\nCheck out the following documents for more information:\n'
|
178 |
+
for file, sim in top_docs:
|
179 |
output += f"\n{file.replace('.txt', '.pdf')}"
|
180 |
|
181 |
yield all_text + output
|
|
|
186 |
s3_client = create_s3_client()
|
187 |
extractions = read_json_from_s3()
|
188 |
|
189 |
+
demo = gr.ChatInterface(fn=ask_ds, title="Ask DS", multimodal=False, chatbot=gr.Chatbot(value=[(None, "Welcome to Ask Dane Street! Whether you're new to the team or just looking for some quick information, I'm here to guide you through our company's literature and platform. Simply ask your question, and I'll provide you with the most relevant information I can.")],),theme=theme)
|
190 |
demo.launch()
|