Skip to content

Commit dfbc6b3

Browse files
committed
Updated to explain the WithFormat
1 parent 3d132af commit dfbc6b3

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,14 @@ func completion(ctx context.Context, agent llm.Agent) (string, error) {
159159
}
160160
```
161161

162-
The zero index argument on `completion.Text(int)` indicates you want the text from the zero'th completion
163-
choice, for providers who can generate serveral different choices simultaneously.
162+
The zero index argument on `completion.Text(int)` indicates you want the text from the zero'th completion choice, for providers who can generate serveral different choices simultaneously.
163+
164+
Use one of the following options as an argument to the `Completion` method to customize the output format of the completion, which needs to be paired with the right model:
165+
166+
* `llm.WithFormat("text")` - Generate text output (default).
167+
* `llm.WithFormat("json")` - Generate JSON output.
168+
* `llm.WithFormat("image", "jpeg")` - Generate JPEG image output (for models which support it).
169+
* `llm.WithFormat("audio", "mp3")` - Generate audio output (for models which support it). Possible values are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.
164170

165171
### Chat Sessions
166172

model.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ type Model interface {
2121
// session options
2222
Context(...Opt) Context
2323

24-
// Create a completion from a text prompt
24+
// Create a completion from a text prompt, including image
25+
// and audio (TTS) generation
2526
Completion(context.Context, string, ...Opt) (Completion, error)
2627

2728
// Embedding vector generation

0 commit comments

Comments
 (0)