Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] 上下文明细(以Token计)没有将上传的图片纳入计算 #2713

Open
3 of 17 tasks
Sun-drenched opened this issue May 29, 2024 · 1 comment
Open
3 of 17 tasks
Labels
🐛 Bug Something isn't working | 缺陷 Inactive No response in 30 days | 超过 30 天未活跃

Comments

@Sun-drenched
Copy link

📦 部署环境

  • Official
  • Official Preview
  • Vercel / Zeabur / Sealos
  • Docker
  • Other

📌 软件版本

0.162.9

💻 系统环境

  • Windows
  • macOS
  • Ubuntu
  • Other Linux
  • iOS
  • Android
  • Other

🌐 浏览器

  • Chrome
  • Edge
  • Safari
  • Firefox
  • Other

🐛 问题描述

使用支持图片分析的模型时,上传的图片也是需要消耗token的,而聊天界面-上下文明细中,只计算了文字占有的token。

📷 复现步骤

No response

🚦 期望结果

No response

📝 补充信息

至少在使用OPENAI提供的模型服务时,计算是比较简洁方便的。官方说明:https://platform.openai.com/docs/guides/vision。
示例代码:
`from math import ceil

def resize(width, height):
if width > 1024 or height > 1024:
if width > height:
height = int(height * 1024 / width)
width = 1024
else:
width = int(width * 1024 / height)
height = 1024
return width, height

def count_image_tokens(width: int, height: int):
width, height = resize(width, height)
h = ceil(height / 512)
w = ceil(width / 512)
total = 85 + 170 * h * w
return total`

@Sun-drenched Sun-drenched added the 🐛 Bug Something isn't working | 缺陷 label May 29, 2024
@github-project-automation github-project-automation bot moved this to Roadmap - Chat 1.x in Lobe Chat Routine May 29, 2024
@lobehubbot
Copy link
Member

👀 @GSYCCN

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible.
Please make sure you have given us as much context as possible.
非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。

@lobehubbot lobehubbot added the Inactive No response in 30 days | 超过 30 天未活跃 label Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working | 缺陷 Inactive No response in 30 days | 超过 30 天未活跃
Projects
Status: Roadmap - Chat 1.x
Development

No branches or pull requests

2 participants