Reconfigure test env
This commit is contained in:
@@ -4,12 +4,12 @@ class Provider::OpenaiTest < ActiveSupport::TestCase
|
||||
include LLMInterfaceTest
|
||||
|
||||
setup do
|
||||
@subject = @openai = Provider::Openai.new(ENV.fetch("OPENAI_ACCESS_TOKEN"))
|
||||
@subject = @openai = Provider::Openai.new(ENV.fetch("OPENAI_ACCESS_TOKEN", "test-openai-token"))
|
||||
@subject_model = "gpt-4o"
|
||||
end
|
||||
|
||||
test "openai errors are automatically raised" do
|
||||
VCR.use_cassette("open_ai/chat/error") do
|
||||
VCR.use_cassette("openai/chat/error") do
|
||||
response = @openai.chat_response(
|
||||
model: "invalid-model-key",
|
||||
chat_history: [ UserMessage.new(content: "Error test") ]
|
||||
@@ -24,7 +24,7 @@ class Provider::OpenaiTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test "handles chat response with tool calls" do
|
||||
VCR.use_cassette("open_ai/chat/tool_calls") do
|
||||
VCR.use_cassette("openai/chat/tool_calls") do
|
||||
class PredictableToolFunction
|
||||
include Assistant::Functions::Toolable
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ end
|
||||
require_relative "../config/environment"
|
||||
|
||||
ENV["RAILS_ENV"] ||= "test"
|
||||
ENV["OPENAI_ACCESS_TOKEN"] ||= "test_openai_token"
|
||||
|
||||
# Fixes Segfaults on M1 Macs when running tests in parallel (temporary workaround)
|
||||
# https://github.com/ged/ruby-pg/issues/538#issuecomment-1591629049
|
||||
|
||||
@@ -24,7 +24,7 @@ http_interactions:
|
||||
message: OK
|
||||
headers:
|
||||
Date:
|
||||
- Mon, 24 Mar 2025 11:56:08 GMT
|
||||
- Mon, 24 Mar 2025 21:44:00 GMT
|
||||
Content-Type:
|
||||
- application/json
|
||||
Transfer-Encoding:
|
||||
@@ -36,34 +36,34 @@ http_interactions:
|
||||
Openai-Organization:
|
||||
- "<OPENAI_ORGANIZATION_ID>"
|
||||
X-Request-Id:
|
||||
- req_c5fb43ea5be1cf9d0510fd78349cb4d7
|
||||
- req_ed8464cb4c786474752f78361683811f
|
||||
Openai-Processing-Ms:
|
||||
- '649'
|
||||
- '676'
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Cf-Cache-Status:
|
||||
- DYNAMIC
|
||||
Set-Cookie:
|
||||
- __cf_bm=RagOVlL20b32fsJFsdXHJRmJh4OJijMKYesPRBIaPWg-1742817368-1.0.1.1-9N9Ra5Y6IGgtJgR.nag4zSSb53t8OYEIyx1Um1X7rIs4jsHYasdOzdTAQyl02tFnIOJDrR0Agt_unVClv_DuBkhGE9srDE0mjg3ZLAWJPOw;
|
||||
path=/; expires=Mon, 24-Mar-25 12:26:08 GMT; domain=.api.openai.com; HttpOnly;
|
||||
- __cf_bm=bCY.suKtipA7n_n4ej.Zaf6.AKa7c5VV8WglOUkJswM-1742852640-1.0.1.1-FY7LbyMoo3XMfSr9MKW06LftuyCXqmyJouamZMkdi4zMbxILT3MVdKFOqPY4vPUdQKi3VrqiaKkAsv8EKFLE0vuw21uyVGoYuf7Nx2HaBvw;
|
||||
path=/; expires=Mon, 24-Mar-25 22:14:00 GMT; domain=.api.openai.com; HttpOnly;
|
||||
Secure; SameSite=None
|
||||
- _cfuvid=72YSOzv7i.OBKrlaFL8w.C_6Gy.KhbR9i1V7AROFLpw-1742817368482-0.0.1.1-604800000;
|
||||
- _cfuvid=xwJ0pVW3DQQFf6TZZbKkyqNt2pUsHIS8_EOPSvd0OsI-1742852640451-0.0.1.1-604800000;
|
||||
path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
Server:
|
||||
- cloudflare
|
||||
Cf-Ray:
|
||||
- 9255fbc45ac8e578-ORD
|
||||
- 925958e5dde6cf73-CMH
|
||||
Alt-Svc:
|
||||
- h3=":443"; ma=86400
|
||||
body:
|
||||
encoding: ASCII-8BIT
|
||||
string: |-
|
||||
{
|
||||
"id": "resp_67e14857cd908192ba7561296953b45707cf2fb10a8a0a6b",
|
||||
"id": "resp_67e1d21fb9cc8192bb416e29e1ce69800b24cca80d3ba0fc",
|
||||
"object": "response",
|
||||
"created_at": 1742817367,
|
||||
"created_at": 1742852639,
|
||||
"status": "completed",
|
||||
"error": null,
|
||||
"incomplete_details": null,
|
||||
@@ -73,7 +73,7 @@ http_interactions:
|
||||
"output": [
|
||||
{
|
||||
"type": "message",
|
||||
"id": "msg_67e1485844dc8192918afd5fb616c88507cf2fb10a8a0a6b",
|
||||
"id": "msg_67e1d22038bc81928134e767ece831a90b24cca80d3ba0fc",
|
||||
"status": "completed",
|
||||
"role": "assistant",
|
||||
"content": [
|
||||
@@ -116,5 +116,5 @@ http_interactions:
|
||||
"user": null,
|
||||
"metadata": {}
|
||||
}
|
||||
recorded_at: Mon, 24 Mar 2025 11:56:08 GMT
|
||||
recorded_at: Mon, 24 Mar 2025 21:44:00 GMT
|
||||
recorded_with: VCR 6.3.1
|
||||
@@ -24,7 +24,7 @@ http_interactions:
|
||||
message: Bad Request
|
||||
headers:
|
||||
Date:
|
||||
- Mon, 24 Mar 2025 11:56:05 GMT
|
||||
- Mon, 24 Mar 2025 21:43:59 GMT
|
||||
Content-Type:
|
||||
- application/json
|
||||
Content-Length:
|
||||
@@ -36,25 +36,25 @@ http_interactions:
|
||||
Openai-Organization:
|
||||
- "<OPENAI_ORGANIZATION_ID>"
|
||||
X-Request-Id:
|
||||
- req_44e26f4f8965fc30b895479963bd25f6
|
||||
- req_6fd45121d089ccbcc665963dfe89d469
|
||||
Openai-Processing-Ms:
|
||||
- '142'
|
||||
- '120'
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Cf-Cache-Status:
|
||||
- DYNAMIC
|
||||
Set-Cookie:
|
||||
- __cf_bm=pYI_l9yXtR6i72B_gFaBwXvtzu1JwQDbAXy9q_0jmJU-1742817365-1.0.1.1-WxucYTcQpYMX6YtQD2EGsGacpvB0K7BSCc6OaQ4dZ49mRyc6dup0ool5giRCpzPNRhye1UtRdcYwQpHhyKqcEEy0Dw6NfYjL_BntOLrvcM8;
|
||||
path=/; expires=Mon, 24-Mar-25 12:26:05 GMT; domain=.api.openai.com; HttpOnly;
|
||||
- __cf_bm=CxiuknWrSEKxFgktXFP4zrYmm7aoUGxkn4qaQwfv9dI-1742852639-1.0.1.1-PnCDFJ.7I7sMOnRC46kOgAZd0Hxtmpxror6P3_kUkpzblVtuV7wYmnpPdVKqPxJoL9AKdfRnyz3dknR.mhihCo.RL_2qdS1RnPrR6Lh2R48;
|
||||
path=/; expires=Mon, 24-Mar-25 22:13:59 GMT; domain=.api.openai.com; HttpOnly;
|
||||
Secure; SameSite=None
|
||||
- _cfuvid=8Og_nd.HyeMTwzXSCuvhAa1bOMXdlStiYmYDaCMsx8M-1742817365319-0.0.1.1-604800000;
|
||||
- _cfuvid=jOV733kUSPAemX8Z6u7bT2PPwGN1n2Yui.2SBg5s6Cg-1742852639913-0.0.1.1-604800000;
|
||||
path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
Server:
|
||||
- cloudflare
|
||||
Cf-Ray:
|
||||
- 9255fbb049cfe273-ORD
|
||||
- 925958e60aaccf88-CMH
|
||||
Alt-Svc:
|
||||
- h3=":443"; ma=86400
|
||||
body:
|
||||
@@ -68,5 +68,5 @@ http_interactions:
|
||||
"code": "model_not_found"
|
||||
}
|
||||
}
|
||||
recorded_at: Mon, 24 Mar 2025 11:56:05 GMT
|
||||
recorded_at: Mon, 24 Mar 2025 21:43:59 GMT
|
||||
recorded_with: VCR 6.3.1
|
||||
@@ -26,7 +26,7 @@ http_interactions:
|
||||
message: OK
|
||||
headers:
|
||||
Date:
|
||||
- Mon, 24 Mar 2025 11:56:06 GMT
|
||||
- Mon, 24 Mar 2025 21:44:00 GMT
|
||||
Content-Type:
|
||||
- application/json
|
||||
Transfer-Encoding:
|
||||
@@ -38,34 +38,34 @@ http_interactions:
|
||||
Openai-Organization:
|
||||
- "<OPENAI_ORGANIZATION_ID>"
|
||||
X-Request-Id:
|
||||
- req_d0876a41303fbe6da082c75b785293c3
|
||||
- req_d048963a2f48cfd1f42b92da3c04d89c
|
||||
Openai-Processing-Ms:
|
||||
- '905'
|
||||
- '1050'
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Cf-Cache-Status:
|
||||
- DYNAMIC
|
||||
Set-Cookie:
|
||||
- __cf_bm=NgsQOUyxatNioEv6sgOoQsUWmEv34qSIOgqj3IyzeoQ-1742817366-1.0.1.1-7ubcA2eV0yv7uVoul8zqS.u_KiKhtpdQXTJQCsIe0azxKxrkAQ35xpWRrcOQHYj0znSk3CkOS5vsAti5qQlW3Aid2LBDx_uOOTPEjc30vbM;
|
||||
path=/; expires=Mon, 24-Mar-25 12:26:06 GMT; domain=.api.openai.com; HttpOnly;
|
||||
- __cf_bm=aHgimIJIQRpqWZvw2fhxWCZlbY40.sBowQXF5R9iUgw-1742852640-1.0.1.1-WM1VBaAniM7JLis1UMAVA.TKOiwegYMF0jiSP7AhtFFpyQNVP.HMsgh5z3PkpvvlJfL7mcy.HfAjJTuUu8q_FAVSoieVkXVHXHUJYTO5pGM;
|
||||
path=/; expires=Mon, 24-Mar-25 22:14:00 GMT; domain=.api.openai.com; HttpOnly;
|
||||
Secure; SameSite=None
|
||||
- _cfuvid=pfd1rfIvOCMbu67UBHx2YfOR988IoNnEWOqvC910iLA-1742817366572-0.0.1.1-604800000;
|
||||
- _cfuvid=zNAzEPY0B72OssXI2T.Ul0yvKmpJ8LNbvxBNAMfFB3k-1742852640804-0.0.1.1-604800000;
|
||||
path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
Server:
|
||||
- cloudflare
|
||||
Cf-Ray:
|
||||
- 9255fbb6bb5fcf81-CMH
|
||||
- 925958e5cee7cf84-CMH
|
||||
Alt-Svc:
|
||||
- h3=":443"; ma=86400
|
||||
body:
|
||||
encoding: ASCII-8BIT
|
||||
string: |-
|
||||
{
|
||||
"id": "resp_67e14855a9988192a411393e44d567cd05ebede25f548fb9",
|
||||
"id": "resp_67e1d21fb23c8192833e882544aad9fb0eccf467b76649e8",
|
||||
"object": "response",
|
||||
"created_at": 1742817365,
|
||||
"created_at": 1742852639,
|
||||
"status": "completed",
|
||||
"error": null,
|
||||
"incomplete_details": null,
|
||||
@@ -75,8 +75,8 @@ http_interactions:
|
||||
"output": [
|
||||
{
|
||||
"type": "function_call",
|
||||
"id": "fc_67e1485661a08192995584746a37273e05ebede25f548fb9",
|
||||
"call_id": "call_qxpPT6DVoIfX5z9PiL9y8LY1",
|
||||
"id": "fc_67e1d22095708192a668fe3e8c63f83c0eccf467b76649e8",
|
||||
"call_id": "call_LRJqOWWq0Ao4oQF38eiohneb",
|
||||
"name": "get_net_worth",
|
||||
"arguments": "{}",
|
||||
"status": "completed"
|
||||
@@ -126,7 +126,7 @@ http_interactions:
|
||||
"user": null,
|
||||
"metadata": {}
|
||||
}
|
||||
recorded_at: Mon, 24 Mar 2025 11:56:06 GMT
|
||||
recorded_at: Mon, 24 Mar 2025 21:44:00 GMT
|
||||
- request:
|
||||
method: post
|
||||
uri: https://api.openai.com/v1/responses
|
||||
@@ -134,7 +134,7 @@ http_interactions:
|
||||
encoding: UTF-8
|
||||
string: '{"model":"gpt-4o","instructions":"Use the tools available to you to
|
||||
answer the user''s question.","input":[{"role":"user","content":"What is my
|
||||
net worth?"},{"type":"function_call","id":"fc_67e1485661a08192995584746a37273e05ebede25f548fb9","call_id":"call_qxpPT6DVoIfX5z9PiL9y8LY1","name":"get_net_worth","arguments":"{}"},{"type":"function_call_output","call_id":"call_qxpPT6DVoIfX5z9PiL9y8LY1","output":"$124,200"}]}'
|
||||
net worth?"},{"type":"function_call","id":"fc_67e1d22095708192a668fe3e8c63f83c0eccf467b76649e8","call_id":"call_LRJqOWWq0Ao4oQF38eiohneb","name":"get_net_worth","arguments":"{}"},{"type":"function_call_output","call_id":"call_LRJqOWWq0Ao4oQF38eiohneb","output":"$124,200"}]}'
|
||||
headers:
|
||||
Content-Type:
|
||||
- application/json
|
||||
@@ -152,7 +152,7 @@ http_interactions:
|
||||
message: OK
|
||||
headers:
|
||||
Date:
|
||||
- Mon, 24 Mar 2025 11:56:07 GMT
|
||||
- Mon, 24 Mar 2025 21:44:02 GMT
|
||||
Content-Type:
|
||||
- application/json
|
||||
Transfer-Encoding:
|
||||
@@ -164,34 +164,34 @@ http_interactions:
|
||||
Openai-Organization:
|
||||
- "<OPENAI_ORGANIZATION_ID>"
|
||||
X-Request-Id:
|
||||
- req_633430fc9215c27cc0a226341decf596
|
||||
- req_e0117a87ad49a43729e4208ac370af1f
|
||||
Openai-Processing-Ms:
|
||||
- '734'
|
||||
- '1348'
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Cf-Cache-Status:
|
||||
- DYNAMIC
|
||||
Set-Cookie:
|
||||
- __cf_bm=Yb4JfiKKvDl9H_PyQZXRjNYW5eUYCvSXoqt6Z9A5DTU-1742817367-1.0.1.1-7XJKuhEr6DF2SZkL20X0HADYB5R9L5VkPL4BweI.9CKU7HicgyiC3jrF1vjLw4958jjD6V_gwlI8MPq1hcdvGSxVZOk2MT0NUh2teI81UoQ;
|
||||
path=/; expires=Mon, 24-Mar-25 12:26:07 GMT; domain=.api.openai.com; HttpOnly;
|
||||
- __cf_bm=k_kSc87FWSNW47rXiQ0t2UskVDlykLyeAZIZnPfbxqY-1742852642-1.0.1.1-VHB6_jGpcGO4Nnj58pWknxAmmYEoGIoswHlx19NuI0DZ02RZoDXAeZSbGK9VNwQuMWIKdkCJ_EF.3IPaYF.YYd0fFGLuDCYAmFuli7Don0M;
|
||||
path=/; expires=Mon, 24-Mar-25 22:14:02 GMT; domain=.api.openai.com; HttpOnly;
|
||||
Secure; SameSite=None
|
||||
- _cfuvid=PV9JJMd_2baUGo7BGxGmzaHWv1n7oCuQoVXPc0wimtM-1742817367605-0.0.1.1-604800000;
|
||||
- _cfuvid=9QuOT2KgbvD2t2pleBXg0T1ZrWXS6SlDwUZoNnmas5M-1742852642420-0.0.1.1-604800000;
|
||||
path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
Server:
|
||||
- cloudflare
|
||||
Cf-Ray:
|
||||
- 9255fbbe6f9572eb-ORD
|
||||
- 925958edfa00cf5a-CMH
|
||||
Alt-Svc:
|
||||
- h3=":443"; ma=86400
|
||||
body:
|
||||
encoding: ASCII-8BIT
|
||||
string: |-
|
||||
{
|
||||
"id": "resp_67e14856d9d88192a24ad9727155351e05ebede25f548fb9",
|
||||
"id": "resp_67e1d2210c788192bab33010721274920eccf467b76649e8",
|
||||
"object": "response",
|
||||
"created_at": 1742817366,
|
||||
"created_at": 1742852641,
|
||||
"status": "completed",
|
||||
"error": null,
|
||||
"incomplete_details": null,
|
||||
@@ -201,7 +201,7 @@ http_interactions:
|
||||
"output": [
|
||||
{
|
||||
"type": "message",
|
||||
"id": "msg_67e14857620c8192ad258f378b27a9e005ebede25f548fb9",
|
||||
"id": "msg_67e1d221dca881929a8097a57a2f75b40eccf467b76649e8",
|
||||
"status": "completed",
|
||||
"role": "assistant",
|
||||
"content": [
|
||||
@@ -244,5 +244,5 @@ http_interactions:
|
||||
"user": null,
|
||||
"metadata": {}
|
||||
}
|
||||
recorded_at: Mon, 24 Mar 2025 11:56:07 GMT
|
||||
recorded_at: Mon, 24 Mar 2025 21:44:02 GMT
|
||||
recorded_with: VCR 6.3.1
|
||||
Reference in New Issue
Block a user