Julia Ostheimer commited on
Commit
8366a22
·
1 Parent(s): 15d7f94

Update comments where needed and make variables more readable

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -127,12 +127,13 @@ def bot(message, history, source_history) -> list[Any]:
127
 
128
  logger.info("Generated a response", response=response)
129
 
130
- # TODO: Log response from source_history.py
131
  source_history = log_response(response, source_history, user_input_prompt)
132
 
133
  return [response["messages"][-1].content], source_history
134
 
135
  with gr.Blocks() as demo:
 
136
  source_history = gr.State([])
137
 
138
  gr.Markdown("### Dies ist der aktuelle Prototyp der DEval AI4Kontextanalysen, mit dem Fokus auf dem Testen der Zitationsfunktion und der grundlegenden Konfiguration.")
@@ -150,8 +151,9 @@ with gr.Blocks() as demo:
150
  additional_outputs=[source_history],
151
  )
152
  with gr.Tab("Quellen"):
153
- state_display = gr.Markdown()
154
- source_history.change(prettify_source_history, source_history, state_display)
 
155
 
156
  if __name__ == "__main__":
157
  demo.launch(share=False, server_name="0.0.0.0")
 
127
 
128
  logger.info("Generated a response", response=response)
129
 
130
+ # Append source details of the response to source history
131
  source_history = log_response(response, source_history, user_input_prompt)
132
 
133
  return [response["messages"][-1].content], source_history
134
 
135
  with gr.Blocks() as demo:
136
+ # Initialize source history as session state variable
137
  source_history = gr.State([])
138
 
139
  gr.Markdown("### Dies ist der aktuelle Prototyp der DEval AI4Kontextanalysen, mit dem Fokus auf dem Testen der Zitationsfunktion und der grundlegenden Konfiguration.")
 
151
  additional_outputs=[source_history],
152
  )
153
  with gr.Tab("Quellen"):
154
+ prettified_source_history_md = gr.Markdown()
155
+ # Update the source history UI immediately when the source_history value changes
156
+ source_history.change(prettify_source_history, source_history, prettified_source_history_md)
157
 
158
  if __name__ == "__main__":
159
  demo.launch(share=False, server_name="0.0.0.0")