Skip to content

Commit

Permalink
explictly get api key
Browse files Browse the repository at this point in the history
  • Loading branch information
areibman committed Dec 23, 2024
1 parent a3d9f6d commit 251d0dd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/openai_handlers/test_openai_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncio
from openai import OpenAI, AsyncOpenAI
from dotenv import load_dotenv
import os

load_dotenv()

Expand All @@ -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"}],
Expand All @@ -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"}],
Expand Down

0 comments on commit 251d0dd

Please sign in to comment.