igrisds commited on
Commit
7369ec3
1 Parent(s): b45f0c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -9
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
- top_3 = similar_documents[:3]
110
 
111
  similar_content = ''
112
- for file, _ in top_3:
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"""You are a helpful, excited assistant that answers questions about certain provided documents.
123
- <Task>
 
 
 
 
 
 
 
 
 
124
  Your task is to review the provided relevant information and answer the user's question to the best of your ability.
125
- Try to use only the information in the document to answer. Refrain from saying things like 'According to the relevant information provided'.
 
126
 
127
- Format your output nicely with sentences that are not too long. You should prefer lists or bullet points but only when applicable.
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 top_3:
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="AskDS_HR", multimodal=False, chatbot=gr.Chatbot(value=[(None, "Welcome to Ask HR at 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. From Benefits and Payroll queries to understanding our Policies or Paylocity, simply ask your question and I'll provide you with the most relevant information I can.\n\nCurious about your 401(k) account changes? Or maybe you need details on the 2023 Benefits Guide? I can help with that and much more! Don't hesitate to ask, and thank you for making Dane Street an amazing place to work. If there’s something specific you'd like to know, please type your question below, and I will do my best to assist you.")],),theme=theme)
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()