最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

openai api - Using client.beta.chat.completions.parse with AzureChatOpenAI client - Stack Overflow

programmeradmin1浏览0评论

I am trying to run this code:

from pydantic import BaseModel
from openai import OpenAI

client = OpenAI()

class CalendarEvent(BaseModel):
    name: str
    date: str
    participants: list[str]

completion = client.beta.chatpletions.parse(
    model="gpt-4o-2024-08-06",
    messages=[
        {"role": "system", "content": "Extract the event information."},
        {"role": "user", "content": "Alice and Bob are going to a science fair on Friday."},
    ],
    response_format=CalendarEvent,
)

event = completion.choices[0].message.parsed

From OpenAI webpage, using AzureChatOpenAI client

from langchain_openai import AzureChatOpenAI

client = AzureChatOpenAI(
    azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
    openai_api_version="2024-06-01",
    model=MODEL_NAME,
    openai_api_key=os.environ["AZURE_OPENAI_API_KEY"],
    temperature=0.0,
)

However, I am encountering this error:

'AzureChatOpenAI' object has no attribute 'beta'

Any solution on this?

发布评论

评论列表(0)

  1. 暂无评论