Closed BeanHsiang closed 3 months ago
You may need to define an assistant. https://platform.openai.com/docs/assistants/overview?lang=python&context=with-streaming
I am also unable to use AzureOpenAI client and the EventHandler. It runs using 1.17.0 but nothing prints.
So am I. I suspect an issue with Azure OpenAI API version, not including the necessary structures to use the new stream feature on assistant from OpenAI. EventHandler() has no impact.
Streaming works using AsyncAzureOpenAI(api_version="2024-04-01-preview")
This issue is for a: (mark with an
x
)Minimal steps to reproduce
load_dotenv()
api_key = os.environ.get("AZURE_OPENAI_API_KEY") api_version = os.environ.get("OPENAI_API_VERSION") azure_endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT") assistant_id = os.environ.get("AZURE_OPENAI_ENDPOINT")
class EventHandler(AssistantEventHandler): @override def on_text_created(self, text) -> None: print(f"\nassistant > ", end="", flush=True)
client = AzureOpenAI(api_key=api_key, api_version=api_version, azure_endpoint=azure_endpoint)
thread = client.beta.threads.create( messages=[] )
client.beta.threads.messages.create( thread_id=thread.id, role="user", content="here are some messages..." )
with client.beta.threads.runs.stream( thread_id=thread.id, assistant_id=assistant_id, event_handler=EventHandler() ) as stream: stream.until_done()
Expected/desired behavior
OS and Version?
Versions
Mention any other details that might be useful