Files
goralphy/main.go
Christoph K. f26005fda6 loggin added
2026-02-25 12:19:14 +01:00

79 lines
1.8 KiB
Go

package main
import (
"bufio"
"context"
"flag"
"fmt"
"log"
"os"
"strconv"
"strings"
"github.com/openai/openai-go"
oaioption "github.com/openai/openai-go/option"
"llm-agent/agent"
)
const baseURL = "http://127.0.0.1:12434/v1"
func selectModel(client *openai.Client) string {
modelsPage, err := client.Models.List(context.Background())
if err != nil {
log.Fatalf("Fehler beim Abrufen der Modelle: %v", err)
}
models := modelsPage.Data
if len(models) == 0 {
log.Fatal("Keine Modelle verfügbar!")
}
fmt.Println("\n📦 Verfügbare Modelle:")
fmt.Println(strings.Repeat("─", 50))
for i, m := range models {
fmt.Printf(" [%d] %s\n", i+1, m.ID)
}
fmt.Println(strings.Repeat("─", 50))
scanner := bufio.NewScanner(os.Stdin)
for {
fmt.Printf("Wähle ein Modell (1-%d): ", len(models))
if !scanner.Scan() {
log.Fatal("Eingabe fehlgeschlagen")
}
choice, err := strconv.Atoi(strings.TrimSpace(scanner.Text()))
if err != nil || choice < 1 || choice > len(models) {
fmt.Printf("❌ Ungültige Eingabe.\n")
continue
}
selected := models[choice-1].ID
fmt.Printf("✅ Modell gewählt: %s\n", selected)
return selected
}
}
func main() {
// Flags definieren
verbose := flag.Bool("verbose", false, "Zeigt alle Chat-Nachrichten vollständig an")
prdFile := flag.String("prd", "PRD.md", "Pfad zur PRD-Datei")
workDir := flag.String("dir", ".", "Arbeitsverzeichnis")
flag.Parse()
client := openai.NewClient(
oaioption.WithBaseURL(baseURL),
oaioption.WithAPIKey("ollama"),
)
fmt.Println("🤖 LLM Agent")
if *verbose {
fmt.Println("🔍 Verbose-Modus aktiv")
}
model := selectModel(&client)
loop := agent.NewAgentLoop(model, *workDir, *prdFile, *verbose)
if err := loop.Run(); err != nil {
log.Fatalf("Agent fehlgeschlagen: %v", err)
}
}