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

add interactive api in service for VL models #1444

Merged
merged 1 commit into from
Apr 19, 2024

Conversation

AllentDan
Copy link
Collaborator

@lvhan028 lvhan028 requested a review from irexyc April 17, 2024 10:34
@lvhan028 lvhan028 added the enhancement New feature or request label Apr 17, 2024
@lvhan028
Copy link
Collaborator

def test_interactive_chat_vl(server_ip, server_port):
    from lmdeploy.serve.openai.api_client import APIClient
    api_client = APIClient(f'http://{server_ip}:{server_port}')
    messages = [
        dict(prompt="这张图上是什么",
             image_url='https://raw.githubusercontent.com/QwenLM/Qwen-VL/master/assets/demo.jpeg'),
        dict(prompt="请根据这张图写篇文章"),
        dict(prompt="请以狗的视角,来描述它的主人")
    ]
    for message in messages:
        prompt = message['prompt']
        image_url = message['image_url'] if 'image_url' in message else None
        for item in api_client.chat_interactive_v1(prompt=prompt,
                                                   image_url=image_url,
                                                   session_id=1,
                                                   interactive_mode=True,
                                                   stream=False):
            print(item)

results:

{'text': '很抱歉,我无法回答这个问题,因为您没有提供任何图片或图像。如果您有关于我,或者我如何工作的任何问题,我会很乐意帮助您。', 'tokens': 36, 'input_tokens': 13, 'history_tokens': 610, 'finish_reason': 'stop'}
{'text': '很抱歉,我无法完成这个任务,因为您没有提供任何图片或图像。如果您有关于我,或者我如何工作的任何问题,我会很乐意帮助您。', 'tokens': 37, 'input_tokens': 15, 'history_tokens': 659, 'finish_reason': 'stop'}
{'text': '很抱歉,我无法完成这个任务,因为狗没有自己的主观意识和视角。我是一个人工智能助手,无法从狗的角度描述主人。如果您有关于狗主人的问题,我会很乐意为您提供帮助。', 'tokens': 44, 'input_tokens': 19, 'history_tokens': 711, 'finish_reason': 'stop'}

但是,已经提供了 image_url 了

@lvhan028 lvhan028 self-requested a review April 19, 2024 07:39
@AllentDan
Copy link
Collaborator Author

用的啥模型?我用 deepseek-vl 没复现

@lvhan028
Copy link
Collaborator

qwen-vl-chat

@AllentDan
Copy link
Collaborator Author

没复现,我这边正常

{'text': '图中是一名女子在沙滩上和狗玩耍,旁边的狗是一只拉布拉多犬,它们处于沙滩上。', 'tokens': 26, 'input_tokens': 284, 'history_tokens': 0, 'finish_reason': 'stop'}
{'text': '在这张照片中,一名女子和一只拉布拉多犬在沙滩上玩耍。在他们身后,是一片无垠的海,海的尽头是连绵的山脉。在照片中,女子的脸上洋溢着快乐的笑容,她正在和拉布拉多犬玩着抛接狗粮的游戏。在这欢乐的气氛中,时间仿佛停滞了,只有海浪的声音和他们欢乐的笑声在耳边回荡。这个画面给人一种宁静和自由的感觉,仿佛所有的烦恼都被海风吹散了。这张照片记录了他们欢乐的时光,也记录了他们之间的深厚感情。对于他们来说,这只拉布拉多犬不仅是宠物,更是他们的朋友和家人。这张照片也让我们感受到了人与宠物之间的真挚感情,让我们更加珍惜和宠物一起度过的每一刻。', 'tokens': 168, 'input_tokens': 15, 'history_tokens': 310, 'finish_reason': 'stop'}
{'text': '从狗的视角来看,它的主人是一个非常有趣和善良的人。每天,它都会和主人一起去沙滩上玩耍,享受阳光和海风。主人总是会带很多狗粮来,和它一起玩抛接狗粮的游戏,这是一天中最期待的时刻。每当主人微笑的时候,它也能感受到主人的快乐。主人还会带它去公园散步,和其他狗狗一起玩耍。它相信,主人是它最忠诚的朋友,是它一生的守护者。每次看到主人,它都会感到非常的安心和温暖。', 'tokens': 114, 'input_tokens': 19, 'history_tokens': 493, 'finish_reason': 'stop'}

@lvhan028 lvhan028 changed the title Interactive api service for VL models add interactive api in service for VL models Apr 19, 2024
@lvhan028 lvhan028 merged commit 26076f4 into InternLM:main Apr 19, 2024
4 of 5 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants