kuzumab commited on
Commit
b80bdf7
·
verified ·
1 Parent(s): 6aae0f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -53,7 +53,13 @@ class ImageCaptionTool(Tool):
53
 
54
  def forward(self, image):
55
  prompt = "Please describe the content of this picture in detail."
56
- return self.model(prompt, images=[image])
 
 
 
 
 
 
57
 
58
  class AudioToTextTool(Tool):
59
  name = "audio-to-text"
@@ -72,7 +78,12 @@ class AudioToTextTool(Tool):
72
 
73
  def forward(self, audio):
74
  prompt = "Please transcribe this audio content into text."
75
- return self.model(prompt, audios=[audio])
 
 
 
 
 
76
 
77
  # --- Basic Agent Definition ---
78
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
 
53
 
54
  def forward(self, image):
55
  prompt = "Please describe the content of this picture in detail."
56
+ result = self.model(prompt, images=[image])
57
+ # 兼容AgentText等包装类型,确保返回str
58
+ if hasattr(result, "to_raw"):
59
+ return result.to_raw()
60
+ if hasattr(result, "value"):
61
+ return result.value
62
+ return str(result)
63
 
64
  class AudioToTextTool(Tool):
65
  name = "audio-to-text"
 
78
 
79
  def forward(self, audio):
80
  prompt = "Please transcribe this audio content into text."
81
+ result = self.model(prompt, audios=[audio])
82
+ if hasattr(result, "to_raw"):
83
+ return result.to_raw()
84
+ if hasattr(result, "value"):
85
+ return result.value
86
+ return str(result)
87
 
88
  # --- Basic Agent Definition ---
89
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------