File tree Expand file tree Collapse file tree 3 files changed +16
-13
lines changed Expand file tree Collapse file tree 3 files changed +16
-13
lines changed Original file line number Diff line number Diff line change 33app /mrmax.py
44db
55/venv /
6+ .idea
7+ .venv
8+ * .iml
9+ * .pyc
Original file line number Diff line number Diff line change 88# api 接口封装类
99llm_api_impl = "llm_api.llm_api_default.LLMApiDefault"
1010
11- # api 配置默使用认UnionLLM,参考:https://github.com/EvalsOne/UnionLLM/tree/main/docs
11+ # api 配置方式参考 docs/llm_api.md
12+ # 默认使用认UnionLLM,参考:https://github.com/EvalsOne/UnionLLM/tree/main/docs
1213# UnionLLM兼容LiteLLM,参考LiteLLM文档:https://docs.litellm.ai/docs
1314api_config = {
14- "OPENAI_API_KEY " : "your openai key" ,
15- "OPENAI_API_BASE " : "https://api.openai.com/v1" ,
16- "MODEL_NAME " : model_gpt_4o ,
17- "PROVIDER " : "openai" ,
15+ "api_key " : "your openai key" ,
16+ "api_base " : "https://api.openai.com/v1" ,
17+ "model " : model_gpt_4o ,
18+ "provider " : "openai" ,
1819}
1920
2021# 2. 提示词
Original file line number Diff line number Diff line change 1111class LLMApiDefault (LLMApiInterface ):
1212
1313 def __init__ (self ):
14- self .model_name = None
14+ self .params = {}
1515 self .response = None
16- self .provider = None
1716
1817 def set_config (self , api_config : dict ) -> bool :
1918 if api_config is None :
2019 raise ValueError ("api_config is None" )
2120 for key in api_config :
22- if key == "MODEL_NAME" :
23- self .model_name = api_config [key ]
24- if key == "PROVIDER" :
25- self .provider = api_config [key ]
26- os .environ [key ] = api_config [key ]
21+ self .params [key ] = api_config [key ]
22+ # 如果为大写,则写入环境变量
23+ if key .isupper ():
24+ os .environ [key ] = api_config [key ]
2725 return True
2826
2927 def generate_text (self , messages : list ) -> bool :
3028 try :
31- self .response = unionchat (provider = self . provider , model = self .model_name , messages = messages )
29+ self .response = unionchat (messages = messages , ** self .params )
3230 except Exception as e :
3331 raise e
3432 return True
You can’t perform that action at this time.
0 commit comments