eeenn commited on
Commit
60b177e
·
verified ·
1 Parent(s): bca68e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -54,14 +54,13 @@ def text_to_image(prompt: str) -> AgentImage:
54
 
55
  resp = requests.post(url, headers=headers, json={"inputs": prompt}, timeout=120)
56
  if resp.status_code != 200:
57
- raise RuntimeError(f"Inference API error {resp.status_code}: {resp.text[:200]}")
58
- if not hf_token:
59
- raise RuntimeError("HF_TOKEN is missing. Please add it in Settings → Variables and Secrets.")
60
-
61
 
62
  img = Image.open(io.BytesIO(resp.content)).convert("RGB")
63
  return AgentImage(img)
64
 
 
65
  @tool
66
  def generate_image(prompt: str) -> AgentImage:
67
  """Generate an image and return AgentImage for UI rendering.
@@ -97,7 +96,7 @@ with open("prompts.yaml", 'r') as stream:
97
 
98
  agent = CodeAgent(
99
  model=model,
100
- tools=[final_answer, DuckDuckGoSearchTool(), image_generation_tool, get_current_time_in_timezone, text_to_image , generate_image ], ## add your tools here (don't remove final answer)
101
  max_steps=6,
102
  verbosity_level=1,
103
  grammar=None,
 
54
 
55
  resp = requests.post(url, headers=headers, json={"inputs": prompt}, timeout=120)
56
  if resp.status_code != 200:
57
+ # 让错误清晰可见(到 Logs)
58
+ raise RuntimeError(f"Inference API error {resp.status_code}: {resp.text[:300]}")
 
 
59
 
60
  img = Image.open(io.BytesIO(resp.content)).convert("RGB")
61
  return AgentImage(img)
62
 
63
+
64
  @tool
65
  def generate_image(prompt: str) -> AgentImage:
66
  """Generate an image and return AgentImage for UI rendering.
 
96
 
97
  agent = CodeAgent(
98
  model=model,
99
+ tools=[final_answer, DuckDuckGoSearchTool(), get_current_time_in_timezone, text_to_image , generate_image ], ## add your tools here (don't remove final answer)
100
  max_steps=6,
101
  verbosity_level=1,
102
  grammar=None,