ruby_llm-providers-qiniu 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.flayignore +1 -0
- data/.github/workflows/ci.yml +28 -0
- data/.github/workflows/gitleaks.yml +23 -0
- data/.github/workflows/release.yml +36 -0
- data/.overcommit.yml +31 -0
- data/.rspec +2 -0
- data/.rubocop.yml +29 -0
- data/Archspec.rb +14 -0
- data/LICENSE +21 -0
- data/README.md +114 -0
- data/lib/ruby_llm/providers/qiniu.rb +134 -0
- data/models.json +859 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_anthropic_claude_sonnet_5_can_handle_a_multi_turn_conversation.yml +154 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_anthropic_claude_sonnet_5_can_have_a_basic_conversation.yml +61 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_anthropic_claude_sonnet_5_can_use_tools.yml +121 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_anthropic_claude_sonnet_5_returns_structured_output.yml +62 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_anthropic_claude_sonnet_5_returns_the_raw_response.yml +66 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_anthropic_claude_sonnet_5_supports_streaming_responses.yml +105 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_deepseek_deepseek_v4_1_flash_can_handle_a_multi_turn_conversation.yml +127 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_deepseek_deepseek_v4_1_flash_can_have_a_basic_conversation.yml +58 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_deepseek_deepseek_v4_1_flash_can_use_tools.yml +119 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_deepseek_deepseek_v4_1_flash_returns_structured_output.yml +59 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_deepseek_deepseek_v4_1_flash_returns_the_raw_response.yml +58 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_deepseek_deepseek_v4_1_flash_supports_streaming_responses.yml +89 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_gemini_3_1_flash_lite_preview_can_handle_a_multi_turn_conversation.yml +195 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_gemini_3_1_flash_lite_preview_can_have_a_basic_conversation.yml +96 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_gemini_3_1_flash_lite_preview_can_use_tools.yml +165 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_gemini_3_1_flash_lite_preview_returns_structured_output.yml +97 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_gemini_3_1_flash_lite_preview_returns_the_raw_response.yml +97 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_gemini_3_1_flash_lite_preview_supports_streaming_responses.yml +70 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_google_gemini_3_1_flash_lite_can_handle_a_multi_turn_conversation.yml +194 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_google_gemini_3_1_flash_lite_can_have_a_basic_conversation.yml +96 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_google_gemini_3_1_flash_lite_can_use_tools.yml +165 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_google_gemini_3_1_flash_lite_returns_structured_output.yml +97 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_google_gemini_3_1_flash_lite_returns_the_raw_response.yml +97 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_google_gemini_3_1_flash_lite_supports_streaming_responses.yml +70 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_google_gemini_3_8_flash_can_handle_a_multi_turn_conversation.yml +199 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_google_gemini_3_8_flash_can_have_a_basic_conversation.yml +97 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_google_gemini_3_8_flash_can_use_tools.yml +166 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_google_gemini_3_8_flash_returns_structured_output.yml +98 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_google_gemini_3_8_flash_returns_the_raw_response.yml +98 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_google_gemini_3_8_flash_supports_streaming_responses.yml +71 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_2_can_handle_a_multi_turn_conversation.yml +419 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_2_can_have_a_basic_conversation.yml +210 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_2_can_use_tools.yml +468 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_2_returns_structured_output.yml +229 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_2_returns_the_raw_response.yml +210 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_2_supports_streaming_responses.yml +102 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_4_can_handle_a_multi_turn_conversation.yml +421 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_4_can_have_a_basic_conversation.yml +157 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_4_can_use_tools.yml +469 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_4_mini_can_handle_a_multi_turn_conversation.yml +422 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_4_mini_can_have_a_basic_conversation.yml +211 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_4_mini_can_use_tools.yml +469 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_4_mini_returns_structured_output.yml +230 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_4_mini_returns_the_raw_response.yml +211 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_4_mini_supports_streaming_responses.yml +102 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_4_returns_structured_output.yml +230 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_4_returns_the_raw_response.yml +157 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_4_supports_streaming_responses.yml +102 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_6_luna_can_handle_a_multi_turn_conversation.yml +389 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_6_luna_can_have_a_basic_conversation.yml +241 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_6_luna_can_use_tools.yml +437 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_6_luna_returns_structured_output.yml +214 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_6_luna_returns_the_raw_response.yml +241 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_5_6_luna_supports_streaming_responses.yml +106 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_6_luna_can_handle_a_multi_turn_conversation.yml +389 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_6_luna_can_have_a_basic_conversation.yml +202 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_6_luna_can_use_tools.yml +437 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_6_luna_returns_structured_output.yml +221 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_6_luna_returns_the_raw_response.yml +202 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_6_luna_supports_streaming_responses.yml +112 -0
- data/spec/ruby_llm/chat_schema_spec.rb +30 -0
- data/spec/ruby_llm/chat_spec.rb +35 -0
- data/spec/ruby_llm/chat_streaming_spec.rb +22 -0
- data/spec/ruby_llm/chat_tools_spec.rb +32 -0
- data/spec/ruby_llm/embedding_spec.rb +49 -0
- data/spec/ruby_llm/image_spec.rb +23 -0
- data/spec/ruby_llm/models_spec.rb +11 -0
- data/spec/ruby_llm/moderation_spec.rb +22 -0
- data/spec/ruby_llm/providers/qiniu_spec.rb +103 -0
- data/spec/ruby_llm/rerank_spec.rb +23 -0
- data/spec/ruby_llm/speech_spec.rb +25 -0
- data/spec/ruby_llm/video_spec.rb +27 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/support/models.rb +30 -0
- data/spec/support/rubyllm_configuration.rb +14 -0
- data/spec/support/vcr_configuration.rb +16 -0
- metadata +147 -0
data/spec/fixtures/vcr_cassettes/rubyllm_chat_qiniu_openai_gpt_6_luna_returns_the_raw_response.yml
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: post
|
|
5
|
+
uri: "<QINIU_BASE_URL>/bypass/openai/v1/responses"
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: '{"model":"openai/gpt-6-luna","input":[{"role":"user","content":"What
|
|
9
|
+
is the capital of France?"}],"stream":false,"store":false,"include":["reasoning.encrypted_content"]}'
|
|
10
|
+
headers:
|
|
11
|
+
User-Agent:
|
|
12
|
+
- Faraday v2.14.4
|
|
13
|
+
Authorization:
|
|
14
|
+
- Bearer <AUTH_TOKEN>
|
|
15
|
+
Content-Type:
|
|
16
|
+
- application/json
|
|
17
|
+
Accept-Encoding:
|
|
18
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
19
|
+
Accept:
|
|
20
|
+
- "*/*"
|
|
21
|
+
response:
|
|
22
|
+
status:
|
|
23
|
+
code: 200
|
|
24
|
+
message: OK
|
|
25
|
+
headers:
|
|
26
|
+
Content-Type:
|
|
27
|
+
- application/json
|
|
28
|
+
Access-Control-Allow-Credentials:
|
|
29
|
+
- 'true'
|
|
30
|
+
Access-Control-Allow-Headers:
|
|
31
|
+
- ''
|
|
32
|
+
Access-Control-Allow-Methods:
|
|
33
|
+
- GET, POST, PUT, PATCH, DELETE, OPTIONS
|
|
34
|
+
Access-Control-Allow-Origin:
|
|
35
|
+
- ''
|
|
36
|
+
Access-Control-Expose-Headers:
|
|
37
|
+
- Http_x_reqid
|
|
38
|
+
Http-X-Reqid:
|
|
39
|
+
- chatptrsp-001490a2645641ae84a615bd29e4b584
|
|
40
|
+
X-Ratelimit-Abusepenalty-Active:
|
|
41
|
+
- 'False'
|
|
42
|
+
X-Ratelimit-Key:
|
|
43
|
+
- gpt-6-luna
|
|
44
|
+
X-Ratelimit-Limit-Requests:
|
|
45
|
+
- '15000'
|
|
46
|
+
X-Ratelimit-Limit-Tokens:
|
|
47
|
+
- '15000000'
|
|
48
|
+
X-Ratelimit-Remaining-Requests:
|
|
49
|
+
- '14999'
|
|
50
|
+
X-Ratelimit-Remaining-Tokens:
|
|
51
|
+
- '14999993'
|
|
52
|
+
X-Ratelimit-Renewalperiod-Requests:
|
|
53
|
+
- '60'
|
|
54
|
+
X-Ratelimit-Renewalperiod-Tokens:
|
|
55
|
+
- '60'
|
|
56
|
+
X-Ratelimit-Reset-Requests:
|
|
57
|
+
- '0'
|
|
58
|
+
X-Ratelimit-Reset-Tokens:
|
|
59
|
+
- '0'
|
|
60
|
+
X-Request-Id:
|
|
61
|
+
- 6fa56ecc-1a15-4c7a-8242-d5292e0a4567
|
|
62
|
+
Server:
|
|
63
|
+
- APISIX
|
|
64
|
+
Cache-Control:
|
|
65
|
+
- no-cache
|
|
66
|
+
Transfer-Encoding:
|
|
67
|
+
- chunked
|
|
68
|
+
Connection:
|
|
69
|
+
- keep-alive
|
|
70
|
+
Date:
|
|
71
|
+
- Wed, 30 Sep 2026 04:44:01 GMT
|
|
72
|
+
Eo-Log-Uuid:
|
|
73
|
+
- '17563679879196998123'
|
|
74
|
+
Eo-Cache-Status:
|
|
75
|
+
- MISS
|
|
76
|
+
body:
|
|
77
|
+
encoding: UTF-8
|
|
78
|
+
string: |-
|
|
79
|
+
{
|
|
80
|
+
"id": "resp_0a54fb5d7b0b43cf016abc939231fc819580259650f1fb6026",
|
|
81
|
+
"object": "response",
|
|
82
|
+
"created_at": 1790743442,
|
|
83
|
+
"status": "completed",
|
|
84
|
+
"background": false,
|
|
85
|
+
"completed_at": 1790743445,
|
|
86
|
+
"content_filters": [
|
|
87
|
+
{
|
|
88
|
+
"blocked": false,
|
|
89
|
+
"source_type": "prompt",
|
|
90
|
+
"content_filter_raw": [],
|
|
91
|
+
"content_filter_results": {},
|
|
92
|
+
"content_filter_offsets": {
|
|
93
|
+
"start_offset": 0,
|
|
94
|
+
"end_offset": 808,
|
|
95
|
+
"check_offset": 0
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"blocked": false,
|
|
100
|
+
"source_type": "completion",
|
|
101
|
+
"content_filter_raw": [],
|
|
102
|
+
"content_filter_results": {},
|
|
103
|
+
"content_filter_offsets": {
|
|
104
|
+
"start_offset": 0,
|
|
105
|
+
"end_offset": 28,
|
|
106
|
+
"check_offset": 0
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"error": null,
|
|
111
|
+
"frequency_penalty": 0.0,
|
|
112
|
+
"incomplete_details": null,
|
|
113
|
+
"instructions": null,
|
|
114
|
+
"max_output_tokens": null,
|
|
115
|
+
"max_tool_calls": null,
|
|
116
|
+
"model": "openai/gpt-6-luna",
|
|
117
|
+
"moderation": null,
|
|
118
|
+
"output": [
|
|
119
|
+
{
|
|
120
|
+
"id": "rs_0a54fb5d7b0b43cf016abc93957be08195a00e4d838298472f",
|
|
121
|
+
"type": "reasoning",
|
|
122
|
+
"content": [],
|
|
123
|
+
"encrypted_content": "gAAAAABqvJOVmTEqb8B8jciIAmyjaNucsPK1TfrhNe_IjYerDN5-gemd8z0sUt2FV09HyIL_rTBEovVLxKGVKImcBTxbgFIAcT60rN8sMiuTQFlvwp5oYAzo_ZiBrG8JISX3sDUMZuNh7MFoUQlSoQvoHdXE_CgYJo32NQLvNf01U0PIpzffOwQcp9dBSLHAdUc9lcfOK-8-H1mK8FWdpuegszRQRW6hObuHwoXhwJv2Onyj2m_KbqPgGcDJCjMa2zXciwHmv65MHcScOwCZCKAU-ZArUksYTgm9v5Dnlhtipl-JQWwAOxqisQAAdtrXJQLSs6QEUv284bMx-3mGdNZCPPyicFGBMhwxZXQCMXD6bg0vfpIBo-PHgfNF8wvmDikNNaT_qOQ4dVBzjtJxKxln0c2X1JFbqA_7jPT4-r6Paxu_F5SmOpnVnhvGimPOf2e0G2apuGEwm2Y20ESY8iQ7wGRE-Gp7Lbc5AUlSyJtfPlrZ7fqW4U5INjfzs_9yvkqIP7pa-zw5uxP6Z8WCoKTscYzWi16TOnd5ijuKELmuhZVUo4pum_fo4N1sGkmkoUSVsMbIICwzWFodDwnMuxotTr7IRsmEaW6WPyMEXdKGtHXT7ODXqvth08noSaU4J4jbwYkD470mMLq5wsC_tifBatEjHJypTDdb73hEPM9Uj8zhSlH083W8dep_--vV16CAiSSy5G4nqUzXXZDOYk1L-9hAHsRzLcr0hY2CElcah9lIxTE9LljhtTfJqMPp1QHppcqCzQXqKcrurIa-FfWazXlEBI22mgOOM3wKa40uMFbjf-gU15y0dzFW_utcpFODo2zTL3ZNiut_j7_hCLC_WOEULylwqj6lQzCO_zruYd-iiXrKCR7T4p-oWSTUSAOfB4_zfunyNh2r6CCFk62dNn4SYS2i-NQJtOVJsUb0-iR00D36ZlG94MMLyhripdRn4S2HY2a8QZfEDExqdaIzd1O9HfR17fyw1wqPj6x_553Kni41TaEUc8zXsO1KEx7pU9PZAy15t9rkEtbSla_fx3BTMrdrfBUwPt7eTegFgJTQW_puW9O9rpdXkOPO1SdGaF6h7-5zVaBwHm4p8qx5Sd9m2MuN-DHofOj_53Is-Wc6_z1lzEQOly8-QYRRKYoGQwo24L3h",
|
|
124
|
+
"summary": []
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"id": "msg_0a54fb5d7b0b43cf016abc93958bb48195bc8ebce9518c3f01",
|
|
128
|
+
"type": "message",
|
|
129
|
+
"status": "completed",
|
|
130
|
+
"content": [
|
|
131
|
+
{
|
|
132
|
+
"type": "output_text",
|
|
133
|
+
"annotations": [],
|
|
134
|
+
"logprobs": [],
|
|
135
|
+
"text": "Paris."
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
"phase": "final_answer",
|
|
139
|
+
"role": "assistant"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"parallel_tool_calls": true,
|
|
143
|
+
"presence_penalty": 0.0,
|
|
144
|
+
"previous_response_id": null,
|
|
145
|
+
"prompt_cache_key": null,
|
|
146
|
+
"prompt_cache_retention": "24h",
|
|
147
|
+
"reasoning": {
|
|
148
|
+
"context": "all_turns",
|
|
149
|
+
"effort": "medium",
|
|
150
|
+
"mode": "standard",
|
|
151
|
+
"summary": null
|
|
152
|
+
},
|
|
153
|
+
"safety_identifier": null,
|
|
154
|
+
"service_tier": "default",
|
|
155
|
+
"store": false,
|
|
156
|
+
"temperature": 1.0,
|
|
157
|
+
"text": {
|
|
158
|
+
"format": {
|
|
159
|
+
"type": "text"
|
|
160
|
+
},
|
|
161
|
+
"verbosity": "medium"
|
|
162
|
+
},
|
|
163
|
+
"tool_choice": "auto",
|
|
164
|
+
"tool_usage": {
|
|
165
|
+
"image_gen": {
|
|
166
|
+
"input_tokens": 0,
|
|
167
|
+
"input_tokens_details": {
|
|
168
|
+
"image_tokens": 0,
|
|
169
|
+
"text_tokens": 0
|
|
170
|
+
},
|
|
171
|
+
"output_tokens": 0,
|
|
172
|
+
"output_tokens_details": {
|
|
173
|
+
"image_tokens": 0,
|
|
174
|
+
"text_tokens": 0
|
|
175
|
+
},
|
|
176
|
+
"total_tokens": 0
|
|
177
|
+
},
|
|
178
|
+
"web_search": {
|
|
179
|
+
"num_requests": 0
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
"tools": [],
|
|
183
|
+
"top_logprobs": 0,
|
|
184
|
+
"top_p": 0.98,
|
|
185
|
+
"truncation": "disabled",
|
|
186
|
+
"usage": {
|
|
187
|
+
"input_tokens": 13,
|
|
188
|
+
"input_tokens_details": {
|
|
189
|
+
"cache_write_tokens": 0,
|
|
190
|
+
"cached_tokens": 0
|
|
191
|
+
},
|
|
192
|
+
"output_tokens": 17,
|
|
193
|
+
"output_tokens_details": {
|
|
194
|
+
"reasoning_tokens": 9
|
|
195
|
+
},
|
|
196
|
+
"total_tokens": 30
|
|
197
|
+
},
|
|
198
|
+
"user": null,
|
|
199
|
+
"metadata": {}
|
|
200
|
+
}
|
|
201
|
+
recorded_at: Wed, 30 Sep 2026 04:44:06 GMT
|
|
202
|
+
recorded_with: VCR 6.4.0
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: post
|
|
5
|
+
uri: "<QINIU_BASE_URL>/bypass/openai/v1/responses"
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: '{"model":"openai/gpt-6-luna","input":[{"role":"user","content":"Count
|
|
9
|
+
from 1 to 3"}],"stream":true,"store":false,"include":["reasoning.encrypted_content"]}'
|
|
10
|
+
headers:
|
|
11
|
+
User-Agent:
|
|
12
|
+
- Faraday v2.14.4
|
|
13
|
+
Authorization:
|
|
14
|
+
- Bearer <AUTH_TOKEN>
|
|
15
|
+
Content-Type:
|
|
16
|
+
- application/json
|
|
17
|
+
Accept-Encoding:
|
|
18
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
19
|
+
Accept:
|
|
20
|
+
- "*/*"
|
|
21
|
+
response:
|
|
22
|
+
status:
|
|
23
|
+
code: 200
|
|
24
|
+
message: OK
|
|
25
|
+
headers:
|
|
26
|
+
Content-Type:
|
|
27
|
+
- text/event-stream
|
|
28
|
+
Access-Control-Allow-Credentials:
|
|
29
|
+
- 'true'
|
|
30
|
+
Access-Control-Allow-Headers:
|
|
31
|
+
- ''
|
|
32
|
+
Access-Control-Allow-Methods:
|
|
33
|
+
- GET, POST, PUT, PATCH, DELETE, OPTIONS
|
|
34
|
+
Access-Control-Allow-Origin:
|
|
35
|
+
- ''
|
|
36
|
+
Access-Control-Expose-Headers:
|
|
37
|
+
- Http_x_reqid
|
|
38
|
+
Http-X-Reqid:
|
|
39
|
+
- chatptrsp-11d04d189e4e4de7964646c292346270
|
|
40
|
+
X-Request-Id:
|
|
41
|
+
- chatptrsp-11d04d189e4e4de7964646c292346270
|
|
42
|
+
Server:
|
|
43
|
+
- APISIX
|
|
44
|
+
Cache-Control:
|
|
45
|
+
- no-cache
|
|
46
|
+
Transfer-Encoding:
|
|
47
|
+
- chunked
|
|
48
|
+
Connection:
|
|
49
|
+
- keep-alive
|
|
50
|
+
Date:
|
|
51
|
+
- Wed, 30 Sep 2026 04:43:50 GMT
|
|
52
|
+
Eo-Log-Uuid:
|
|
53
|
+
- '9455614535617570705'
|
|
54
|
+
Eo-Cache-Status:
|
|
55
|
+
- MISS
|
|
56
|
+
body:
|
|
57
|
+
encoding: UTF-8
|
|
58
|
+
string: |+
|
|
59
|
+
event: response.created
|
|
60
|
+
data: {"type":"response.created","response":{"id":"resp_00ab7a8a15e8d501016abc93873edc8196a31c110964bd201d","object":"response","created_at":1790743431,"status":"in_progress","background":false,"completed_at":null,"content_filters":null,"error":null,"frequency_penalty":0.0,"incomplete_details":null,"instructions":null,"max_output_tokens":null,"max_tool_calls":null,"model":"openai/gpt-6-luna","moderation":null,"output":[],"parallel_tool_calls":true,"presence_penalty":0.0,"previous_response_id":null,"prompt_cache_key":null,"prompt_cache_retention":"24h","reasoning":{"context":"all_turns","effort":"medium","mode":"standard","summary":null},"safety_identifier":null,"service_tier":"auto","store":false,"temperature":1.0,"text":{"format":{"type":"text"},"verbosity":"medium"},"tool_choice":"auto","tool_usage":{"image_gen":{"input_tokens":0,"input_tokens_details":{"image_tokens":0,"text_tokens":0},"output_tokens":0,"output_tokens_details":{"image_tokens":0,"text_tokens":0},"total_tokens":0},"web_search":{"num_requests":0}},"tools":[],"top_logprobs":0,"top_p":0.98,"truncation":"disabled","usage":null,"user":null,"metadata":{}},"sequence_number":0}
|
|
61
|
+
|
|
62
|
+
event: response.in_progress
|
|
63
|
+
data: {"type":"response.in_progress","response":{"id":"resp_00ab7a8a15e8d501016abc93873edc8196a31c110964bd201d","object":"response","created_at":1790743431,"status":"in_progress","background":false,"completed_at":null,"content_filters":null,"error":null,"frequency_penalty":0.0,"incomplete_details":null,"instructions":null,"max_output_tokens":null,"max_tool_calls":null,"model":"openai/gpt-6-luna","moderation":null,"output":[],"parallel_tool_calls":true,"presence_penalty":0.0,"previous_response_id":null,"prompt_cache_key":null,"prompt_cache_retention":"24h","reasoning":{"context":"all_turns","effort":"medium","mode":"standard","summary":null},"safety_identifier":null,"service_tier":"auto","store":false,"temperature":1.0,"text":{"format":{"type":"text"},"verbosity":"medium"},"tool_choice":"auto","tool_usage":{"image_gen":{"input_tokens":0,"input_tokens_details":{"image_tokens":0,"text_tokens":0},"output_tokens":0,"output_tokens_details":{"image_tokens":0,"text_tokens":0},"total_tokens":0},"web_search":{"num_requests":0}},"tools":[],"top_logprobs":0,"top_p":0.98,"truncation":"disabled","usage":null,"user":null,"metadata":{}},"sequence_number":1}
|
|
64
|
+
|
|
65
|
+
event: response.output_item.added
|
|
66
|
+
data: {"type":"response.output_item.added","item":{"id":"rs_00ab7a8a15e8d501016abc9387e7ec819681846275c46a31c4","type":"reasoning","content":[],"encrypted_content":"gAAAAABqvJOH46YpEjBiFrHt7cEzNHe1GY1hVKI3tmJ9sSS_U8M0Rrl6HbPR8HsS2lKijFiXExlNdusc2OopeoLYUsBpnwRdzaFXCSBxrlXRvUwgh-y5lR7wXD8kpkazw2qxleyG9RFWJkCUAdvZGxq4injhKLi3QbcruCgrZv4Hvy6EFcAXoL_eRJXbU-VdljC4Y7kz49ubwt-n_SNusSjL-rYvPX09ZLDa67lYjjGl_tlACbk-yFCQOtCM0A7s-pqujNk1yzCTXCK-F-aQt70MD338I3N96ll3qCLBNBcXgzhRoFJA-LBlpE4vZLJF0VRzLfsPnYVtHuSycWbBrQCUCxJxMpaYSgt7Og6hdOsVg_2P2DdXMUx3mMcDwDe3U_d_XSgRzQBY5yAK3mftMnA6q_vmuIO47uswA3VM_KR5ROidZ9QreFvqzQA7Vp7Dtz9Tgs3tN8Whtvqrd7CyVgxn3m6j344IwUdsjkJbKPc2SiqaLlRbns0SxfuO4-Y-rXl4VV05a-zgFb0c__XGc0vbMPdMovDnBASnyR3lh6nO-RTLq7VgWewJRMiG8MSQaCCoKxBXmXxfFBJZedmTxf1-j4ocDywskMRU3mb1r_qxms0ez5sQPWXrNk_FFPFa0IyDJ7Zow37_M6eGO8SSINPh36CuRZpj-VgtUnhal5MoZaBTbkn5v_as1MnQHMMgl7nyO69KjUkuVXlE8ULu7pO6Py2AqWBW2RlKjXutIxgGDP_N9U7tr4WG8FICwwdjul711PylBPZiKQD9ymxAun2s8NwLy6u7KLIsX9BvVzYPcbO9EdxtpaJgmH5JSN8ATBz5z4ZRzzPHgd0cyxmNve_ssGXkYVulodyh6Uaq8q_DzgmJwVerc-aDOz9mFdZGGOnNRiVKoWXb-1qRBkc1lg5o8pj0yxLcEVsyet1MbgjH82YPyLfUH3FmCb664Ccv_7IzDWtevXScWHi5nIYg-s_R4oTB1l2tC36EmdP98IbYWPt2y2oks4qWrCjKgyqFgYtm4d1OnORKitZ0qpLY0rbcNtnWQ2TYbQNu1iQ_LNe5Jxl3XfAcVPRQdbnkhuC-OhhIKtVmmazCnVtsy957_4HGY_Bi7EbIYQ==","summary":[]},"output_index":0,"sequence_number":2}
|
|
67
|
+
|
|
68
|
+
event: response.output_item.done
|
|
69
|
+
data: {"type":"response.output_item.done","item":{"id":"rs_00ab7a8a15e8d501016abc9387e7ec819681846275c46a31c4","type":"reasoning","content":[],"encrypted_content":"gAAAAABqvJOHeObxPIgzwe1n7dEhLxmTRZbPJ6f1bXHdHYn36VFLQo1DR7U5fk-_QTr6j0x-9i_s05jg2LfIIxvDib8KA2lcCin0tTZTR4EeC2yY1E3kYbfV8OI__XbBBM_2sq7XS5yxd2UZe5eUDr9_M1O_eWVmny6hK_LzcyOT3q5DQaIEDkrl8m8bbDUZ4GYEkJSx0sTvJ8D-NxdjUsO07hsoZycKIBZWQbOgRSgHCKdmtAjgRWDp-ecyck0cIK8Q3NhrLyxc3PdC09i58o5byw-fZusEaLKq7inPgR6wps6mt6X70Jdu3jEql2IFHDQqIqZIePZuWI84yupvFuZGebegL4eVohsdcuwZ2MTkg8SF-3yWhqPG6ap26yiBM20u81pl3iibJdPgjRp6YrYQuvo3heDCz932n1XNwVyaTvY06MGC1SPr1H2AoY7KSf_gOiKciCRTnIkjBdU80d5F7QBK8Ti43l_UOe0Xh8WsQPHV9XbnvGu2nWyxPBJ744h75N5R0zfEi-X3yohFrV98D2KGW3BHo8qdPal2sjWPPKwpaNLtUTK-ER3LCdHhufln-k3X-0n2WQ408zNap2UA1ytZcr8VstqjXxJQG-omTiK7AQR1YBJK9RAGKm-5NZswOjevSEppVMMPiAMltrhgPADhPJ_qeOeUpoSr0T48sGw-s0XQLOHTwn7AZsqsDWdNdQUNj9EnFOV5DtB94FV-6ZtZVT7lykDRBmCBlKeeiV62deCZ3D9oxD7SXlCL3sDboJw2nyv08svKBl3gR5dyaNYT53L5EUPeS2wdRydpY9WQtxMvHneqnYM5sXX8C8nedOOo5r3QPcKiykbIwtvVEwDmIluV1p0DlCwIJc9UNtz2LO2v70br3_NgNzMPZPbW548o7-8hgonxapAJ4ic4y7sTknm6ze1J5ahUtCuhD4R5svuBSSCOv7RZSUuTBrvZAd_JiBYlzFOjdSM8B4hWyY8uPpwGD46QIwafM6E_lOLJ1spvVKdJIef8zbkaPJJ8j-0x5k2gDHpsZp-NObbmP403_CjN9s0Uf8URtnnUv5keC_ML15kJHeiqXvheHKV4DJ6w3q2-tZXoL8DrE2jWH7ZLmJ78onlt7Pjn7nVf5DPAvBhOrKPkWjAzkx4rORtIxWazyrQn","summary":[]},"output_index":0,"sequence_number":3}
|
|
70
|
+
|
|
71
|
+
event: response.output_item.added
|
|
72
|
+
data: {"type":"response.output_item.added","item":{"id":"msg_00ab7a8a15e8d501016abc9387f954819696764c6c49b1c96c","type":"message","status":"in_progress","content":[],"phase":"final_answer","role":"assistant"},"output_index":1,"sequence_number":4}
|
|
73
|
+
|
|
74
|
+
event: response.content_part.added
|
|
75
|
+
data: {"type":"response.content_part.added","content_index":0,"item_id":"msg_00ab7a8a15e8d501016abc9387f954819696764c6c49b1c96c","output_index":1,"part":{"type":"output_text","annotations":[],"logprobs":[],"text":""},"sequence_number":5}
|
|
76
|
+
|
|
77
|
+
event: response.output_text.delta
|
|
78
|
+
data: {"type":"response.output_text.delta","content_index":0,"delta":"1","item_id":"msg_00ab7a8a15e8d501016abc9387f954819696764c6c49b1c96c","logprobs":[],"obfuscation":"JMnrA8nUdDKhVvo","output_index":1,"sequence_number":6}
|
|
79
|
+
|
|
80
|
+
event: response.output_text.delta
|
|
81
|
+
data: {"type":"response.output_text.delta","content_index":0,"delta":",","item_id":"msg_00ab7a8a15e8d501016abc9387f954819696764c6c49b1c96c","logprobs":[],"obfuscation":"7eeW1BR2McNXrsF","output_index":1,"sequence_number":7}
|
|
82
|
+
|
|
83
|
+
event: response.output_text.delta
|
|
84
|
+
data: {"type":"response.output_text.delta","content_index":0,"delta":" ","item_id":"msg_00ab7a8a15e8d501016abc9387f954819696764c6c49b1c96c","logprobs":[],"obfuscation":"XQBSjTQIQ8oRch2","output_index":1,"sequence_number":8}
|
|
85
|
+
|
|
86
|
+
event: response.output_text.delta
|
|
87
|
+
data: {"type":"response.output_text.delta","content_index":0,"delta":"2","item_id":"msg_00ab7a8a15e8d501016abc9387f954819696764c6c49b1c96c","logprobs":[],"obfuscation":"yE43Rvc0GlikHqo","output_index":1,"sequence_number":9}
|
|
88
|
+
|
|
89
|
+
event: response.output_text.delta
|
|
90
|
+
data: {"type":"response.output_text.delta","content_index":0,"delta":",","item_id":"msg_00ab7a8a15e8d501016abc9387f954819696764c6c49b1c96c","logprobs":[],"obfuscation":"hGeJC00Eg384jJq","output_index":1,"sequence_number":10}
|
|
91
|
+
|
|
92
|
+
event: response.output_text.delta
|
|
93
|
+
data: {"type":"response.output_text.delta","content_index":0,"delta":" ","item_id":"msg_00ab7a8a15e8d501016abc9387f954819696764c6c49b1c96c","logprobs":[],"obfuscation":"Zg67z5u4jqzjMnn","output_index":1,"sequence_number":11}
|
|
94
|
+
|
|
95
|
+
event: response.output_text.delta
|
|
96
|
+
data: {"type":"response.output_text.delta","content_index":0,"delta":"3","item_id":"msg_00ab7a8a15e8d501016abc9387f954819696764c6c49b1c96c","logprobs":[],"obfuscation":"0LtEfJpIzld2BOv","output_index":1,"sequence_number":12}
|
|
97
|
+
|
|
98
|
+
event: response.output_text.done
|
|
99
|
+
data: {"type":"response.output_text.done","content_index":0,"item_id":"msg_00ab7a8a15e8d501016abc9387f954819696764c6c49b1c96c","logprobs":[],"output_index":1,"sequence_number":13,"text":"1, 2, 3"}
|
|
100
|
+
|
|
101
|
+
event: response.content_part.done
|
|
102
|
+
data: {"type":"response.content_part.done","content_index":0,"item_id":"msg_00ab7a8a15e8d501016abc9387f954819696764c6c49b1c96c","output_index":1,"part":{"type":"output_text","annotations":[],"logprobs":[],"text":"1, 2, 3"},"sequence_number":14}
|
|
103
|
+
|
|
104
|
+
event: response.output_item.done
|
|
105
|
+
data: {"type":"response.output_item.done","item":{"id":"msg_00ab7a8a15e8d501016abc9387f954819696764c6c49b1c96c","type":"message","status":"completed","content":[{"type":"output_text","annotations":[],"logprobs":[],"text":"1, 2, 3"}],"phase":"final_answer","role":"assistant"},"output_index":1,"sequence_number":15}
|
|
106
|
+
|
|
107
|
+
event: response.completed
|
|
108
|
+
data: {"type":"response.completed","response":{"id":"resp_00ab7a8a15e8d501016abc93873edc8196a31c110964bd201d","object":"response","created_at":1790743431,"status":"completed","background":false,"completed_at":1790743432,"content_filters":[{"blocked":false,"source_type":"prompt","content_filter_raw":[],"content_filter_results":{},"content_filter_offsets":{"start_offset":0,"end_offset":795,"check_offset":0}},{"blocked":false,"source_type":"completion","content_filter_raw":[],"content_filter_results":{},"content_filter_offsets":{"start_offset":0,"end_offset":28,"check_offset":0}}],"error":null,"frequency_penalty":0.0,"incomplete_details":null,"instructions":null,"max_output_tokens":null,"max_tool_calls":null,"model":"openai/gpt-6-luna","moderation":null,"output":[{"id":"rs_00ab7a8a15e8d501016abc9387e7ec819681846275c46a31c4","type":"reasoning","content":[],"encrypted_content":"gAAAAABqvJOI_kY8RC0uU7J8V5fNLbukD2k2N8JGLzSctyKwVmjoNUgsnHCsaFUbvQCsL48X3ncASVaoXzmmQGZYyAezAPZWSan8JueZ4-71ADWVMDQz7FFVIo2d583XzNj_kMyCSPUz0mt501ZIyjrEp4-zj1mCBgm1MGOLPt41o0BS-MF2GLXkeEp3Emb1Tv69ALyAConWWonWb3GQ3UT4vMC-GiiYXzqNoMc-jhKSoEmKq_dSGk2tmw0H5xP7EZSEnqgo6_YkeeUtFhLdpKDm-vIETE_1m-wT3AaFsSvs2Z5c8Lrpzoo7wz4EUV9lqmDTZPbmRco_1BINxi9YGjGHrwRIMqAqxTVO-4iwnrAbswnmA3WqmDlymgNx73LZP0n_p1vPAxizvDqTzc8kFaSF6ZMYNqISsU4Qs0xYwsmwlLEiMQvdV6zajKVhqoAXHGXVHw-0ZBHSDmNA72z-H1bHcdJG1aXd6m8CxEzXRkgZnLmQMM5lsnLXtglXkNVgW0zxy-VEpglLasaWlBRxqPi3iqhKOBVIpdg3N4mM9qQvFGYIFWNuyf94Z37wuuoQsq0YA-4G9eTcgZkSNVaxoDXAy8p-B91PV1rRlx0TbL6cGJvizXv54uoUrnmnYWpXeh3coNNN3n10TBipktz-5x8WLOJXwYOfRj1KpUtR2nZGyNBwdQTObEjKMz9dG15-AoSzY2aUXqwCLH5fnG5GaKp2y-yCwrSYL3WOWdZacgYmkONb3sz4gqrAHt_0NsBudHPt7Tk37jr3pS6q7267wP3wV4IPLBsH6EWk-dbhdN6ZwDy8w9SNGjPhRHTQzMrM_X-XtIvxErp8ibxemcQtyeE4y7Qnga-iwt0J73An7KOgb3yKeM1bA5SgZlEs1Flnt-VkqGMIT89Wdsih5tueJ6jedUSmqcUmYsitGDTUGbZ5rxDfx_JeVPDaKpFXdrpOW9-6D9h-EIh7i4qiOv1nExJTqpkA0QGnMOcWXdZHhZNo0JJq_Fwajsx50tgH_f89Zk9XsBwCQ6Er_G2Hq4kC2_R_rmS1_GNUnTrZtb2N0YRDAl4w1b5ZWq5qwqU93PLzbWrXkmJvR7fX4HZJkz7OdaKgMCRNCN8KdVjqTvM4D8EwRtIssTcqfi0A_i5hQgseqOwgraIF8M_-","summary":[]},{"id":"msg_00ab7a8a15e8d501016abc9387f954819696764c6c49b1c96c","type":"message","status":"completed","content":[{"type":"output_text","annotations":[],"logprobs":[],"text":"1, 2, 3"}],"phase":"final_answer","role":"assistant"}],"parallel_tool_calls":true,"presence_penalty":0.0,"previous_response_id":null,"prompt_cache_key":null,"prompt_cache_retention":"24h","reasoning":{"context":"all_turns","effort":"medium","mode":"standard","summary":null},"safety_identifier":null,"service_tier":"default","store":false,"temperature":1.0,"text":{"format":{"type":"text"},"verbosity":"medium"},"tool_choice":"auto","tool_usage":{"image_gen":{"input_tokens":0,"input_tokens_details":{"image_tokens":0,"text_tokens":0},"output_tokens":0,"output_tokens_details":{"image_tokens":0,"text_tokens":0},"total_tokens":0},"web_search":{"num_requests":0}},"tools":[],"top_logprobs":0,"top_p":0.98,"truncation":"disabled","usage":{"input_tokens":13,"input_tokens_details":{"cache_write_tokens":0,"cached_tokens":0},"output_tokens":27,"output_tokens_details":{"reasoning_tokens":14},"total_tokens":40},"user":null,"metadata":{}},"sequence_number":16}
|
|
109
|
+
|
|
110
|
+
recorded_at: Wed, 30 Sep 2026 04:43:52 GMT
|
|
111
|
+
recorded_with: VCR 6.4.0
|
|
112
|
+
...
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RubyLLM::Chat, :live do
|
|
6
|
+
include_context 'with configured RubyLLM'
|
|
7
|
+
|
|
8
|
+
let(:person_schema) do
|
|
9
|
+
{
|
|
10
|
+
type: 'object',
|
|
11
|
+
properties: {
|
|
12
|
+
name: { type: 'string' },
|
|
13
|
+
age: { type: 'integer' }
|
|
14
|
+
},
|
|
15
|
+
required: %w[name age],
|
|
16
|
+
additionalProperties: false
|
|
17
|
+
}
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
each_model(STRUCTURED_OUTPUT_MODELS) do |provider, model|
|
|
21
|
+
it "#{provider}/#{model} returns structured output" do
|
|
22
|
+
response = RubyLLM.chat(model: model, provider: provider, assume_model_exists: true)
|
|
23
|
+
.with_schema(person_schema)
|
|
24
|
+
.ask('Generate a person named John who is 30 years old')
|
|
25
|
+
|
|
26
|
+
expect(response.content).to be_a(String)
|
|
27
|
+
expect(response.parsed).to include('name' => 'John', 'age' => 30)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RubyLLM::Chat, :live do
|
|
6
|
+
include_context 'with configured RubyLLM'
|
|
7
|
+
|
|
8
|
+
each_model(CHAT_MODELS) do |provider, model|
|
|
9
|
+
it "#{provider}/#{model} can have a basic conversation" do
|
|
10
|
+
response = RubyLLM.chat(model: model, provider: provider, assume_model_exists: true).ask("What's 2 + 2?")
|
|
11
|
+
|
|
12
|
+
expect(response.content).to include('4')
|
|
13
|
+
expect(response.role).to eq(:assistant)
|
|
14
|
+
expect(response.tokens.input.to_i).to be_positive
|
|
15
|
+
expect(response.tokens.output.to_i).to be_positive
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "#{provider}/#{model} returns the raw response" do
|
|
19
|
+
response = RubyLLM.chat(model: model, provider: provider, assume_model_exists: true)
|
|
20
|
+
.ask('What is the capital of France?')
|
|
21
|
+
|
|
22
|
+
expect(response.raw.status).to eq(200)
|
|
23
|
+
expect(response.raw.headers).not_to be_empty
|
|
24
|
+
expect(response.raw.body).not_to be_empty
|
|
25
|
+
expect(response.raw.env.request_body).not_to be_empty
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "#{provider}/#{model} can handle a multi-turn conversation" do
|
|
29
|
+
chat = RubyLLM.chat(model: model, provider: provider, assume_model_exists: true)
|
|
30
|
+
|
|
31
|
+
expect(chat.ask('Who created the programming language Ruby?').content).to match(/Matz|Matsumoto/i)
|
|
32
|
+
expect(chat.ask('What year was Ruby first released?').content).to include('199')
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RubyLLM::Chat, :live do
|
|
6
|
+
include_context 'with configured RubyLLM'
|
|
7
|
+
|
|
8
|
+
each_model(CHAT_MODELS) do |provider, model|
|
|
9
|
+
it "#{provider}/#{model} supports streaming responses" do
|
|
10
|
+
chunks = []
|
|
11
|
+
chat = RubyLLM.chat(model: model, provider: provider, assume_model_exists: true)
|
|
12
|
+
|
|
13
|
+
response = chat.ask('Count from 1 to 3') { |chunk| chunks << chunk }
|
|
14
|
+
|
|
15
|
+
expect(chunks).not_to be_empty
|
|
16
|
+
expect(chunks.first).to be_a(RubyLLM::Chunk)
|
|
17
|
+
expect(response.raw.status).to eq(200)
|
|
18
|
+
expect(response.raw.headers).not_to be_empty
|
|
19
|
+
expect(response.raw.env.request_body).not_to be_empty
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RubyLLM::Chat, :live do
|
|
6
|
+
include_context 'with configured RubyLLM'
|
|
7
|
+
|
|
8
|
+
let(:weather_tool) do
|
|
9
|
+
Class.new(RubyLLM::Tool) do
|
|
10
|
+
def self.tool_name = 'weather'
|
|
11
|
+
|
|
12
|
+
description 'Gets current weather for a location'
|
|
13
|
+
parameter :latitude, description: 'Latitude'
|
|
14
|
+
parameter :longitude, description: 'Longitude'
|
|
15
|
+
|
|
16
|
+
def execute(latitude:, longitude:)
|
|
17
|
+
"Current weather at #{latitude}, #{longitude}: 15°C, Wind: 10 km/h"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
each_model(TOOL_MODELS) do |provider, model|
|
|
23
|
+
it "#{provider}/#{model} can use tools" do
|
|
24
|
+
chat = RubyLLM.chat(model: model, provider: provider, assume_model_exists: true).with_tools(weather_tool)
|
|
25
|
+
response = chat.ask("What's the weather in Berlin? Use 52.5200, 13.4050.")
|
|
26
|
+
|
|
27
|
+
expect(response.content).to include('15')
|
|
28
|
+
expect(response.content).to include('10')
|
|
29
|
+
expect(chat.messages.any?(&:tool_call?)).to be(true)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RubyLLM::Embedding, :live do
|
|
6
|
+
include_context 'with configured RubyLLM'
|
|
7
|
+
|
|
8
|
+
each_model(EMBEDDING_MODELS) do |provider, model, model_info|
|
|
9
|
+
it "#{provider}/#{model} embeds one text" do
|
|
10
|
+
embedding = RubyLLM.embed(
|
|
11
|
+
"Ruby is a programmer's best friend",
|
|
12
|
+
model: model,
|
|
13
|
+
provider: provider,
|
|
14
|
+
assume_model_exists: true
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
expect(embedding.vectors).to be_an(Array)
|
|
18
|
+
expect(embedding.vectors.first).to be_a(Numeric)
|
|
19
|
+
expect(embedding.model).to eq(model)
|
|
20
|
+
expect(embedding.tokens.input.to_i).to be >= 0
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "#{provider}/#{model} embeds several texts" do
|
|
24
|
+
embeddings = RubyLLM.embed(
|
|
25
|
+
%w[Ruby Python JavaScript],
|
|
26
|
+
model: model,
|
|
27
|
+
provider: provider,
|
|
28
|
+
assume_model_exists: true
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
expect(embeddings.vectors.size).to eq(3)
|
|
32
|
+
expect(embeddings.vectors).to all(be_an(Array))
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
next unless model_info[:dimensions]
|
|
36
|
+
|
|
37
|
+
it "#{provider}/#{model} supports custom dimensions" do
|
|
38
|
+
embedding = RubyLLM.embed(
|
|
39
|
+
'Ruby',
|
|
40
|
+
model: model,
|
|
41
|
+
provider: provider,
|
|
42
|
+
assume_model_exists: true,
|
|
43
|
+
dimensions: model_info[:dimensions]
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
expect(embedding.vectors.length).to eq(model_info[:dimensions])
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RubyLLM::Image, :live do
|
|
6
|
+
include_context 'with configured RubyLLM'
|
|
7
|
+
|
|
8
|
+
each_model(IMAGE_GENERATION_MODELS) do |provider, model, model_info|
|
|
9
|
+
it "#{provider}/#{model} paints an image" do
|
|
10
|
+
image = RubyLLM.paint(
|
|
11
|
+
'a siamese cat',
|
|
12
|
+
model: model,
|
|
13
|
+
provider: provider,
|
|
14
|
+
assume_model_exists: true,
|
|
15
|
+
provider_options: model_info.fetch(:provider_options, {})
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
expect(image.mime_type).to include('image')
|
|
19
|
+
expect(image.model).to eq(model)
|
|
20
|
+
expect(image.to_blob.bytesize).to be > 1000
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RubyLLM::Models do
|
|
6
|
+
include_context 'with configured RubyLLM'
|
|
7
|
+
|
|
8
|
+
it 'expects generated providers to add registry metadata before use' do
|
|
9
|
+
expect(RubyLLM::Providers::Qiniu.assume_models_exist?).to be(false)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RubyLLM::Moderation, :live do
|
|
6
|
+
include_context 'with configured RubyLLM'
|
|
7
|
+
|
|
8
|
+
each_model(MODERATION_MODELS) do |provider, model|
|
|
9
|
+
it "#{provider}/#{model} moderates content" do
|
|
10
|
+
moderation = RubyLLM.moderate(
|
|
11
|
+
'This is a safe message',
|
|
12
|
+
model: model,
|
|
13
|
+
provider: provider,
|
|
14
|
+
assume_model_exists: true
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
expect(moderation).to be_a(described_class)
|
|
18
|
+
expect(moderation.results).to all(be_a(RubyLLM::Moderation::Result))
|
|
19
|
+
expect(moderation.flagged?).to be_in([true, false])
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RubyLLM::Providers::Qiniu do
|
|
6
|
+
subject(:provider) { described_class.new(config) }
|
|
7
|
+
|
|
8
|
+
let(:config) do
|
|
9
|
+
RubyLLM::Configuration.new.tap do |provider_config|
|
|
10
|
+
provider_config.qiniu_api_key = 'test-key'
|
|
11
|
+
provider_config.qiniu_api_base = 'https://example.test'
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'is registered with RubyLLM' do
|
|
16
|
+
expect(RubyLLM::Provider.resolve(:qiniu)).to eq(described_class)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'registers the documented access protocols' do
|
|
20
|
+
expect(described_class.protocols.keys).to eq(
|
|
21
|
+
%i[chat_completions anthropic responses anthropic_bypass gemini_bypass]
|
|
22
|
+
)
|
|
23
|
+
expect(described_class.default_protocol).to eq(:chat_completions)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'declares provider configuration' do
|
|
27
|
+
expect(described_class.configuration_options).to eq(%i[qiniu_api_key qiniu_api_base])
|
|
28
|
+
expect(described_class.configuration_requirements).to eq(%i[qiniu_api_key])
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'uses configured API base and bearer token' do
|
|
32
|
+
expect(provider.api_base).to eq('https://example.test')
|
|
33
|
+
expect(provider.headers).to eq('Authorization' => 'Bearer test-key')
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'defaults to the mainland China endpoint' do
|
|
37
|
+
config.qiniu_api_base = nil
|
|
38
|
+
expect(provider.api_base).to eq('https://api.qnaigc.com')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'uses the configured base URL verbatim' do
|
|
42
|
+
config.qiniu_api_base = 'https://api.modelink.ai/v1'
|
|
43
|
+
expect(provider.api_base).to eq('https://api.modelink.ai/v1')
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe 'protocol paths' do
|
|
47
|
+
let(:model) { RubyLLM::Model.new(id: 'deepseek-v3', provider: :qiniu) }
|
|
48
|
+
|
|
49
|
+
def url_for(protocol_name, seam, model: self.model)
|
|
50
|
+
described_class.protocols[protocol_name].new(provider, model).send(seam)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'serves the OpenAI-compatible dialect under /v1' do
|
|
54
|
+
expect(url_for(:chat_completions, :completion_url)).to eq('v1/chat/completions')
|
|
55
|
+
expect(url_for(:chat_completions, :models_url)).to eq('v1/models')
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'serves Anthropic-compatible messages at /v1/messages' do
|
|
59
|
+
expect(url_for(:anthropic, :completion_url)).to eq('v1/messages')
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'serves native bypass endpoints under /bypass' do
|
|
63
|
+
expect(url_for(:anthropic_bypass, :completion_url)).to eq('bypass/anthropic/v1/messages')
|
|
64
|
+
expect(url_for(:responses, :completion_url)).to eq('bypass/openai/v1/responses')
|
|
65
|
+
|
|
66
|
+
gemini = RubyLLM::Model.new(id: 'gemini-3.1-pro-preview', provider: :qiniu)
|
|
67
|
+
expect(url_for(:gemini_bypass, :completion_url, model: gemini))
|
|
68
|
+
.to eq('bypass/vertex/v1/models/gemini-3.1-pro-preview:generateContent')
|
|
69
|
+
expect(url_for(:gemini_bypass, :stream_url, model: gemini))
|
|
70
|
+
.to eq('bypass/vertex/v1/models/gemini-3.1-pro-preview:streamGenerateContent?alt=sse')
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
describe 'protocol routing' do
|
|
75
|
+
it 'prefers the vendor-native bypass channel for chat' do
|
|
76
|
+
{
|
|
77
|
+
'claude-4.6-sonnet' => :anthropic_bypass,
|
|
78
|
+
'anthropic/claude-4.5-haiku' => :anthropic_bypass,
|
|
79
|
+
'gemini-3.1-pro-preview' => :gemini_bypass,
|
|
80
|
+
'gpt-5.2' => :responses,
|
|
81
|
+
'openai/o4-mini' => :responses
|
|
82
|
+
}.each do |model_id, protocol|
|
|
83
|
+
model = RubyLLM::Model.new(id: model_id, provider: :qiniu)
|
|
84
|
+
expect(provider.protocol_for(model)).to(
|
|
85
|
+
eq(described_class.protocols[protocol]), "#{model_id} should route to #{protocol}"
|
|
86
|
+
)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'keeps other models on the OpenAI-compatible dialect' do
|
|
91
|
+
other = RubyLLM::Model.new(id: 'deepseek-v3', provider: :qiniu)
|
|
92
|
+
expect(provider.protocol_for(other)).to eq(described_class.protocols[:chat_completions])
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it 'keeps auxiliary operations on the compatible layout' do
|
|
96
|
+
gemini = RubyLLM::Model.new(id: 'gemini-3.1-pro-preview', provider: :qiniu)
|
|
97
|
+
%i[embed paint speak transcribe animate].each do |operation|
|
|
98
|
+
expect(provider.protocol_for(gemini, operation:))
|
|
99
|
+
.to eq(described_class.protocols[:chat_completions])
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|