Skip to content

LangChain


注意事项 ​

  • openai_api_base, 的末尾要加上, /v1/chat/completions, ,而且目前只支持 Chat 模型,请确认不要导入错误的包。

示例代码 ​

python
from langchain.chat_models import ChatOpenAI

llm = ChatOpenAI(
    openai_api_base="https://api.changhuai.ai/v1/chat/completions", 
    openai_api_key="sk-xxxxx",
)

res = llm.predict("hello")

print(res)