2024-09-30 10:14:11 -06:00
|
|
|
package provider
|
2024-02-21 21:55:38 -07:00
|
|
|
|
2024-03-12 12:24:05 -06:00
|
|
|
import (
|
|
|
|
"context"
|
2024-09-30 10:14:11 -06:00
|
|
|
|
|
|
|
"git.mlow.ca/mlow/lmcli/pkg/api"
|
2024-03-12 12:24:05 -06:00
|
|
|
)
|
2024-02-21 21:55:38 -07:00
|
|
|
|
2024-06-08 17:37:58 -06:00
|
|
|
type Chunk struct {
|
2024-06-09 14:45:18 -06:00
|
|
|
Content string
|
|
|
|
TokenCount uint
|
2024-06-08 17:37:58 -06:00
|
|
|
}
|
|
|
|
|
2024-06-12 02:35:07 -06:00
|
|
|
type RequestParameters struct {
|
|
|
|
Model string
|
|
|
|
|
|
|
|
MaxTokens int
|
|
|
|
Temperature float32
|
|
|
|
TopP float32
|
|
|
|
|
2024-09-30 10:14:11 -06:00
|
|
|
Toolbox []api.ToolSpec
|
2024-06-12 02:35:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
type ChatCompletionProvider interface {
|
2024-09-30 11:37:50 -06:00
|
|
|
// CreateChatCompletion generates a chat completion response to the
|
|
|
|
// provided messages.
|
2024-02-21 21:55:38 -07:00
|
|
|
CreateChatCompletion(
|
2024-03-12 12:24:05 -06:00
|
|
|
ctx context.Context,
|
2024-06-12 02:35:07 -06:00
|
|
|
params RequestParameters,
|
2024-09-30 10:14:11 -06:00
|
|
|
messages []api.Message,
|
|
|
|
) (*api.Message, error)
|
2024-02-21 21:55:38 -07:00
|
|
|
|
|
|
|
// Like CreateChageCompletion, except the response is streamed via
|
2024-09-30 11:37:50 -06:00
|
|
|
// the output channel.
|
2024-02-21 21:55:38 -07:00
|
|
|
CreateChatCompletionStream(
|
2024-03-12 12:24:05 -06:00
|
|
|
ctx context.Context,
|
2024-06-12 02:35:07 -06:00
|
|
|
params RequestParameters,
|
2024-09-30 10:14:11 -06:00
|
|
|
messages []api.Message,
|
2024-06-12 02:35:07 -06:00
|
|
|
chunks chan<- Chunk,
|
2024-09-30 10:14:11 -06:00
|
|
|
) (*api.Message, error)
|
2024-06-22 19:46:27 -06:00
|
|
|
}
|