-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Frontend] Add OpenAI Vision API Support (#5237)
Co-authored-by: DarkLight1337 <tlleungac@connect.ust.hk>
- Loading branch information
1 parent
ca3ea51
commit 7a9cb29
Showing
9 changed files
with
653 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{%- if messages[0]['role'] == 'system' -%} | ||
{%- set system_message = messages[0]['content'] -%} | ||
{%- set messages = messages[1:] -%} | ||
{%- else -%} | ||
{% set system_message = '' -%} | ||
{%- endif -%} | ||
|
||
{{ bos_token + system_message }} | ||
{%- for message in messages -%} | ||
{%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) -%} | ||
{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }} | ||
{%- endif -%} | ||
|
||
{%- if message['role'] == 'user' -%} | ||
{{ 'USER: ' + message['content'] + '\n' }} | ||
{%- elif message['role'] == 'assistant' -%} | ||
{{ 'ASSISTANT: ' + message['content'] + eos_token + '\n' }} | ||
{%- endif -%} | ||
{%- endfor -%} | ||
|
||
{%- if add_generation_prompt -%} | ||
{{ 'ASSISTANT:' }} | ||
{% endif %} |
Oops, something went wrong.