初始化项目:langgraph 学习笔记与 lg_common 通用组件包
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import os
|
||||
|
||||
from langchain.chat_models import init_chat_model
|
||||
|
||||
|
||||
def get_llm(
|
||||
model: str = "openai:qwen3.6-flash",
|
||||
base_url: str | None = None,
|
||||
api_key: str | None = None,
|
||||
**kwargs,
|
||||
):
|
||||
"""初始化 ChatModel,默认从环境变量读取 BASE_URL / API_KEY。"""
|
||||
if base_url is None:
|
||||
base_url = os.getenv("BASE_URL")
|
||||
if api_key is None:
|
||||
api_key = os.getenv("API_KEY")
|
||||
return init_chat_model(model=model, base_url=base_url, api_key=api_key, **kwargs)
|
||||
Reference in New Issue
Block a user