MCPcopy Create free account
hub / github.com/aws-samples/sample-devgenius-aws-solution-builder / collect_feedback

Function collect_feedback

chatbot/utils.py:184–214  ·  view source on GitHub ↗
(uuid, response, use_case, bedrock_model_name)

Source from the content-addressed store, hash-verified

182# Retrieve feedback
183@st.fragment
184def collect_feedback(uuid, response, use_case, bedrock_model_name):
185 FEEDBACK_TABLE_NAME = retrieve_environment_variables("FEEDBACK_TABLE_NAME")
186 selected = st.feedback("thumbs", key=f"s-{uuid}")
187 if selected is not None:
188 print("about to write to dynamo")
189 text = st.text_input(
190 f"fe-{uuid}", label_visibility="hidden",
191 placeholder="[MANDATORY] Please provide an explanation to submit the feedback",
192 )
193 if text:
194 print(f"feedback sentiment: {selected}. feedback explanation: {text}.")
195 print(f"uuid: {uuid}. conversation_id: {st.session_state['conversation_id']}")
196 print(f"bedrock_model_name: {bedrock_model_name}. use_case: {use_case}.")
197 current_datetime = datetime.datetime.now(tz=datetime.timezone.utc)
198 current_datetime = current_datetime.strftime("%Y-%m-%d %H:%M:%S")
199 item = {
200 'conversation_id': st.session_state['conversation_id'],
201 'uuid': uuid,
202 'feedback': selected,
203 'feedback_explanation': text,
204 'response': response,
205 'conversation_time': current_datetime,
206 'bedrock_model': bedrock_model_name,
207 'use_case': use_case
208 }
209 feedback_table = dynamodb_resource.Table(FEEDBACK_TABLE_NAME)
210 print(f"About to write item to dynamodb: {item}")
211 feedback_table.put_item(Item=item)
212 print(f"updated item in DynamoDB table: {FEEDBACK_TABLE_NAME}")
213 sentiment_mapping = [":material/thumb_down:", ":material/thumb_up:"]
214 st.markdown(f"Feedback rating: {sentiment_mapping[selected]}. Feedback text: {text}")
215
216
217def retrieve_environment_variables(key):

Callers 5

generate_cfnFunction · 0.90
generate_cdkFunction · 0.90
generate_docFunction · 0.90
generate_archFunction · 0.90
generate_cost_estimatesFunction · 0.90

Calls 1

Tested by

no test coverage detected