XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/gpt4free

Add documentation for image metadata in Usage class and improve comments

Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>

f4a770ec
copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
提交于

代码差异

2 个文件 +8 -1
Modified g4f/gui/server/api.py +2 -1
@@ -251,13 +251,14 @@ class Api:
251 251 logger.exception(e)
252 252 options["target_paths"] = target_paths
253 253 # Collect image metadata for usage statistics
254 # For image generation, we show dimensions and file size instead of token counts
254 255 if isinstance(chunk, ImageResponse):
255 256 image_metadata = {
256 257 "images": len(target_paths),
257 258 "width": width,
258 259 "height": height,
259 260 }
260 # Calculate total file size
261 # Calculate total file size across all generated images
261 262 total_size = 0
262 263 for path in target_paths:
263 264 try:
Modified g4f/providers/response.py +6 -0
@@ -197,6 +197,12 @@ class ToolCalls(HiddenResponse):
197 197 return self.list
198 198
199 199 class Usage(JsonMixin, HiddenResponse):
200 """
201 Usage statistics for API responses.
202
203 For text generation, this includes token counts.
204 For image generation, this includes image metadata (width, height, file_size, images).
205 """
200 206 def __init__(
201 207 self,
202 208 promptTokens: int = None,