feat: create_llama_index_llm
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from langchain_core.runnables import RunnableLambda
|
||||
from langchain_openai import ChatOpenAI
|
||||
from llama_index.llms.openai_like import OpenAILike
|
||||
|
||||
from app.config.ai_configs import ai_configs
|
||||
from app.utils.CustomEmbeddings import CustomEmbeddings
|
||||
@@ -19,6 +20,23 @@ def create_llm(platform_code='huoshan-doubao', temperature=0.5):
|
||||
)
|
||||
|
||||
|
||||
def create_llama_index_llm(platform_code='huoshan-doubao', temperature=0.5):
|
||||
_ai_config = ai_configs.get(platform_code)
|
||||
|
||||
if _ai_config is None:
|
||||
raise Exception('Unknown platform code', platform_code)
|
||||
|
||||
return OpenAILike(
|
||||
api_base=_ai_config.get('url').replace("chat/completions", ""),
|
||||
api_key=_ai_config.get('key'),
|
||||
model=_ai_config.get('model'),
|
||||
temperature=temperature,
|
||||
max_tokens=None, # 不限制最大token
|
||||
is_chat_model=True, # 明确指定是聊天模型
|
||||
timeout=120.0, # 增加超时时间
|
||||
)
|
||||
|
||||
|
||||
def create_embeddings(platform_code="huoshan-embedding-240715"):
|
||||
"""
|
||||
创建自定义嵌入模型实例
|
||||
|
||||
Reference in New Issue
Block a user