jcleee commited on
Commit
9a2c5c8
·
verified ·
1 Parent(s): a5d26ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -21
app.py CHANGED
@@ -122,13 +122,13 @@ agent = CodeAgent(
122
 
123
  import gradio as gr
124
 
125
- # # OLD VERSION
126
- # def run_agent(question):
127
- # try:
128
- # result = agent(question)
129
- # return [str(result)] # Must return a list with one string (like ["answer"])
130
- # except Exception as e:
131
- # return [f"Error: {e}"]
132
 
133
  # # NEW VERSION
134
  # def run_agent(question):
@@ -156,23 +156,23 @@ import gradio as gr
156
  # except Exception as e:
157
  # return [f"Error: {e}"]
158
 
159
- # NEWER VERSION (should just return the result)
160
- import re
161
 
162
- def run_agent(question):
163
- try:
164
- result = agent(question)
165
 
166
- # If result is a string and contains "### 1. Task outcome", extract that
167
- if isinstance(result, str):
168
- match = re.search(r"### 1\. Task outcome \(short version\):\s*(.+)", result)
169
- if match:
170
- return [match.group(1).strip()] # return just the short answer
171
- return [result.strip()]
172
 
173
- return [str(result)]
174
- except Exception as e:
175
- return [f"Error: {e}"]
176
 
177
 
178
  demo = gr.Interface(fn=run_agent, inputs="text", outputs="text")
 
122
 
123
  import gradio as gr
124
 
125
+ # OLD VERSION
126
+ def run_agent(question):
127
+ try:
128
+ result = agent(question)
129
+ return [str(result)] # Must return a list with one string (like ["answer"])
130
+ except Exception as e:
131
+ return [f"Error: {e}"]
132
 
133
  # # NEW VERSION
134
  # def run_agent(question):
 
156
  # except Exception as e:
157
  # return [f"Error: {e}"]
158
 
159
+ # # NEWER VERSION (should just return the result)
160
+ # import re
161
 
162
+ # def run_agent(question):
163
+ # try:
164
+ # result = agent(question)
165
 
166
+ # # If result is a string and contains "### 1. Task outcome", extract that
167
+ # if isinstance(result, str):
168
+ # match = re.search(r"### 1\. Task outcome \(short version\):\s*(.+)", result)
169
+ # if match:
170
+ # return [match.group(1).strip()] # return just the short answer
171
+ # return [result.strip()]
172
 
173
+ # return [str(result)]
174
+ # except Exception as e:
175
+ # return [f"Error: {e}"]
176
 
177
 
178
  demo = gr.Interface(fn=run_agent, inputs="text", outputs="text")