Julien Matuszak commited on
Commit
0a4c508
·
verified ·
1 Parent(s): f59d858

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -116,14 +116,16 @@ def process_request(input_text):
116
  # Return the translations and contexts
117
  return translations, context_results
118
 
119
- # Gradio interface
120
  def gradio_interface(input_text):
121
  translations, contexts = process_request(input_text)
122
- # Format the output
123
- output = "Translations:\n\n"
 
124
  for context, translation in translations.items():
125
- output += f"**{context.capitalize()}**: {translation}\n\n"
126
- return output.strip()
 
 
127
 
128
  # Create the Gradio interface
129
  interface = gr.Interface(
 
116
  # Return the translations and contexts
117
  return translations, context_results
118
 
 
119
  def gradio_interface(input_text):
120
  translations, contexts = process_request(input_text)
121
+
122
+ # Format the output as a JSON-serializable list of dictionaries
123
+ output = []
124
  for context, translation in translations.items():
125
+ output.append({"context": context.capitalize(), "text": translation})
126
+
127
+ # Return the JSON-serializable object
128
+ return output
129
 
130
  # Create the Gradio interface
131
  interface = gr.Interface(