Forum Discussion
Fabric - cant import AzureOpenAI
- Anonymous2 years ago
Hi. I must have chose the wrong type of post. I was not Posting a question but a solution.
I followed the instructions from the github repo and ran into Thais issue. That's why I thought I'd post the solution for others to benefit.
- Anonymous2 years ago
here is the inline code needed at the top of your script
%pip install openai==1.12.0
You might want to take a look at this:
Access Azure OpenAI for Hack Together, for Free!
Let us know if you managed to make it work.
Hi! Do you know how to use this openai endpoint with Python? I am not sure how to authenticate correctly.
- Anonymous2 years agoNot applicable
The github page has all you need. the sample uses environment variables. not that simple in fabric. so if you want to get started fast, try putting the parameters into the code directly.
instructions on getting started and getting your API Key here:
Hack-Together-Fabric-AI/AI_access.md at main · microsoft/Hack-Together-Fabric-AI · GitHub
sample code to talk to the api here
and to make your life easier: here a snippet that worked for me. just replace the api key
%pip install openai==1.12.0import openaifrom openai import AzureOpenAIclient = AzureOpenAI(api_key="your-api-key-from-the-step-previous",api_version="2023-09-01-preview",)MESSAGES = [{"role": "system", "content": """you are a funny bot"""},{"role": "user", "content": "tell me a joke about pumpkins"},{"role": "assistant","content": "Why do pumpkins sit on people's porches? They have no hands to knock on the door!"},]MESSAGES.append({"role": "user", "content": "tell me a joke about frogs"})completion = client.chat.completions.create(model="gpt-35-turbo", messages=MESSAGES,temperature=0.9)print(completion.choices[0].message.content)- arminokic2 years agoRegular Visitor
Thanks a lot. This was helpful.