blob: a3225999e805e398548942568c4a5938e546409a [file] [log] [blame]
package main
import (
"context"
"fmt"
"log"
"github.com/iomodo/staff/llm"
_ "github.com/iomodo/staff/llm/providers" // Auto-register providers
)
func main() {
// Create fake LLM config
config := llm.Config{
Provider: llm.ProviderFake,
APIKey: "fake-key",
BaseURL: "fake://test",
}
// Create provider
provider, err := llm.CreateProvider(config)
if err != nil {
log.Fatalf("Failed to create provider: %v", err)
}
defer provider.Close()
// Test chat completion
req := llm.ChatCompletionRequest{
Model: "fake-gpt-4",
Messages: []llm.Message{
{
Role: llm.RoleSystem,
Content: "You are a helpful AI assistant.",
},
{
Role: llm.RoleUser,
Content: "Create a solution for implementing user authentication",
},
},
MaxTokens: &[]int{4000}[0],
Temperature: &[]float64{0.3}[0],
}
fmt.Println("Testing Fake LLM Provider...")
fmt.Println("==========================")
resp, err := provider.ChatCompletion(context.Background(), req)
if err != nil {
log.Fatalf("Chat completion failed: %v", err)
}
fmt.Printf("Response ID: %s\n", resp.ID)
fmt.Printf("Model: %s\n", resp.Model)
fmt.Printf("Provider: %s\n", resp.Provider)
fmt.Printf("Usage: %+v\n", resp.Usage)
fmt.Println("\nGenerated Solution:")
fmt.Println("===================")
fmt.Println(resp.Choices[0].Message.Content)
fmt.Println("\n✅ Fake LLM Provider is working correctly!")
}