Skip to content

Commit 7681c18

Browse files
committed
Merge branch 'master' into ai-ext-openai-stream-fix
2 parents 4d9186d + 1d58f10 commit 7681c18

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3764
-598
lines changed

docs/reference/ai/http.rst

Lines changed: 102 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@ Request headers
2929
Request body
3030
------------
3131

32-
* ``input`` (array of strings or a single string, required): The text to use as
33-
the basis for embeddings generation.
34-
32+
* ``inputs`` (array of strings, or single string, required): The text items to use as the basis
33+
for embeddings generation.
3534
* ``model`` (string, required): The name of the embedding model to use. You may
3635
use any of the supported :ref:`embedding models
3736
<ref_ai_extai_reference_embedding_models>`.
38-
3937
* ``dimensions`` (number, optional): The number of dimensions to truncate to.
4038

4139
* ``user`` (string, optional): A user identifier for the request.
@@ -47,7 +45,7 @@ Example request
4745
.. code-block:: bash
4846
4947
$ curl --user <username>:<password> --json '{\
50-
"input": "What color is the sky on Mars?",\
48+
"inputs": ["What color is the sky on Mars?"],\
5149
"model": "text-embedding-3-small"\
5250
}' http://localhost:10931/branch/main/ai/embeddings
5351
@@ -134,9 +132,13 @@ Request body
134132
* ``id`` (string, optional): ID of predefined prompt.
135133
* ``custom`` (array of objects, optional): Custom prompt messages, each containing a ``role`` and ``content``. If no ``name`` or ``id`` was provided, the custom messages provided here become the prompt. If one of those was provided, these messages will be added to that existing prompt.
136134
* ``role`` (string): "system", "user", "assistant", or "tool".
137-
* ``content`` (string|object): Content of the message.
138-
* ``tool_call_id`` (string): Identifier for tool call.
139-
* ``tool_calls`` (array): Array of tool calls.
135+
* ``content`` (string | array): Content of the message.
136+
* For ``role: "system"``: Must be a string.
137+
* For ``role: "user"``: Must be an array of content blocks, e.g., ``[{"type": "text", "text": "..."}]``.
138+
* For ``role: "assistant"``: Must be a string (the assistant's text response). May optionally include ``tool_calls``.
139+
* For ``role: "tool"``: Must be a string (the result of the tool call). Requires ``tool_call_id``.
140+
* ``tool_call_id`` (string, optional): Identifier for the tool call whose result this message represents (required if ``role: "tool"``).
141+
* ``tool_calls`` (array, optional): Array of tool calls requested by the assistant (used if ``role: "assistant"``). Each object should follow the format: ``{"id": "...", "type": "function", "function": {"name": "...", "arguments": "..."}}``. Arguments should be a JSON string.
140142

141143
* ``temperature`` (number, optional): Sampling temperature.
142144

@@ -156,6 +158,11 @@ Request body
156158

157159
* ``user`` (string, optional): User identifier.
158160

161+
* ``tools`` (array, optional): A list of tools the model may call. Each tool
162+
has a ``type`` ("function") and a ``function`` object with ``name``,
163+
``description`` (optional), and ``parameters`` (JSON schema). Example:
164+
``[{"type": "function", "function": {"name": "get_weather", "description": "Get the current weather", "parameters": {"type": "object", "properties": {"location": {"type": "string"}}, "required": ["location"]}}}]``
165+
159166

160167
Example request
161168
---------------
@@ -174,11 +181,32 @@ Response
174181

175182
* **HTTP status**: 200 OK
176183
* **Content-Type**: application/json
177-
* **Body**:
184+
* **Body**: A JSON object containing the RAG response details.
178185

179186
.. code-block:: json
180187
181-
{"response": "The sky on Mars is red."}
188+
{
189+
"id": "chatcmpl-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
190+
"model": "gpt-4-turbo-preview",
191+
"text": "The sky on Mars typically appears butterscotch or reddish due to the fine dust particles suspended in the atmosphere.",
192+
"finish_reason": "stop",
193+
"usage": {
194+
"prompt_tokens": 50,
195+
"completion_tokens": 30,
196+
"total_tokens": 80
197+
},
198+
"logprobs": null,
199+
"tool_calls": null
200+
}
201+
202+
* ``id`` (string): Unique identifier for the chat completion.
203+
* ``model`` (string): The model used for the chat completion.
204+
* ``text`` (string | null): The main text content of the response message.
205+
* ``finish_reason`` (string | null): The reason the model stopped generating tokens (e.g., "stop", "length", "tool_calls").
206+
* ``usage`` (object | null): Token usage statistics for the request.
207+
* ``logprobs`` (object | null): Log probability information for the generated tokens (if requested).
208+
* ``tool_calls`` (array | null): Any tool calls requested by the model. Each element contains ``id``, ``type`` ("function"), ``name``, and ``args`` (parsed JSON object).
209+
182210

183211
Error response
184212
--------------
@@ -215,7 +243,7 @@ the response in a structured format:
215243

216244
* Event type: ``message_start``
217245

218-
* Data: Starts a message, specifying identifiers and roles.
246+
* Data: Starts a message, specifying identifiers, roles, and initial usage.
219247

220248
.. code-block:: json
221249
@@ -224,15 +252,16 @@ the response in a structured format:
224252
"message": {
225253
"id": "<message_id>",
226254
"role": "assistant",
227-
"model": "<model_name>"
255+
"model": "<model_name>",
256+
"usage": { "prompt_tokens": 10 }
228257
}
229258
}
230259
231260
2. **Content block start**
232261

233262
* Event type: ``content_block_start``
234263

235-
* Data: Marks the beginning of a new content block.
264+
* Data: Marks the beginning of a new content block (either text or a tool call).
236265

237266
.. code-block:: json
238267
@@ -245,12 +274,27 @@ the response in a structured format:
245274
}
246275
}
247276
277+
Or for a tool call:
278+
279+
.. code-block:: json
280+
281+
{
282+
"type": "content_block_start",
283+
"index": 0,
284+
"content_block": {
285+
"id": "<tool_call_id>",
286+
"type": "tool_use",
287+
"name": "<function_name>",
288+
"args": "{..."
289+
}
290+
}
291+
292+
248293
3. **Content block delta**
249294

250295
* Event type: ``content_block_delta``
251296

252-
* Data: Incrementally updates the content, appending more text to the
253-
message.
297+
* Data: Incrementally updates the content, appending more text or tool arguments. Includes logprobs if requested.
254298

255299
.. code-block:: json
256300
@@ -260,10 +304,24 @@ the response in a structured format:
260304
"delta": {
261305
"type": "text_delta",
262306
"text": "The"
263-
}
307+
},
308+
"logprobs": null
264309
}
265310
266-
Subsequent ``content_block_delta`` events add more text to the message.
311+
Or for tool arguments:
312+
313+
.. code-block:: json
314+
315+
{
316+
"type": "content_block_delta",
317+
"index": 0,
318+
"delta": {
319+
"type": "tool_call_delta",
320+
"args": "{\"location"
321+
}
322+
}
323+
324+
Subsequent ``content_block_delta`` events add more text/arguments to the message.
267325

268326
4. **Content block stop**
269327

@@ -278,7 +336,24 @@ the response in a structured format:
278336
"index": 0
279337
}
280338
281-
5. **Message stop**
339+
5. **Message delta**
340+
341+
* Event type: ``message_delta``
342+
343+
* Data: Provides final message-level updates like the stop reason and final usage statistics.
344+
345+
.. code-block:: json
346+
347+
{
348+
"type": "message_delta",
349+
"delta": {
350+
"stop_reason": "stop"
351+
},
352+
"usage": { "prompt_tokens": 10 }
353+
}
354+
355+
356+
6. **Message stop**
282357

283358
* Event type: ``message_stop``
284359

@@ -298,37 +373,37 @@ stream.
298373
:class: collapsible
299374
300375
event: message_start
301-
data: {"type": "message_start", "message": {"id": "chatcmpl-9MzuQiF0SxUjFLRjIdT3mTVaMWwiv", "role": "assistant", "model": "gpt-4-0125-preview"}}
376+
data: {"type": "message_start", "message": {"id": "chatcmpl-9MzuQiF0SxUjFLRjIdT3mTVaMWwiv", "role": "assistant", "model": "gpt-4-0125-preview", "usage": {"prompt_tokens": 10}}}
302377
303378
event: content_block_start
304379
data: {"type": "content_block_start","index":0,"content_block":{"type":"text","text":""}}
305380
306381
event: content_block_delta
307-
data: {"type": "content_block_delta","index":0,"delta":{"type": "text_delta", "text": "The"}}
382+
data: {"type": "content_block_delta","index":0,"delta":{"type": "text_delta", "text": "The"}, "logprobs": null}
308383
309384
event: content_block_delta
310-
data: {"type": "content_block_delta","index":0,"delta":{"type": "text_delta", "text": " skies"}}
385+
data: {"type": "content_block_delta","index":0,"delta":{"type": "text_delta", "text": " skies"}, "logprobs": null}
311386
312387
event: content_block_delta
313-
data: {"type": "content_block_delta","index":0,"delta":{"type": "text_delta", "text": " on"}}
388+
data: {"type": "content_block_delta","index":0,"delta":{"type": "text_delta", "text": " on"}, "logprobs": null}
314389
315390
event: content_block_delta
316-
data: {"type": "content_block_delta","index":0,"delta":{"type": "text_delta", "text": " Mars"}}
391+
data: {"type": "content_block_delta","index":0,"delta":{"type": "text_delta", "text": " Mars"}, "logprobs": null}
317392
318393
event: content_block_delta
319-
data: {"type": "content_block_delta","index":0,"delta":{"type": "text_delta", "text": " are"}}
394+
data: {"type": "content_block_delta","index":0,"delta":{"type": "text_delta", "text": " are"}, "logprobs": null}
320395
321396
event: content_block_delta
322-
data: {"type": "content_block_delta","index":0,"delta":{"type": "text_delta", "text": " red"}}
397+
data: {"type": "content_block_delta","index":0,"delta":{"type": "text_delta", "text": " red"}, "logprobs": null}
323398
324399
event: content_block_delta
325-
data: {"type": "content_block_delta","index":0,"delta":{"type": "text_delta", "text": "."}}
400+
data: {"type": "content_block_delta","index":0,"delta":{"type": "text_delta", "text": "."}, "logprobs": null}
326401
327402
event: content_block_stop
328403
data: {"type": "content_block_stop","index":0}
329404
330405
event: message_delta
331-
data: {"type": "message_delta", "delta": {"stop_reason": "stop"}}
406+
data: {"type": "message_delta", "delta": {"stop_reason": "stop"}, "usage": {"completion_tokens": 7, "total_tokens": 17}}
332407
333408
event: message_stop
334409
data: {"type": "message_stop"}

docs/reference/auth/index.rst

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,22 +267,38 @@ If you are having trouble receiving webhooks, you might need to look for any res
267267
Configuring SMTP
268268
================
269269

270-
For email-based factors, you can configure SMTP to allow the extension to send
271-
emails on your behalf. You should either configure SMTP, or webhooks for the
272-
relevant events.
273270

274-
Here is an example of configuring SMTP for local development, using something
275-
like `Mailpit <https://mailpit.axllent.org/docs/>`__.
271+
For email-based factors, you can configure SMTP to allow the extension to send emails on your behalf. You should either configure SMTP, or webhooks for the relevant events.
272+
273+
The easiest way to configure SMTP is to use the built-in UI. Here is an example of configuring SMTP for local development using EdgeQL directly, using something like `Mailpit <https://mailpit.axllent.org/docs/>`__.
274+
275+
.. note:: Gel Cloud users, rejoice!
276+
277+
If you are using Gel Cloud, you can use the built-in development SMTP provider without any configuration. This special provider is already configured for development usage and is ready to send emails while you are developing your application. This provider is tuned specifically for development: it is rate limited and the sender is hardcoded. Do not use it in production, it will not work for that purpose.
276278

277279
.. code-block:: edgeql
278280
279-
CONFIGURE CURRENT BRANCH INSERT cfg::SMTPProviderConfig {
281+
# Create a new SMTP provider:
282+
#
283+
configure current branch
284+
insert cfg::SMTPProviderConfig {
285+
# This name must be unique and is used to reference the provider
286+
name := 'local_mailpit',
280287
sender := 'hello@example.com',
281288
host := 'localhost',
282289
port := <int32>1025,
290+
username := 'smtpuser',
291+
password := 'smtppassword',
283292
security := 'STARTTLSOrPlainText',
284293
validate_certs := false,
285-
};
294+
timeout_per_email := <duration>'60 seconds',
295+
timeout_per_attempt := <duration>'15 seconds',
296+
};
297+
298+
# Set this provider as the current email provider by name:
299+
#
300+
configure current branch
301+
set current_email_provider_name := 'local_mailpit';
286302
287303
288304
Enabling authentication providers

docs/reference/using/js/client.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,33 @@ Client Reference
743743
// ...
744744
});
745745
746+
.. js:method:: withWarningHandler(handler: (warnings: errors.GelError[]) => void): Client
747+
748+
Returns a clone of the ``Client`` instance with the specified warning handler. Some queries may generate warnings while still returning a result. The ``handler`` function will be called with an array of ``GelError`` objects whenever the client encounters warnings during query execution.
749+
750+
By default, the warnings are logged to the console with ``console.warn``.
751+
752+
:arg handler: A function that takes an array of ``GelError`` objects as its argument.
753+
754+
:returns: ``Client``
755+
756+
Example:
757+
758+
.. code-block:: typescript
759+
760+
const warningHandler = (warnings: errors.GelError[]) => {
761+
warnings.forEach((gelError) => {
762+
console.warn("Warning:", gelError.message);
763+
});
764+
};
765+
766+
const clientWithWarningHandler = client.withWarningHandler(warningHandler);
767+
768+
await clientWithWarningHandler.query(`
769+
select User filter .friends.name = "John";
770+
`);
771+
// Warning: Gel warning: possibly more than one element returned by an expression in a FILTER clause
772+
746773
.. js:method:: close(): Promise<void>
747774

748775
Close the client's open connections gracefully. When a client is closed, all its underlying connections are awaited to complete their pending operations, then closed. A warning is produced if the pool takes more than 60 seconds to close.

docs/resources/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Resources
66
:maxdepth: 3
77
:hidden:
88

9+
upgrading
910
guides/index
1011
protocol/index
1112
cheatsheets/index
12-
changelog/index
13+
changelog/index

0 commit comments

Comments
 (0)