From 1b9a8f319c35f7a509b9d0754e1d218c05de5388 Mon Sep 17 00:00:00 2001 From: Matt Low Date: Mon, 29 Apr 2024 06:16:41 +0000 Subject: [PATCH] Split anthropic types out to types.go --- pkg/lmcli/provider/anthropic/anthropic.go | 37 ----------------------- pkg/lmcli/provider/anthropic/tools.go | 2 ++ pkg/lmcli/provider/anthropic/types.go | 37 +++++++++++++++++++++++ 3 files changed, 39 insertions(+), 37 deletions(-) create mode 100644 pkg/lmcli/provider/anthropic/types.go diff --git a/pkg/lmcli/provider/anthropic/anthropic.go b/pkg/lmcli/provider/anthropic/anthropic.go index 2aa7164..ecf6674 100644 --- a/pkg/lmcli/provider/anthropic/anthropic.go +++ b/pkg/lmcli/provider/anthropic/anthropic.go @@ -15,43 +15,6 @@ import ( "git.mlow.ca/mlow/lmcli/pkg/lmcli/tools" ) -type AnthropicClient struct { - APIKey string -} - -type Message struct { - Role string `json:"role"` - Content string `json:"content"` -} - -type Request struct { - Model string `json:"model"` - Messages []Message `json:"messages"` - System string `json:"system,omitempty"` - MaxTokens int `json:"max_tokens,omitempty"` - StopSequences []string `json:"stop_sequences,omitempty"` - Stream bool `json:"stream,omitempty"` - Temperature float32 `json:"temperature,omitempty"` - //TopP float32 `json:"top_p,omitempty"` - //TopK float32 `json:"top_k,omitempty"` -} - -type OriginalContent struct { - Type string `json:"type"` - Text string `json:"text"` -} - -type Response struct { - Id string `json:"id"` - Type string `json:"type"` - Role string `json:"role"` - Content []OriginalContent `json:"content"` - StopReason string `json:"stop_reason"` - StopSequence string `json:"stop_sequence"` -} - -const FUNCTION_STOP_SEQUENCE = "" - func buildRequest(params model.RequestParameters, messages []model.Message) Request { requestBody := Request{ Model: params.Model, diff --git a/pkg/lmcli/provider/anthropic/tools.go b/pkg/lmcli/provider/anthropic/tools.go index 2d91504..d2faa4d 100644 --- a/pkg/lmcli/provider/anthropic/tools.go +++ b/pkg/lmcli/provider/anthropic/tools.go @@ -9,6 +9,8 @@ import ( "git.mlow.ca/mlow/lmcli/pkg/lmcli/model" ) +const FUNCTION_STOP_SEQUENCE = "" + const TOOL_PREAMBLE = `You have access to the following tools when replying. You may call them like this: diff --git a/pkg/lmcli/provider/anthropic/types.go b/pkg/lmcli/provider/anthropic/types.go new file mode 100644 index 0000000..54b03ed --- /dev/null +++ b/pkg/lmcli/provider/anthropic/types.go @@ -0,0 +1,37 @@ +package anthropic + +type AnthropicClient struct { + APIKey string +} + +type Message struct { + Role string `json:"role"` + Content string `json:"content"` +} + +type Request struct { + Model string `json:"model"` + Messages []Message `json:"messages"` + System string `json:"system,omitempty"` + MaxTokens int `json:"max_tokens,omitempty"` + StopSequences []string `json:"stop_sequences,omitempty"` + Stream bool `json:"stream,omitempty"` + Temperature float32 `json:"temperature,omitempty"` + //TopP float32 `json:"top_p,omitempty"` + //TopK float32 `json:"top_k,omitempty"` +} + +type OriginalContent struct { + Type string `json:"type"` + Text string `json:"text"` +} + +type Response struct { + Id string `json:"id"` + Type string `json:"type"` + Role string `json:"role"` + Content []OriginalContent `json:"content"` + StopReason string `json:"stop_reason"` + StopSequence string `json:"stop_sequence"` +} +