Spaces:
Paused
Paused
Download example-DIAL.py from DreamyDetective/agentic-rag: direct link, hf CLI and curl.
- Browser
- Download file 662 Bytes
-
https://huggingface.co/spaces/DreamyDetective/agentic-rag/resolve/main/example-DIAL.py
- Command line
-
hf download hf://spaces/DreamyDetective/agentic-rag/example-DIAL.py
-
curl -L -o example-DIAL.py https://huggingface.co/spaces/DreamyDetective/agentic-rag/resolve/main/example-DIAL.py
662 Bytes
| import os | |
| from dotenv import load_dotenv | |
| from openai import AzureOpenAI | |
| # Load environment variables from .env file | |
| load_dotenv() | |
| # Initialize the client | |
| client = AzureOpenAI( | |
| api_key=os.getenv("AZURE_OPENAI_API_KEY"), | |
| api_version=os.getenv("AZURE_OPENAI_API_VERSION"), | |
| azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT") | |
| ) | |
| # Example Chat Completion Call | |
| response = client.chat.completions.create( | |
| model=os.getenv("AZURE_OPENAI_DEPLOYMENT"), # e.g., "gpt-5.4" | |
| messages=[ | |
| {"role": "system", "content": "You are a helpful assistant."}, | |
| {"role": "user", "content": "Hello!"} | |
| ] | |
| ) | |
| print(response.choices[0].message.content) | |