https://github.com/benderscript/azure_ai_chat_completions
Azure AI Chat Completions Example
https://github.com/benderscript/azure_ai_chat_completions
ai azure chat completions gpt-4 gpt4 openai openai-a
Last synced: 2 months ago
JSON representation
Azure AI Chat Completions Example
- Host: GitHub
- URL: https://github.com/benderscript/azure_ai_chat_completions
- Owner: BenderScript
- License: mit
- Created: 2023-10-17T23:27:54.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-20T08:21:42.000Z (11 months ago)
- Last Synced: 2025-02-07T16:28:42.703Z (8 months ago)
- Topics: ai, azure, chat, completions, gpt-4, gpt4, openai, openai-a
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Minimalistic Azure AI Chat Completion
Three versions are provided:
- Basic Chat Coompletions
- Chat Completions with Structured Output using OpenAI SDK
- Chat Completions with Structured Output using Lancgchain## Overview
This is a simple Python application that uses the Azure OpenAI AI API to generate chat completions.
## Prerequisites
- Python 3.11 or higher
## Setup
1. Clone the repository.
2. Install the required Python libraries using pip:```bash
pip3 install -r requirements.txt
```3. Create a `.env` file in the root directory of the project and add your Azure AI API credentials and settings:
```bash
AZURE_OPENAI_API_KEY=your-key
AZURE_OPENAI_ENDPOINT=your URL endpoint
AZURE_OPENAI_API_VERSION=
AZURE_OPENAI_DEPLOYMENT=
```## Usage
Run the script using Python:
```bash
python main.py
```The script will load the settings from the `.env` file, make a chat completion request to the Azure OpenAI deployment you specified
If you are working with pure REST the full URL will look like:
```bash
url = openai_api_base + "openai/deployments/" + deployment_name + "/chat/completions?api-version=" + openai_api_version
```## Customization
You can customize the script by modifying the `messages` dictionary.
## Troubleshooting
If you encounter any errors, check the printed error message and status code for clues about what went wrong. Common issues include incorrect API credentials in the `.env` file and network connectivity problems.
## Contributing
Contributions are welcome! Please read our contributing guidelines before submitting a pull request.