Basic usage

Basic Usage of gollm

gollm provides a straightforward way to interact with language models. Here are some basic usage patterns:

Creating an LLM Instance

llm, err := gollm.NewLLM(
	gollm.SetProvider("openai"),
	gollm.SetModel("gpt-4o-mini"),
	gollm.SetAPIKey("your-api-key-here"),
)

Creating a Prompt

prompt := gollm.NewPrompt("Summarize the main points of the given text.",
	gollm.WithContext("The text is about climate change."),
	gollm.WithMaxLength(100),
)

Generating a Response

response, err := llm.Generate(context.Background(), prompt)
if err != nil {
	log.Fatalf("Failed to generate response: %v", err)
}
fmt.Println(response)

These basic patterns will help you get started with gollm. As you become more familiar with the package, you can explore its more advanced features.

Last updated