Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

fix: expose input and output for anthropic for instill credit #190

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ai/anthropic/v0/component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ func TestComponent_Generation(t *testing.T) {

tc := struct {
input map[string]any
wantResp messagesOutput
wantResp MessagesOutput
}{
input: map[string]any{"prompt": "Hi! What's your name?", "chat-history": mockHistory},
wantResp: messagesOutput{
wantResp: MessagesOutput{
Text: "Hi! My name is Claude. (messageCount: 3)",
Usage: messagesUsage{
InputTokens: 10,
Expand Down
16 changes: 14 additions & 2 deletions ai/anthropic/v0/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,19 @@ type messagesReq struct {
TopP float32 `json:"top_p,omitempty"`
}

type messagesOutput struct {
type MessagesInput struct {
jvallesm marked this conversation as resolved.
Show resolved Hide resolved
ChatHistory []message `json:"chat-history"`
MaxNewTokens int `json:"max-new-tokens"`
ModelName string `json:"model-name"`
Prompt string `json:"prompt"`
PromptImages []interface{} `json:"prompt-images"`
Seed int `json:"seed"`
SystemMsg string `json:"system-message"`
Temperature float32 `json:"temperature"`
TopK int `json:"top-k"`
}

type MessagesOutput struct {
Text string `json:"text"`
Usage messagesUsage `json:"usage"`
}
Expand Down Expand Up @@ -273,7 +285,7 @@ func (e *execution) generateText(in *structpb.Struct) (*structpb.Struct, error)
return nil, err
}

outputStruct := messagesOutput{
outputStruct := MessagesOutput{
Text: "",
Usage: messagesUsage{
InputTokens: resp.Usage.InputTokens,
Expand Down
Loading