langchaingo-llm-bedrock

for github.com/tmc/langchaingo Amazon Bedrock LLM interface implement

GoDoc Go Report Card License

Example

package main

import (
	"context"
	_ "embed"
	"log"

	bedrock "github.com/mashiike/langchaingo-llm-bedrock"
	"github.com/tmc/langchaingo/llms"
	"github.com/tmc/langchaingo/schema"
)

//go:embed image.png
var image []byte

func main() {
	llm, err := bedrock.New(
		bedrock.WithModel(bedrock.Claude3Haiku),
	)
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	resp, err := llm.GenerateContent(ctx, []llms.MessageContent{
		{
			Role: schema.ChatMessageTypeHuman,
			Parts: []llms.ContentPart{
				llms.BinaryPart("image/png", image),
				llms.TextPart("この画像に書かれている内容をテキストにしてください。"),
			},
		},
	})
	if err != nil {
		log.Fatal(err)
	}
	for _, choice := range resp.Choices {
		log.Println(choice.Content)
	}
}

License

MIT License