feat: vision parameter support of OpenAI Compatible API (#3272)

This commit is contained in:
takatost
2024-04-10 11:13:56 +08:00
committed by GitHub
parent cfb5ccc7d3
commit 97d1e0bbbb
2 changed files with 28 additions and 5 deletions

View File

@@ -167,23 +167,27 @@ class OAIAPICompatLargeLanguageModel(_CommonOAI_API_Compat, LargeLanguageModel):
""" """
generate custom model entities from credentials generate custom model entities from credentials
""" """
support_function_call = False
features = [] features = []
function_calling_type = credentials.get('function_calling_type', 'no_call') function_calling_type = credentials.get('function_calling_type', 'no_call')
if function_calling_type == 'function_call': if function_calling_type == 'function_call':
features = [ModelFeature.TOOL_CALL] features.append(ModelFeature.TOOL_CALL)
support_function_call = True
endpoint_url = credentials["endpoint_url"] endpoint_url = credentials["endpoint_url"]
# if not endpoint_url.endswith('/'): # if not endpoint_url.endswith('/'):
# endpoint_url += '/' # endpoint_url += '/'
# if 'https://api.openai.com/v1/' == endpoint_url: # if 'https://api.openai.com/v1/' == endpoint_url:
# features = [ModelFeature.STREAM_TOOL_CALL] # features.append(ModelFeature.STREAM_TOOL_CALL)
vision_support = credentials.get('vision_support', 'not_support')
if vision_support == 'support':
features.append(ModelFeature.VISION)
entity = AIModelEntity( entity = AIModelEntity(
model=model, model=model,
label=I18nObject(en_US=model), label=I18nObject(en_US=model),
model_type=ModelType.LLM, model_type=ModelType.LLM,
fetch_from=FetchFrom.CUSTOMIZABLE_MODEL, fetch_from=FetchFrom.CUSTOMIZABLE_MODEL,
features=features if support_function_call else [], features=features,
model_properties={ model_properties={
ModelPropertyKey.CONTEXT_SIZE: int(credentials.get('context_size', "4096")), ModelPropertyKey.CONTEXT_SIZE: int(credentials.get('context_size', "4096")),
ModelPropertyKey.MODE: credentials.get('mode'), ModelPropertyKey.MODE: credentials.get('mode'),

View File

@@ -97,6 +97,25 @@ model_credential_schema:
label: label:
en_US: Not Support en_US: Not Support
zh_Hans: 不支持 zh_Hans: 不支持
- variable: vision_support
show_on:
- variable: __model_type
value: llm
label:
zh_Hans: Vision 支持
en_US: Vision Support
type: select
required: false
default: no_support
options:
- value: support
label:
en_US: Support
zh_Hans: 支持
- value: no_support
label:
en_US: Not Support
zh_Hans: 不支持
- variable: stream_mode_delimiter - variable: stream_mode_delimiter
label: label:
zh_Hans: 流模式返回结果的分隔符 zh_Hans: 流模式返回结果的分隔符