This project provides a simple command-line interface (CLI) to interact with the Azure OpenAI service using Python. By typing ag
in the terminal, users can start a chat session with the GPT model deployed on Azure.
- Python 3.x
- Virtual environment tool (such as
venv
) - Azure OpenAI API key and deployment name
-
Clone the repository:
git clone git@github.com:jonlai211/Azure-OpenAI-Agent-CLI.git cd Azure-OpenAI-Agent-CLI/
-
Create and activate a virtual environment:
python3 -m venv .venv source .venv/bin/activate
-
Install the required packages:
pip install requests
-
Modify the
ag
Bash script:echo '#!/bin/bash source "Your_Path/Azure OpenAI Agent/.venv/bin/activate" python "Your_Path/Azure OpenAI Agent/agent.py"' > ag.bash chmod +x ag.bash sudo cp ag.bash /usr/local/bin/ag
To start a chat session with the GPT model, simply type ag
in your terminal and press Enter. Type your questions or commands, and the GPT model will respond. To exit the chat session, type exit
or quit
.
Before running the script, you need to configure your Azure OpenAI endpoint and API key in the agent.py
file:
endpoint = "https://YOUR_DEPLOYMENT_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/chat/completions?api-version=2024-02-15-preview"
api_key = "YOUR_API_KEY"
Replace YOUR_DEPLOYMENT_NAME
and YOUR_API_KEY
with your actual deployment name and API key from Azure.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.