Fix Type with new OpenAI Endpoint (#480)

This commit is contained in:
Yuhong Sun
2023-09-25 11:15:56 -07:00
committed by GitHub
parent 0c3ecbfa2f
commit 6d376d3cf6

View File

@@ -1,5 +1,6 @@
import os
from typing import Any
from typing import cast
from langchain.chat_models.openai import ChatOpenAI
@@ -28,7 +29,8 @@ class OpenAIGPT(LangChainChatLLM):
self._llm = ChatOpenAI(
model=model_version,
openai_api_key=api_key,
openai_api_base=kwargs.get('endpoint', ''),
# Prefer using None which is the default value, endpoint could be empty string
openai_api_base=cast(str, kwargs.get("endpoint")) or None,
max_tokens=max_output_tokens,
temperature=temperature,
request_timeout=timeout,