我正在研究在Python中集成LangChain
和AzureOpenAI
,并遇到了一些问题.我最近从一个废弃的方法更新到了一个新的类实现,但现在我遇到了一些我不完全理解的错误.下面是我代码的相关部分:
from langchain_openai import AzureOpenAI as LCAzureOpenAI
# from langchain.llms import AzureOpenAI <-- Deprecated
# Create client accessing LangChain's class
client = LCAzureOpenAI(
openai_api_version=api_version,
azure_deployment=deployment_name,
azure_endpoint=azure_endpoint,
temperature=TEMPERATURE,
max_tokens=MAX_TOKENS,
model=model
#,model_kwargs={'azure_openai_api_key': api_key}
)
# Attempt to send a chat message
client.chat("Hi")
这会导致以下错误:
AttributeError: 'AzureOpenAI' object has no attribute 'chat'
当我用client.invoke("Hi")
替换client.chat("Hi")
时,我会得到一个不同的错误:
BadRequestError: Error code: 400 - {'error': {'code': 'OperationNotSupported', 'message': 'The completion operation does not work with the specified model, gpt-4. Please choose different model and try again. You can learn more about which models can be used with each operation here: https://go.microsoft.com/fwlink/?linkid=2197993.'}}
如何解决这些错误?
对于这些错误以及如何解决它们的任何指导或见解,我们将不胜感激!