|
|
|
|
|
by huac
1066 days ago
|
|
I've written a version of this in Golang (tied to OpenAI API, mostly): https://github.com/stillmatic/gollum/blob/main/dispatch.go Define a struct and tag it with golang's json comments. Then, give it a prompt and ... type dinnerParty struct {
Topic string `json:"topic" jsonschema:"required" jsonschema_description:"The topic of the conversation"`
RandomWords []string `json:"random_words" jsonschema:"required" jsonschema_description:"Random words to prime the conversation"`
}
completer := openai.NewClient(os.Getenv("OPENAI_API_KEY"))
d := gollum.NewOpenAIDispatcher[dinnerParty]("dinner_party", "Given a topic, return random words", completer, nil)
output, _ := d.Prompt(context.Background(), "Talk to me about dinosaurs")
and you should get a response like expected := dinnerParty{
Topic: "dinosaurs",
RandomWords: []string{"dinosaur", "fossil", "extinct"},
}
|
|