mirror of
https://github.com/TeamWiseFlow/wiseflow.git
synced 2025-01-23 10:50:25 +08:00
fix env sample key
This commit is contained in:
parent
c5cebcce36
commit
6805be7d14
@ -8,8 +8,8 @@
|
||||
|
||||
- PROJECT_DIR="xxxx" #项目缓存文件夹(相对于client文件夹的路径),如果不设定就直接放在repo下面了
|
||||
- WS_LOG="verbose" #设定是否开始debug观察,调试阶段建议开始,尤其可以观察到每一步接口调用的原始请求和返回
|
||||
- LLM_API_BASE: #使用本地大模型推理服务使用(本地加载大模型)的 host:port, 不配置默认走http://localhost:8000
|
||||
- DASHSCOPE_API_KEY="YOUR_DASHSCOPE_API_KEY" #使用阿里灵积大模型推理服务使用
|
||||
- LLM_API_BASE: #使用兼容openaiSDK的LLM服务或者本地大模型推理使用(不配置默认走http://localhost:8000)
|
||||
- LLM_API_KEY="YOUR_DASHSCOPE_API_KEY" #大模型推理服务API KEY(注册参考最下)
|
||||
- ZHIPUAI_API_KEY= #使用智谱大模型接口使用(目前只会调用glm4,model参数没有意义)
|
||||
- VOLC_KEY='AK|SK' #使用火山云翻译api使用,格式为AK|SK
|
||||
- EMBEDDING_MODEL_PATH='' #embedding模型的地址,注意需要填写完整的绝对路径
|
||||
|
@ -1,12 +1,10 @@
|
||||
'''
|
||||
"""
|
||||
除了openai外,很多大模型提供商也都使用openai的SDK,对于这一类可以统一使用本wrapper
|
||||
这里演示使用deepseek提供的DeepSeek-V2
|
||||
'''
|
||||
"""
|
||||
|
||||
import random
|
||||
import os
|
||||
from openai import OpenAI
|
||||
import time
|
||||
|
||||
|
||||
token = os.environ.get('LLM_API_KEY', "")
|
||||
@ -25,32 +23,12 @@ def openai_llm(messages: list, model: str, logger=None, **kwargs) -> str:
|
||||
logger.debug(f'model: {model}')
|
||||
logger.debug(f'kwargs:\n {kwargs}')
|
||||
|
||||
try:
|
||||
response = client.chat.completions.create(messages=messages, model=model, **kwargs)
|
||||
|
||||
for i in range(2):
|
||||
if response and response.choices:
|
||||
break
|
||||
|
||||
except Exception as e:
|
||||
if logger:
|
||||
logger.warning(f"request failed. code: {response}\nretrying...")
|
||||
else:
|
||||
print(f"request failed. code: {response}\nretrying...")
|
||||
|
||||
time.sleep(1 + i * 30)
|
||||
kwargs['seed'] = random.randint(1, 10000)
|
||||
response = client.chat.completions.create(
|
||||
messages=messages,
|
||||
model=model,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
if not response or not response.choices:
|
||||
if logger:
|
||||
logger.warning(
|
||||
f"request failed. code: {response}\nabort after multiple retries...")
|
||||
else:
|
||||
print(
|
||||
f"request failed. code: {response}\naborted after multiple retries...")
|
||||
logger.error(f'openai_llm error: {e}')
|
||||
return ''
|
||||
|
||||
if logger:
|
||||
|
Loading…
Reference in New Issue
Block a user