|
| 1 | +# coding=utf-8 |
| 2 | +""" |
| 3 | + @project: maxkb |
| 4 | + @Author:虎 |
| 5 | + @file: openai_model_provider.py |
| 6 | + @date:2024/3/28 16:26 |
| 7 | + @desc: |
| 8 | +""" |
| 9 | +import os |
| 10 | + |
| 11 | +from common.util.file_util import get_file_content |
| 12 | +from setting.models_provider.base_model_provider import IModelProvider, ModelProvideInfo, ModelInfo, \ |
| 13 | + ModelTypeConst, ModelInfoManage |
| 14 | +from setting.models_provider.impl.anthropic_model_provider.credential.image import AnthropicImageModelCredential |
| 15 | +from setting.models_provider.impl.anthropic_model_provider.credential.llm import AnthropicLLMModelCredential |
| 16 | +from setting.models_provider.impl.anthropic_model_provider.model.image import AnthropicImage |
| 17 | +from setting.models_provider.impl.anthropic_model_provider.model.llm import AnthropicChatModel |
| 18 | +from smartdoc.conf import PROJECT_DIR |
| 19 | + |
| 20 | +openai_llm_model_credential = AnthropicLLMModelCredential() |
| 21 | +openai_image_model_credential = AnthropicImageModelCredential() |
| 22 | + |
| 23 | +model_info_list = [ |
| 24 | + ModelInfo('claude-3-opus-20240229', '', ModelTypeConst.LLM, |
| 25 | + openai_llm_model_credential, AnthropicChatModel |
| 26 | + ), |
| 27 | + ModelInfo('claude-3-sonnet-20240229', '', ModelTypeConst.LLM, openai_llm_model_credential, |
| 28 | + AnthropicChatModel), |
| 29 | + ModelInfo('claude-3-haiku-20240307', '', ModelTypeConst.LLM, openai_llm_model_credential, |
| 30 | + AnthropicChatModel), |
| 31 | + ModelInfo('claude-3-5-sonnet-20240620', '', ModelTypeConst.LLM, openai_llm_model_credential, |
| 32 | + AnthropicChatModel), |
| 33 | + ModelInfo('claude-3-5-haiku-20241022', '', ModelTypeConst.LLM, openai_llm_model_credential, |
| 34 | + AnthropicChatModel), |
| 35 | + ModelInfo('claude-3-5-sonnet-20241022', '', ModelTypeConst.LLM, openai_llm_model_credential, |
| 36 | + AnthropicChatModel), |
| 37 | +] |
| 38 | + |
| 39 | +image_model_info = [ |
| 40 | + ModelInfo('claude-3-5-sonnet-20241022', '', ModelTypeConst.IMAGE, openai_image_model_credential, |
| 41 | + AnthropicImage), |
| 42 | +] |
| 43 | + |
| 44 | +model_info_manage = ( |
| 45 | + ModelInfoManage.builder() |
| 46 | + .append_model_info_list(model_info_list) |
| 47 | + .append_default_model_info(model_info_list[0]) |
| 48 | + .append_model_info_list(image_model_info) |
| 49 | + .append_default_model_info(image_model_info[0]) |
| 50 | + .build() |
| 51 | +) |
| 52 | + |
| 53 | + |
| 54 | +class AnthropicModelProvider(IModelProvider): |
| 55 | + |
| 56 | + def get_model_info_manage(self): |
| 57 | + return model_info_manage |
| 58 | + |
| 59 | + def get_model_provide_info(self): |
| 60 | + return ModelProvideInfo(provider='model_anthropic_provider', name='Anthropic', icon=get_file_content( |
| 61 | + os.path.join(PROJECT_DIR, "apps", "setting", 'models_provider', 'impl', 'anthropic_model_provider', 'icon', |
| 62 | + 'anthropic_icon_svg'))) |
0 commit comments