Skip to content

Commit 018838e

Browse files
committed
clear up more info about tool calliing in the readme
1 parent b0c369f commit 018838e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ created with `new_chat_session`
396396
The field `messages` stores an array of chat messages representing the chat
397397
history. Each message object must conform to the following structure:
398398

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).
400400
- `content`: A string containing the content of the message.
401401
- `name`: An optional string representing the name of the message sender. If not provided, it should be `nil`.
402402

@@ -440,9 +440,10 @@ Appends a message to the chat history and triggers a completion with
440440
`generate_response` and returns the response as a string. On failure, returns
441441
`nil`, an error message, and the raw request response.
442442

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.
446447

447448
- `message`: A message object or a string.
448449
- `stream_callback`: (optional) A function to enable streaming output.
@@ -558,8 +559,9 @@ including chat completions, chat sessions, and streaming.
558559

559560
OpenAI's [tool calling
560561
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.
563565

564566
```lua
565567
local openai = require("openai")

0 commit comments

Comments
 (0)