Skip to content

Commit

Permalink
Merge pull request #12 from nbox363/feat/image_to_text_model
Browse files Browse the repository at this point in the history
Add model field to ImageToTextParams
  • Loading branch information
emil14 authored Dec 30, 2024
2 parents 74d611f + 38b0b0d commit 430687f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
7 changes: 4 additions & 3 deletions examples/image_to_text/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
_ "github.com/joho/godotenv/autoload"

"github.com/neurocult/agency"
"github.com/neurocult/agency/providers/openai"
openAIProvider "github.com/neurocult/agency/providers/openai"
"github.com/sashabaranov/go-openai"
)

func main() {
Expand All @@ -17,8 +18,8 @@ func main() {
panic(err)
}

result, err := openai.New(openai.Params{Key: os.Getenv("OPENAI_API_KEY")}).
ImageToText(openai.ImageToTextParams{MaxTokens: 300}).
result, err := openAIProvider.New(openAIProvider.Params{Key: os.Getenv("OPENAI_API_KEY")}).
ImageToText(openAIProvider.ImageToTextParams{Model: openai.GPT4o, MaxTokens: 300}).
SetPrompt("describe what you see").
Execute(
context.Background(),
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/neurocult/agency
go 1.21.0

require (
github.com/sashabaranov/go-openai v1.21.0
github.com/sashabaranov/go-openai v1.36.1
github.com/weaviate/weaviate v1.24.8
github.com/weaviate/weaviate-go-client/v4 v4.13.1
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/sashabaranov/go-openai v1.21.0 h1:isAf3zPSD3VLd0pC2/2Q6ZyRK7jzPAaz+X3rjsviaYQ=
github.com/sashabaranov/go-openai v1.21.0/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
github.com/sashabaranov/go-openai v1.36.1 h1:EVfRXwIlW2rUzpx6vR+aeIKCK/xylSrVYAx1TMTSX3g=
github.com/sashabaranov/go-openai v1.36.1/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/weaviate/weaviate v1.24.8 h1:obeBOJuXScDvUlbTKuqPwJl/cUB5csRhCN6q4smcQiM=
Expand Down
3 changes: 2 additions & 1 deletion providers/openai/image_to_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
)

type ImageToTextParams struct {
Model string
MaxTokens int
Temperature NullableFloat32
TopP NullableFloat32
Expand Down Expand Up @@ -45,7 +46,7 @@ func (f *Provider) ImageToText(params ImageToTextParams) *agency.Operation {

resp, err := f.client.CreateChatCompletion(ctx, openai.ChatCompletionRequest{
MaxTokens: params.MaxTokens,
Model: openai.GPT4Turbo,
Model: params.Model,
Messages: []openai.ChatCompletionMessage{openaiMsg},
Temperature: nullableToFloat32(params.Temperature),
TopP: nullableToFloat32(params.TopP),
Expand Down

0 comments on commit 430687f

Please sign in to comment.