Skip to content

Commit 6b54d1e

Browse files
committed
fix tests
1 parent 0e8b77d commit 6b54d1e

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

tests/test_datasets.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import json
2-
import os
32
import time
43
from concurrent.futures import ThreadPoolExecutor
54
from typing import Sequence
65

7-
from langchain import OpenAI, PromptTemplate
6+
from langchain import PromptTemplate
7+
from langchain_openai import OpenAI
88

99
from langfuse import Langfuse, observe
1010
from langfuse.api.resources.commons.types.dataset_status import DatasetStatus
@@ -253,7 +253,7 @@ def test_langchain_dataset():
253253
dataset_item_id = item.id
254254
final_trace_id = span.trace_id
255255

256-
llm = OpenAI(openai_api_key=os.environ.get("OPENAI_API_KEY"))
256+
llm = OpenAI()
257257
template = """You are a playwright. Given the title of play, it is your job to write a synopsis for that title.
258258
Title: {title}
259259
Playwright: This is a synopsis for the above play:"""
@@ -284,6 +284,11 @@ def test_langchain_dataset():
284284
def sorted_dependencies_from_trace(trace):
285285
parent_to_observation = {}
286286
for obs in trace.observations:
287+
# Filter out the generation that might leak in due to the monkey patching OpenAI integration
288+
# that might have run in the previous test suite. TODO: fix this hack
289+
if obs.name == "OpenAI-generation":
290+
continue
291+
287292
parent_to_observation[obs.parent_observation_id] = obs
288293

289294
# Start with the root observation (parent_observation_id is None)

0 commit comments

Comments
 (0)