Theright07 commited on
Commit
c83d6aa
·
verified ·
1 Parent(s): 1ab4a0c

Fix: add type='tuples' to Chatbot, fix history iteration, remove share=True error

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -135,9 +135,13 @@ TOOL_RE = re.compile(r"```tool\s*(\{.*?\})\s*```", re.S)
135
 
136
  def run_agent(user_msg, history, max_steps=6):
137
  msgs = [{"role": "system", "content": SYSTEM}]
138
- for u, a in history:
139
- msgs.append({"role": "user", "content": u})
140
- msgs.append({"role": "assistant", "content": a})
 
 
 
 
141
  msgs.append({"role": "user", "content": user_msg})
142
 
143
  transcript = ""
@@ -161,7 +165,7 @@ def run_agent(user_msg, history, max_steps=6):
161
 
162
  with gr.Blocks(title="Android Build Agent") as demo:
163
  gr.Markdown("## 🤖 Android Build Agent (Qwen2.5-Coder + Gradle + SDK)")
164
- chat = gr.Chatbot(height=500)
165
  box = gr.Textbox(placeholder="e.g. clone https://github.com/.../MyApp and build debug APK")
166
  state = gr.State([])
167
 
@@ -172,4 +176,4 @@ with gr.Blocks(title="Android Build Agent") as demo:
172
 
173
  box.submit(respond, [box, state], [box, chat, state])
174
 
175
- demo.queue().launch(server_name="0.0.0.0", server_port=7860)
 
135
 
136
  def run_agent(user_msg, history, max_steps=6):
137
  msgs = [{"role": "system", "content": SYSTEM}]
138
+ for item in history:
139
+ if isinstance(item, (list, tuple)) and len(item) == 2:
140
+ u, a = item
141
+ if u:
142
+ msgs.append({"role": "user", "content": str(u)})
143
+ if a:
144
+ msgs.append({"role": "assistant", "content": str(a)})
145
  msgs.append({"role": "user", "content": user_msg})
146
 
147
  transcript = ""
 
165
 
166
  with gr.Blocks(title="Android Build Agent") as demo:
167
  gr.Markdown("## 🤖 Android Build Agent (Qwen2.5-Coder + Gradle + SDK)")
168
+ chat = gr.Chatbot(height=500, type="tuples")
169
  box = gr.Textbox(placeholder="e.g. clone https://github.com/.../MyApp and build debug APK")
170
  state = gr.State([])
171
 
 
176
 
177
  box.submit(respond, [box, state], [box, chat, state])
178
 
179
+ demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=False)