Skip to content
This repository was archived by the owner on Dec 11, 2025. It is now read-only.

Commit 7b40d21

Browse files
committed
chore: added new fixture for gpt-4.5 so it will return tool_calls
1 parent 11edade commit 7b40d21

17 files changed

Lines changed: 4033 additions & 2441 deletions

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ repos:
2424
hooks:
2525
- id: flake8
2626
args: [--max-line-length=130]
27-
exclude: ^(cookbooks|docs)
27+
exclude: ^(cookbooks|docs|tests/conftest.py)

notdiamond/settings.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@
6363
"gpt-4-turbo-preview",
6464
"gpt-4-0125-preview",
6565
"gpt-4-1106-preview",
66-
# Need to update langchain-openai to >=0.3.9 to support these
67-
# "gpt-4.5-preview",
68-
# "gpt-4.5-preview-2025-02-27"
66+
"gpt-4.5-preview",
67+
"gpt-4.5-preview-2025-02-27",
6968
],
7069
"support_response_model": [
7170
"gpt-3.5-turbo",

poetry.lock

Lines changed: 635 additions & 107 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ cryptography = ">=44.0.1"
1818
tiktoken = ">=0.8.0,<0.9.0"
1919
langchain = { version = ">=0.3.22", optional = true }
2020
langchain-google-genai = { version = ">=2.1.2", optional = true }
21-
langchain-openai = { version = ">=0.3.5", optional = true }
21+
langchain-openai = { version = ">=0.3.9", optional = true }
2222
langchain-anthropic = { version = ">=0.3.10", optional = true }
2323
langchain-community = { version = ">=0.3.20", optional = true }
2424
langchain-mistralai = { version = ">=0.2.10", optional = true }
@@ -33,13 +33,12 @@ unstructured = { extras = [
3333
onnxruntime = { version = "<1.20", optional = true }
3434
python-multipart = { version = "0.0.18", extras = ["rag"] }
3535
llama-index = { version = "^0.12.25", optional = true }
36-
r2r = ">=3.5.9"
3736

3837
[tool.poetry.group.test.dependencies]
3938
pytest = "^8.0.0"
4039
pytest-asyncio = "^0.23.6"
4140
pytest-mock = "^3.14.0"
42-
openai = ">=1.60.0"
41+
openai = ">=1.66.3"
4342
coverage = "^7.6.0"
4443
pytest-recording = "^0.13.2"
4544
pytest-timeout = "^2.3.1"

tests/conftest.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,23 @@ def openai_tools_fixture():
9595
return [add_tool]
9696

9797

98+
@pytest.fixture
99+
def get_stock_price_tool_fixture():
100+
"""Fixture that creates a tool for getting stock prices."""
101+
stock_tool = {
102+
"name": "get_stock_price",
103+
"description": "Get current stock price for a provided ticker symbol from Yahoo Finance using the yahooquery Python library.",
104+
"parameters": {
105+
"type": "object",
106+
"properties": {"ticker": {"type": "string"}},
107+
"required": ["ticker"],
108+
"additionalProperties": False,
109+
},
110+
}
111+
112+
return [stock_tool]
113+
114+
98115
@pytest.fixture
99116
def response_model():
100117
class Joke(BaseModel):

tests/test_llm_calls/cassettes/test_openai/Test_OpenAI.test_streaming[provider0].yaml

Lines changed: 1002 additions & 32 deletions
Large diffs are not rendered by default.

tests/test_llm_calls/cassettes/test_openai/Test_OpenAI.test_streaming[provider1].yaml

Lines changed: 595 additions & 522 deletions
Large diffs are not rendered by default.

tests/test_llm_calls/cassettes/test_openai/Test_OpenAI.test_streaming[provider2].yaml

Lines changed: 419 additions & 1160 deletions
Large diffs are not rendered by default.

tests/test_llm_calls/cassettes/test_openai/Test_OpenAI.test_streaming[provider3].yaml

Lines changed: 5 additions & 581 deletions
Large diffs are not rendered by default.
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
interactions:
2+
- request:
3+
body: '{"messages": [{"role": "user", "content": "How much is 3 + 5?"}], "llm_providers":
4+
[{"provider": "openai", "model": "gpt-4.5-preview", "is_custom": false, "context_length":
5+
null, "input_price": null, "output_price": null, "latency": null}], "metric":
6+
"accuracy", "max_model_depth": 1, "hash_content": false, "tools": [{"type":
7+
"function", "function": {"name": "add_fct", "description": "Add two numbers",
8+
"parameters": {"type": "object", "properties": {"a": {"type": "integer", "description":
9+
"The first number"}, "b": {"type": "integer", "description": "The second number"}},
10+
"required": ["a", "b"]}}}]}'
11+
headers:
12+
Accept:
13+
- '*/*'
14+
Accept-Encoding:
15+
- gzip, deflate, zstd
16+
Connection:
17+
- keep-alive
18+
Content-Length:
19+
- '604'
20+
User-Agent:
21+
- Python-SDK/0.4.2
22+
content-type:
23+
- application/json
24+
method: POST
25+
uri: https://staging-api.notdiamond.ai/v2/modelRouter/modelSelect
26+
response:
27+
body:
28+
string: '{"providers":[{"provider":"openai","model":"gpt-4.5-preview"}],"session_id":"5fb8445b-ff9e-4b57-9acd-2d9d0c6f6b3e"}'
29+
headers:
30+
CF-RAY:
31+
- 92a11e0a989d0d4f-SOF
32+
Connection:
33+
- keep-alive
34+
Content-Type:
35+
- application/json
36+
Date:
37+
- Wed, 02 Apr 2025 14:46:44 GMT
38+
Server:
39+
- cloudflare
40+
Transfer-Encoding:
41+
- chunked
42+
alt-svc:
43+
- h3=":443"; ma=86400
44+
cf-cache-status:
45+
- DYNAMIC
46+
content-length:
47+
- '115'
48+
rndr-id:
49+
- 4dd7a88f-b631-4f4b
50+
vary:
51+
- Accept-Encoding
52+
x-render-origin-server:
53+
- uvicorn
54+
status:
55+
code: 200
56+
message: OK
57+
- request:
58+
body: '{"messages": [{"content": "How much is 3 + 5?", "role": "user"}], "model":
59+
"gpt-4.5-preview", "max_completion_tokens": 200, "stream": false, "tools": [{"type":
60+
"function", "function": {"name": "add_fct", "description": "Add two numbers",
61+
"parameters": {"type": "object", "properties": {"a": {"type": "integer", "description":
62+
"The first number"}, "b": {"type": "integer", "description": "The second number"}},
63+
"required": ["a", "b"]}}}]}'
64+
headers:
65+
accept:
66+
- application/json
67+
accept-encoding:
68+
- gzip, deflate, zstd
69+
connection:
70+
- keep-alive
71+
content-length:
72+
- '437'
73+
content-type:
74+
- application/json
75+
host:
76+
- api.openai.com
77+
user-agent:
78+
- OpenAI/Python 1.70.0
79+
x-stainless-arch:
80+
- x64
81+
x-stainless-async:
82+
- 'false'
83+
x-stainless-lang:
84+
- python
85+
x-stainless-os:
86+
- Linux
87+
x-stainless-package-version:
88+
- 1.70.0
89+
x-stainless-read-timeout:
90+
- '120.0'
91+
x-stainless-retry-count:
92+
- '0'
93+
x-stainless-runtime:
94+
- CPython
95+
x-stainless-runtime-version:
96+
- 3.12.3
97+
method: POST
98+
uri: https://api.openai.com/v1/chat/completions
99+
response:
100+
body:
101+
string: "{\n \"id\": \"chatcmpl-BHteWM3dNbq2UiM7cbMF7yccELYnx\",\n \"object\":
102+
\"chat.completion\",\n \"created\": 1743605204,\n \"model\": \"gpt-4.5-preview-2025-02-27\",\n
103+
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
104+
\"assistant\",\n \"content\": \"\\\\(3 + 5 = 8\\\\)\",\n \"refusal\":
105+
null,\n \"annotations\": []\n },\n \"finish_reason\": \"stop\"\n
106+
\ }\n ],\n \"usage\": {\n \"prompt_tokens\": 64,\n \"completion_tokens\":
107+
12,\n \"total_tokens\": 76,\n \"prompt_tokens_details\": {\n \"cached_tokens\":
108+
0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\":
109+
{\n \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
110+
0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\":
111+
\"default\",\n \"system_fingerprint\": null\n}\n"
112+
headers:
113+
CF-RAY:
114+
- 92a11e0f8af4b5c8-SOF
115+
Connection:
116+
- keep-alive
117+
Content-Type:
118+
- application/json
119+
Date:
120+
- Wed, 02 Apr 2025 14:46:47 GMT
121+
Server:
122+
- cloudflare
123+
Set-Cookie:
124+
- __cf_bm=e1hGRQbVfWbQAUfTWkiHBV58D0JiA7DvneWayu7cK1Y-1743605207-1.0.1.1-dMrwzvpkaZ6UqRANnwL7kyZnUeKBubze87lVISrsLjGbzTEtpCNIDloWXY6wgW_RWuhTNRY7fBruJQd05I3hrHRFrAGjhP3gPySqcE7a0Rg;
125+
path=/; expires=Wed, 02-Apr-25 15:16:47 GMT; domain=.api.openai.com; HttpOnly;
126+
Secure; SameSite=None
127+
- _cfuvid=S2kCgoIa_ZQAJnOXZoUBZQM.o1yCue0O1RtcICIMHQM-1743605207502-0.0.1.1-604800000;
128+
path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None
129+
Transfer-Encoding:
130+
- chunked
131+
X-Content-Type-Options:
132+
- nosniff
133+
access-control-expose-headers:
134+
- X-Request-ID
135+
alt-svc:
136+
- h3=":443"; ma=86400
137+
cf-cache-status:
138+
- DYNAMIC
139+
content-length:
140+
- '791'
141+
openai-organization:
142+
- not-diamond-bdz8cg
143+
openai-processing-ms:
144+
- '2915'
145+
openai-version:
146+
- '2020-10-01'
147+
strict-transport-security:
148+
- max-age=31536000; includeSubDomains; preload
149+
x-ratelimit-limit-requests:
150+
- '10000'
151+
x-ratelimit-limit-tokens:
152+
- '2000000'
153+
x-ratelimit-remaining-requests:
154+
- '9999'
155+
x-ratelimit-remaining-tokens:
156+
- '1999993'
157+
x-ratelimit-reset-requests:
158+
- 6ms
159+
x-ratelimit-reset-tokens:
160+
- 0s
161+
x-request-id:
162+
- req_6bbe0297b07f4fef026163d118c45ab7
163+
status:
164+
code: 200
165+
message: OK
166+
- request:
167+
body: '{"session_id": "5fb8445b-ff9e-4b57-9acd-2d9d0c6f6b3e", "provider": {"provider":
168+
"openai", "model": "gpt-4.5-preview", "is_custom": false, "context_length":
169+
null, "input_price": null, "output_price": null, "latency": null}, "feedback":
170+
{"tokens_per_second": 0.9338486470343585}}'
171+
headers:
172+
Accept:
173+
- '*/*'
174+
Accept-Encoding:
175+
- gzip, deflate, zstd
176+
Connection:
177+
- keep-alive
178+
Content-Length:
179+
- '277'
180+
User-Agent:
181+
- Python-SDK/0.4.2
182+
content-type:
183+
- application/json
184+
method: POST
185+
uri: https://staging-api.notdiamond.ai/v2/report/metrics/latency
186+
response:
187+
body:
188+
string: '{"detail":"requestID=d8be5161-40e4-401d, Session 5fb8445b-ff9e-4b57-9acd-2d9d0c6f6b3e
189+
does not belong to user d6b6f4db-9cd9-4a33-b885-506685cd2d34."}'
190+
headers:
191+
CF-RAY:
192+
- 92a11e239c7c5b6d-VIE
193+
Connection:
194+
- keep-alive
195+
Content-Type:
196+
- application/json
197+
Date:
198+
- Wed, 02 Apr 2025 14:46:47 GMT
199+
Server:
200+
- cloudflare
201+
Transfer-Encoding:
202+
- chunked
203+
alt-svc:
204+
- h3=":443"; ma=86400
205+
cf-cache-status:
206+
- DYNAMIC
207+
rndr-id:
208+
- d8be5161-40e4-401d
209+
vary:
210+
- Accept-Encoding
211+
x-render-origin-server:
212+
- uvicorn
213+
status:
214+
code: 401
215+
message: Unauthorized
216+
version: 1

0 commit comments

Comments
 (0)