Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 690 Bytes

README.md

File metadata and controls

39 lines (31 loc) · 690 Bytes

glu

Go LLM Utility

Super simple chat completion support for Ollama, Groq, and OpenAI.

package main

import (
	"fmt"
	l "github.com/pbjer/glu"
)

func main() {
	thread := l.NewThread(
		l.SystemMessage("When the user says 'hello', you say 'world'."),
		l.UserMessage("hello"))

	client := l.NewClient(
		l.OpenAI("gpt-4-turbo"),
		l.WithAPIKey("YOUR-API-KEY"))

	err := client.Generate(thread)
	if err != nil {
		panic(err)
	}
	fmt.Println(thread.LastMessage().Content)
	// world
	
	thread.AddMessages(l.UserMessage("hello"))
	
	err = client.GenerateStream(thread, func(response l.StreamMessage) error {
		fmt.Println(response.Message.Content)
		return nil
	})
	// wor
	// ld
}