mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-11 03:04:02 +00:00
66ccbe37cd
Show how to use gollem, a production Go agent framework, with LiteLLM proxy for multi-provider LLM access including tool use and streaming.
42 lines
950 B
Go
42 lines
950 B
Go
// Basic gollem agent connected to a LiteLLM proxy.
|
|
//
|
|
// Usage:
|
|
//
|
|
// litellm --model gpt-4o # start proxy in another terminal
|
|
// go run ./basic
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/fugue-labs/gollem/core"
|
|
"github.com/fugue-labs/gollem/provider/openai"
|
|
)
|
|
|
|
func main() {
|
|
proxyURL := "http://localhost:4000"
|
|
if u := os.Getenv("LITELLM_PROXY_URL"); u != "" {
|
|
proxyURL = u
|
|
}
|
|
|
|
// Connect to LiteLLM proxy. NewLiteLLM creates an OpenAI-compatible
|
|
// provider pointed at the given URL.
|
|
model := openai.NewLiteLLM(proxyURL,
|
|
openai.WithModel("gpt-4o"), // any model name configured in LiteLLM
|
|
)
|
|
|
|
// Create and run a simple agent.
|
|
agent := core.NewAgent[string](model,
|
|
core.WithSystemPrompt[string]("You are a helpful assistant. Be concise."),
|
|
)
|
|
|
|
result, err := agent.Run(context.Background(), "Explain quantum computing in two sentences.")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
fmt.Println(result.Output)
|
|
}
|