gollm
  • Introduction
  • Getting started
    • Getting started
    • Basic usage
    • Configuration
    • Memory
    • Examples inside Prompts
  • Prompt-template
    • Sumarize
    • Question Answering
    • Chain of Thought
    • Structured Output
  • advanced features
    • Advanced features
    • Prompt engineering
    • Comparison
    • JSON output validation
    • Prompt Optimization
  • Examples
    • Example
    • 1. Basic usage
    • 2. Prompt types
    • 3. Compare providers
    • 4. Custom config
    • 5. Advanced Prompt
    • 6. Structured output
    • 7. Structured output comparison
    • 8. Content creation workflo
    • Ollama Example
    • Prompt Optimizer
    • Batch Prompt Optimizer
  • API reference
  • FAQ
Powered by GitBook
On this page

Was this helpful?

  1. Getting started

Configuration

Configuring gollm

gollm offers flexible configuration options to customize your LLM interactions. Here are the main ways to configure gollm:

Environment Variables

You can set the following environment variables:

  • GOLLM_PROVIDER: The default LLM provider (e.g., "openai", "anthropic")

  • GOLLM_MODEL: The default model to use

  • GOLLM_API_KEY: Your API key for the chosen provider

  • GOLLM_MAX_TOKENS: Maximum number of tokens for the response

Code-based Configuration

Use configuration options when creating a new LLM instance:

llm, err := gollm.NewLLM(
	gollm.SetProvider("anthropic"),
	gollm.SetModel("claude-3-5-sonnet-20240620"),
	gollm.SetAPIKey("your-api-key"),
	gollm.SetMaxTokens(150),
)

Configuration File

You can also use a JSON configuration file:

{
  "provider": "openai",
  "model": "gpt-4o-mini",
  "api_key": "your-api-key",
  "max_tokens": 100
}

Load the configuration file in your code:

config, err := gollm.LoadConfig("path/to/config.json")
if err != nil {
	log.Fatalf("Failed to load config: %v", err)
}

llm, err := gollm.NewLLM(config)

Choose the configuration method that best suits your project's needs and structure.

PreviousBasic usageNextMemory

Last updated 9 months ago

Was this helpful?