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

poe的api能否支持文件和图片啊 #5

Open
TeamFan opened this issue Apr 10, 2024 · 5 comments
Open

poe的api能否支持文件和图片啊 #5

TeamFan opened this issue Apr 10, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@TeamFan
Copy link

TeamFan commented Apr 10, 2024

你好,想问一下项目还会有别的更新吗?比如支持文件和图片上传,我那天简单看了一下他的api文档好像可以(?)然后会添加别的模型支持吗😂非常感谢!

@Timmy-web
Copy link
Owner

你好,想问一下项目还会有别的更新吗?比如支持文件和图片上传,我那天简单看了一下他的api文档好像可以(?)然后会添加别的模型支持吗😂非常感谢!

更新应该就是把pr改一改,加一个白名单了。
模型支持那里可以考虑增加command换自定义model的功能。
文件图片上传之前我看了下文档有点抽象,没有上传文件示例,也跟人讨论过,等看看有没有大佬提pr了。

@Timmy-web Timmy-web added the enhancement New feature or request label Apr 10, 2024
@TeamFan
Copy link
Author

TeamFan commented Apr 11, 2024

好的,谢谢作者!期待有大佬提pr!

@canwushuang
Copy link

你好,想问一下项目还会有别的更新吗?比如支持文件和图片上传,我那天简单看了一下他的api文档好像可以(?)然后会添加别的模型支持吗😂非常感谢!

更新应该就是把pr改一改,加一个白名单了。 模型支持那里可以考虑增加command换自定义model的功能。 文件图片上传之前我看了下文档有点抽象,没有上传文件示例,也跟人讨论过,等看看有没有大佬提pr了。

tg的话直接把file_id捕获后本地处理即可,也可以参考modal的方案进行云处理。Poe也是通过三方云计算类似modal去处理文件,然后将结果取回后丢给api进行加工。

@canwushuang
Copy link

canwushuang commented Apr 26, 2024

async def handle_file_message(update: Update, context):
    await handle_message(update, context)
    msg = update.message
    bot = context.bot
    user_id = update.effective_chat.id
    logging.info(f'update信息: {update},{user_name}')
    file_id = msg.photo[-1].file_id if msg.photo else msg.document.file_id
    text = await pix2text(Update, context, file_id)
    logging.info(f'识别文字:{text}')
    message = fp.ProtocolMessage(role="user", content=f'“{text}”,请整理并纠错。以“我收到了你的图片,内容是:\n”开始回复。')
    user_context[user_id]['messages'].append(message)
    await handle_user_request(user_id, update, context)

pix2text可以更换成别的ocr服务即可。可以云也可以本地。
对于文件的处理

    bot = context.bot
    file = await bot.get_file(file_id)
    out = BytesIO()
    await file.download_to_memory(out)
    out.seek(0)

@Timmy-web
Copy link
Owner

async def handle_file_message(update: Update, context):

    await handle_message(update, context)

    msg = update.message

    bot = context.bot

    user_id = update.effective_chat.id

    logging.info(f'update信息: {update},{user_name}')

    file_id = msg.photo[-1].file_id if msg.photo else msg.document.file_id

    text = await pix2text(Update, context, file_id)

    logging.info(f'识别文字:{text}')

    message = fp.ProtocolMessage(role="user", content=f'“{text}”,请整理并纠错。以“我收到了你的图片,内容是:\n”开始回复。')

    user_context[user_id]['messages'].append(message)

    await handle_user_request(user_id, update, context)

pix2text可以更换成别的ocr服务即可。可以云也可以本地。

对于文件的处理

    bot = context.bot

    file = await bot.get_file(file_id)

    out = BytesIO()

    await file.download_to_memory(out)

    out.seek(0)

你这个解决方案可以,就是透过ocr之类的本地处理完成文字,再发送给poe处理。本来我想着直接整个丢给poe让poe自己处理呢,说起来我也好久没更新了😂,上传图片这个我再参考下,争取把白名单整了先

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants