|
| 1 | +import math |
1 | 2 | import os |
2 | 3 | import time |
3 | | -import math |
4 | 4 | import uuid |
5 | 5 | from unittest.mock import patch |
6 | 6 |
|
| 7 | +import pytest |
7 | 8 | from langchain_community.chat_models.fake import FakeMessagesListChatModel |
8 | 9 | from langchain_community.llms.fake import FakeListLLM, FakeStreamingListLLM |
9 | 10 | from langchain_core.messages import AIMessage |
10 | 11 | from langchain_core.prompts import ChatPromptTemplate |
11 | 12 | from langchain_core.runnables import RunnableLambda |
12 | 13 | from langchain_openai.chat_models import ChatOpenAI |
13 | | -import pytest |
14 | 14 |
|
15 | 15 | from posthog.ai.langchain import PosthogCallbackHandler |
16 | 16 |
|
17 | | - |
18 | 17 | OPENAI_API_KEY = os.getenv("OPENAI_API_KEY") |
19 | 18 |
|
20 | 19 |
|
@@ -497,7 +496,6 @@ def test_openai_streaming(mock_client): |
497 | 496 | api_key=OPENAI_API_KEY, model="gpt-4o-mini", temperature=0, max_tokens=1, stream=True, stream_usage=True |
498 | 497 | ) |
499 | 498 | callbacks = PosthogCallbackHandler(mock_client) |
500 | | - start_time = time.time() |
501 | 499 | result = [m for m in chain.stream({}, config={"callbacks": [callbacks]})] |
502 | 500 | result = sum(result[1:], result[0]) |
503 | 501 |
|
@@ -530,7 +528,6 @@ async def test_async_openai_streaming(mock_client): |
530 | 528 | api_key=OPENAI_API_KEY, model="gpt-4o-mini", temperature=0, max_tokens=1, stream=True, stream_usage=True |
531 | 529 | ) |
532 | 530 | callbacks = PosthogCallbackHandler(mock_client) |
533 | | - start_time = time.time() |
534 | 531 | result = [m async for m in chain.astream({}, config={"callbacks": [callbacks]})] |
535 | 532 | result = sum(result[1:], result[0]) |
536 | 533 |
|
|
0 commit comments