docs: examples for every hard requirement + mort migration blueprint
Phase 7: nine runnable examples/ programs (parse, failover chains with trailing alias, tiers, LLM_* env providers, multimodal, tool loop, Generate[T], agent, skills); docs/mort-migration.md mapping mort's go-llm/go-agentkit usage onto majordomo APIs with the planned additive library extensions and conversion order; README finalized with the complete matrix. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
// Command parse demonstrates the resolver: one spec string in, one Model
|
||||
// out, regardless of whether it names a single target, a chain, or a tier.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"gitea.stevedudenhoeffer.com/steve/majordomo"
|
||||
)
|
||||
|
||||
func main() {
|
||||
model := flag.String("model", "ollama-cloud/minimax-m3:cloud", "model spec (provider/model, chain, or alias)")
|
||||
prompt := flag.String("prompt", "Say hello in five words.", "prompt to send")
|
||||
flag.Parse()
|
||||
|
||||
m, err := majordomo.Parse(*model)
|
||||
if err != nil {
|
||||
log.Fatalf("parse %q: %v", *model, err)
|
||||
}
|
||||
|
||||
resp, err := m.Generate(context.Background(), majordomo.Request{
|
||||
Messages: []majordomo.Message{majordomo.UserText(*prompt)},
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("generate: %v", err)
|
||||
}
|
||||
fmt.Printf("[%s] %s\n", resp.Model, resp.Text())
|
||||
fmt.Printf("usage: %d in / %d out tokens\n", resp.Usage.InputTokens, resp.Usage.OutputTokens)
|
||||
}
|
||||
Reference in New Issue
Block a user