From 251d0dd0ff4668ed8d59c19e05fbed59a9617319 Mon Sep 17 00:00:00 2001 From: reibs Date: Sun, 22 Dec 2024 17:00:05 -0800 Subject: [PATCH] explictly get api key --- tests/openai_handlers/test_openai_integration.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/openai_handlers/test_openai_integration.py b/tests/openai_handlers/test_openai_integration.py index 9661c512..2d749319 100644 --- a/tests/openai_handlers/test_openai_integration.py +++ b/tests/openai_handlers/test_openai_integration.py @@ -3,6 +3,7 @@ import asyncio from openai import OpenAI, AsyncOpenAI from dotenv import load_dotenv +import os load_dotenv() @@ -22,14 +23,14 @@ def test_openai_integration(): session = agentops.start_session() def sync_no_stream(): - client = OpenAI() + client = OpenAI(api_key=os.getenv("OPENAI_API_KEY")) client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": "Hello from sync no stream"}], ) def sync_stream(): - client = OpenAI() + client = OpenAI(api_key=os.getenv("OPENAI_API_KEY")) stream_result = client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": "Hello from sync streaming"}], @@ -39,14 +40,14 @@ def sync_stream(): pass async def async_no_stream(): - client = AsyncOpenAI() + client = AsyncOpenAI(api_key=os.getenv("OPENAI_API_KEY")) await client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": "Hello from async no stream"}], ) async def async_stream(): - client = AsyncOpenAI() + client = AsyncOpenAI(api_key=os.getenv("OPENAI_API_KEY")) async_stream_result = await client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": "Hello from async streaming"}],