Documentation
¶
Overview ¶
Example ¶
Example demonstrates basic usage of the fake provider.
ctx := context.Background()
p := NewProvider()
stream, err := p.CreateStream(ctx, llm.StreamOptions{
Model: "fake-model",
Messages: llm.Messages{
&llm.UserMsg{Content: "Hello!"},
},
})
if err != nil {
panic(err)
}
for event := range stream {
switch event.Type {
case llm.StreamEventDelta:
// Handle text response
_ = event.Delta
case llm.StreamEventToolCall:
// Handle tool invocation
_ = event.ToolCall
case llm.StreamEventDone:
// Stream complete
return
case llm.StreamEventError:
panic(event.Error)
}
}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is a test-only provider that returns a single tool call on the first request and a text-only response on subsequent requests.
func (*Provider) CreateStream ¶
func (f *Provider) CreateStream(_ context.Context, opts llm.StreamOptions) (<-chan llm.StreamEvent, error)
Click to show internal directories.
Click to hide internal directories.