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 useGOLLM_API_KEY
: Your API key for the chosen providerGOLLM_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.
Last updated
Was this helpful?