File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616import os
1717
1818import pytest
19+ import tiktoken
1920from langchain_core .messages .ai import AIMessage
2021from langchain_core .messages .tool import ToolMessage
2122from langchain_openai import ChatOpenAI , OpenAIEmbeddings
7677 ]
7778)
7879
80+ TIKTOKEN_ENCODINGS = ["cl100k_base" ]
81+
7982
8083# Intercept outgoing requests and log to file for mocking
8184EXPECTED_AGENT_RESPONSE = "Hello!"
@@ -108,6 +111,13 @@ def embedding_openai_client(openai_clients):
108111 return embedding_client
109112
110113
114+ @pytest .fixture (scope = "session" )
115+ def load_tiktoken_encodings ():
116+ """Load tiktoken encodings before tests run to avoid issues with VCR blocking the network."""
117+ for encoding in TIKTOKEN_ENCODINGS :
118+ tiktoken .get_encoding (encoding )
119+
120+
111121@pytest .fixture
112122def chat_openai_client (openai_clients ):
113123 chat_client , _ = openai_clients
You can’t perform that action at this time.
0 commit comments