Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support Azure OpenAI API #88

Merged
merged 4 commits into from
Jul 18, 2023
Merged

support Azure OpenAI API #88

merged 4 commits into from
Jul 18, 2023

Conversation

caiqinghua
Copy link
Contributor

No description provided.

@caiqinghua
Copy link
Contributor Author

Test result:

2023-07-17 20:26:27,543 - init - whisper.py - INFO - Loading [Local Whisper] model: [tiny]...
INFO: Started server process [45585]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
INFO: 127.0.0.1:50600 - "GET / HTTP/1.1" 200 OK
INFO: ('127.0.0.1', 50608) - "WebSocket /ws/432017" [accepted]
INFO: connection open
2023-07-17 20:26:35,625 - handle_receive - websocket_routes.py - INFO - Client #432017:web connected to server
INFO: 127.0.0.1:50612 - "GET /bruce.png HTTP/1.1" 304 Not Modified
INFO: 127.0.0.1:50601 - "GET /loki.svg HTTP/1.1" 304 Not Modified
INFO: 127.0.0.1:50600 - "GET /elon.png HTTP/1.1" 304 Not Modified
INFO: 127.0.0.1:50614 - "GET /jobs.png HTTP/1.1" 304 Not Modified
INFO: 127.0.0.1:50611 - "GET /raiden.svg HTTP/1.1" 304 Not Modified
2023-07-17 20:26:53,983 - handle_receive - websocket_routes.py - INFO - Client #432017 selected character: Steve Jobs
2023-07-17 20:27:39,938 - _generate_context - openai_llm.py - INFO - Found 4 documents
Jobs> I created Apple to make a dent in the universe. We wanted to create products that would change people's lives and make a difference in the world.2023-07-17 20:27:48,148 - achat - openai_llm.py - INFO - Response: generations=[[ChatGeneration(text="Jobs> I created Apple to make a dent in the universe. We wanted to create products that would change people's lives and make a difference in the world.", generation_info=None, message=AIMessage(content="Jobs> I created Apple to make a dent in the universe. We wanted to create products that would change people's lives and make a difference in the world.", additional_kwargs={}, example=False))]] llm_output={'token_usage': {}, 'model_name': 'gpt-35-turbo'} run=[RunInfo(run_id=UUID('453fe6c4-52b4-448e-80a6-c7cd6f0cb1b6'))]
2023-07-17 20:52:05,135 - handle_receive - websocket_routes.py - INFO - Client #432017 closed the connection

@Shaunwei Shaunwei self-requested a review July 18, 2023 07:01
@Shaunwei
Copy link
Owner

Thanks for adding Azure OpenAI API support. I am checking it

@@ -8,7 +8,8 @@
logger = get_logger(__name__)

embedding = OpenAIEmbeddings(openai_api_key=os.getenv("OPENAI_API_KEY"))

if os.getenv('OPENAI_API_TYPE') == 'azure':
embedding = OpenAIEmbeddings(openai_api_key=os.getenv("OPENAI_API_KEY"), deployment="text-embedding-ada-002", chunk_size=1)
Copy link
Collaborator

@pycui pycui Jul 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you keep the params same? Or is there a reason to change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chunk_size = 1 for fixing the problem: openai.error.InvalidRequestError: Too many inputs. The max number of inputs is 1.
Deployment parameter for Azure deploy a different model name.
We can change the deployment name to .env

Copy link
Collaborator

@pycui pycui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! We haven't got access to AzureOpenAI (yet) so cannot test it unfortunately, but the code and your log look right. Please merge main and I will merge this.

@pycui pycui merged commit 83d8284 into Shaunwei:main Jul 18, 2023
@Kevin-free
Copy link
Contributor

@caiqinghua Hey, I have created the Key in Azure, and the settings are correct, but the execution error:

openai.error.InvalidRequestError: The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again.

How to check and solve this?

Is it because OPENAI_API_EMBEDDING_DEPLOYMENT_NAME is not set? But I don't find this in Azure

image
image

@caiqinghua
Copy link
Contributor Author

Have you deployed text-embedding-ada-002 model?

image

@caiqinghua Hey, I have created the Key in Azure, and the settings are correct, but the execution error:

openai.error.InvalidRequestError: The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again.

How to check and solve this?

Is it because OPENAI_API_EMBEDDING_DEPLOYMENT_NAME is not set? But I don't find this in Azure

image image

@Kevin-free
Copy link
Contributor

Have you deployed text-embedding-ada-002 model?

image > @caiqinghua Hey, I have created the Key in Azure, and the settings are correct, but the execution error: > ```shell > openai.error.InvalidRequestError: The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again. > ``` > > > > > > > > > > > > How to check and solve this? > Is it because OPENAI_API_EMBEDDING_DEPLOYMENT_NAME is not set? But I don't find this in Azure > ![image](https://user-images.githubusercontent.com/26422757/256970965-3bded176-84a8-494d-806c-67278be6bcfe.png) ![image](https://user-images.githubusercontent.com/26422757/256970974-4a57da50-fe3d-486b-a2c2-6d7c47ec6a94.png)

Thanks! I solved it

Have you deployed text-embedding-ada-002 model?

image > @caiqinghua Hey, I have created the Key in Azure, and the settings are correct, but the execution error: > ```shell > openai.error.InvalidRequestError: The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again. > ``` > > > > > > > > > > > > How to check and solve this? > Is it because OPENAI_API_EMBEDDING_DEPLOYMENT_NAME is not set? But I don't find this in Azure > ![image](https://user-images.githubusercontent.com/26422757/256970965-3bded176-84a8-494d-806c-67278be6bcfe.png) ![image](https://user-images.githubusercontent.com/26422757/256970974-4a57da50-fe3d-486b-a2c2-6d7c47ec6a94.png)

Thanks! i solved it

yaohaizhou pushed a commit to yaohaizhou/RealChar that referenced this pull request Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants