Mel Seto commited on
Commit
0184e81
·
1 Parent(s): 6a5b9c2

remove RAG mode and mode dropdown

Browse files
Files changed (1) hide show
  1. src/app.py +5 -29
src/app.py CHANGED
@@ -103,30 +103,11 @@ Answer:"""
103
  # ======================
104
  # UI Wrapper
105
  # ======================
106
- def update_ui(situation, mode):
107
- if mode == "RAG":
108
- top_idioms = retrieve_idiom(situation, top_k=2)
109
- formatted_idioms = []
110
- for idiom_entry in top_idioms:
111
- # Split "<Chinese>: <English>" format
112
- if ": " in idiom_entry:
113
- chinese, english = idiom_entry.split(": ", 1)
114
- else:
115
- chinese, english = idiom_entry, ""
116
- pinyin_text = get_pinyin(chinese)
117
- formatted_idioms.append(f"<div class='idiom-entry'><b>{chinese}</b><br>{pinyin_text}<br>{english}</div>")
118
-
119
- # Combine all entries with horizontal separators
120
- idiom = "<hr>".join(formatted_idioms)
121
- explanation = "Retrieved using embeddings (RAG)."
122
- elif mode == "LLM":
123
- if USE_MOCK:
124
- idiom, explanation = generate_idiom_mock()
125
- else:
126
- idiom, explanation = generate_idiom(situation)
127
  else:
128
- idiom = "Unknown mode"
129
- explanation = ""
130
 
131
  return (
132
  f"<div class='idiom-output'>{idiom}</div>",
@@ -148,11 +129,6 @@ def launch_app():
148
  lines=2,
149
  placeholder="e.g., When facing a big challenge",
150
  )
151
- mode_dropdown = gr.Dropdown(
152
- ["LLM", "RAG"],
153
- label="Mode",
154
- value="RAG",
155
- )
156
  generate_btn = gr.Button("✨ Find Idiom")
157
 
158
  # ✅ Example situations
@@ -174,7 +150,7 @@ def launch_app():
174
  # pylint: disable=no-member
175
  generate_btn.click(
176
  fn=update_ui,
177
- inputs=[situation, mode_dropdown],
178
  outputs=[idiom_output, explanation_output],
179
  )
180
 
 
103
  # ======================
104
  # UI Wrapper
105
  # ======================
106
+ def update_ui(situation):
107
+ if USE_MOCK:
108
+ idiom, explanation = generate_idiom_mock()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  else:
110
+ idiom, explanation = generate_idiom(situation)
 
111
 
112
  return (
113
  f"<div class='idiom-output'>{idiom}</div>",
 
129
  lines=2,
130
  placeholder="e.g., When facing a big challenge",
131
  )
 
 
 
 
 
132
  generate_btn = gr.Button("✨ Find Idiom")
133
 
134
  # ✅ Example situations
 
150
  # pylint: disable=no-member
151
  generate_btn.click(
152
  fn=update_ui,
153
+ inputs=[situation],
154
  outputs=[idiom_output, explanation_output],
155
  )
156