You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -396,7 +396,7 @@ created with `new_chat_session`
396
396
The field `messages` stores an array of chat messages representing the chat
397
397
history. Each message object must conform to the following structure:
398
398
399
-
-`role`: A string representing the role of the message sender. It must be one of the following values: "system", "user", or "assistant".
399
+
-`role`: A string representing the role of the message sender. It must be one of the following values: `"system"`, `"user"`, `"assistant"`, `"function"` (legacy), or `"tool"` (for tool call results).
400
400
-`content`: A string containing the content of the message.
401
401
-`name`: An optional string representing the name of the message sender. If not provided, it should be `nil`.
402
402
@@ -440,9 +440,10 @@ Appends a message to the chat history and triggers a completion with
440
440
`generate_response` and returns the response as a string. On failure, returns
441
441
`nil`, an error message, and the raw request response.
442
442
443
-
If the response includes a `function_call`, then the entire message object is
444
-
returned instead of a string of the content. You can return the result of the
445
-
function by passing `role = "function"` object to the `send` method
443
+
If the response includes `tool_calls` or a `function_call`, the entire message
444
+
object is returned instead of a string. You can send the result back by passing
445
+
a `role = "tool"` message (with `tool_call_id`) or a `role = "function"` message
446
+
(legacy) to the `send` method.
446
447
447
448
-`message`: A message object or a string.
448
449
-`stream_callback`: (optional) A function to enable streaming output.
@@ -558,8 +559,9 @@ including chat completions, chat sessions, and streaming.
558
559
559
560
OpenAI's [tool calling
560
561
API](https://platform.openai.com/docs/guides/function-calling) allows models to
561
-
request function calls during a conversation. The chat session manages the
562
-
back-and-forth of tool calls and results automatically.
562
+
request function calls during a conversation. When a tool call is requested, the
563
+
response contains the tool call details instead of a text string. You can then
564
+
execute the function and send the result back to continue the conversation.
0 commit comments