A script to call the Azure OpenAI API and ask a question, returning the answer.
ask_gpt.sh is a Bash script that interacts with the Azure OpenAI API to ask a question and retrieve the corresponding answer. It simplifies the process of making API calls and handling the JSON response.
./ask_gpt.sh "What is the meaning of life?"Replace "What is the meaning of life?" with your desired question.
- The
jqcommand line tool must be installed. - The following environment variables must be set:
AZURE_OPENAI_API_KEY: Azure OpenAI API key.AZURE_OPENAI_ENDPOINT: Azure OpenAI endpoint.OPENAI_API_VERSION: Azure OpenAI API version.CHAT_DEPLOYMENT: Azure OpenAI deployment name.
-
Clone the repository:
git clone <repository_url>
-
Change into the repository directory:
cd ask-gpt -
Make the script executable:
chmod +x ask_gpt.sh
Run the script with your desired question as an argument:
./ask_gpt.sh "What is the meaning of life?"The script sends a request to the Azure OpenAI API, passing the question as a user message. It then retrieves the answer from the API response and displays it in the console.
This project is licensed under the MIT License.