Download coonection.py from abdullah9873/js-engineer-chatbot: direct link, hf CLI and curl.
- Browser
- Download file 663 Bytes
-
https://huggingface.co/spaces/abdullah9873/js-engineer-chatbot/resolve/main/coonection.py
- Command line
-
hf download hf://spaces/abdullah9873/js-engineer-chatbot/coonection.py
-
curl -L -o coonection.py https://huggingface.co/spaces/abdullah9873/js-engineer-chatbot/resolve/main/coonection.py
663 Bytes
| from dotenv import load_dotenv | |
| import os | |
| from agents import AsyncOpenAI, ModelSettings, OpenAIChatCompletionsModel, RunConfig | |
| load_dotenv() | |
| # Load OpenAI API key | |
| openai_api_key = os.getenv("OPENAI_API_KEY") | |
| if not openai_api_key: | |
| raise ValueError("OPENAI_API_KEY is not set. Please add it to your .env file.") | |
| # Create OpenAI client (NO base_url needed) | |
| openai_client = AsyncOpenAI( | |
| api_key=openai_api_key | |
| ) | |
| # Choose OpenAI model | |
| model = OpenAIChatCompletionsModel( | |
| model="gpt-4o-mini", | |
| openai_client=openai_client, | |
| ) | |
| # Run configuration | |
| config = RunConfig( | |
| model=model, | |
| model_provider=openai_client | |
| ) | |