feat(v2): add Parse() and extensible Registry #5
Reference in New Issue
Block a user
Delete Branch "feat/parse-registry"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
llm.Parse(spec)resolves model strings into ready-to-use*Modelobjects in one call. Supports"openai/gpt-4o","openai/gpt-4o:high"(with reasoning suffix), Ollama-style tags like"ollama/qwen3:30b", static aliases, dynamic resolvers, and named targets viaLLM_Xenv var DSNs.Registrytype withRegisterProvider,RegisterAlias, andRegisterResolvermethods. ADefaultRegistryis pre-populated with all built-in providers (including the newforemanentry). Package-level convenience functions delegate toDefaultRegistry.Foremanconstructor for targeting foreman daemons (private authenticated Ollama endpoints with queuing/observability).LLM_XDSN env vars enable named multi-instance targets without code changes:LLM_M5=foreman://token@hostlets callers writellm.Parse("m5/qwen3:30b").Spec format
DSN format (for
LLM_Xenv vars)Examples:
LLM_M5=foreman://my-token@foreman-m5.localLLM_LOCAL=ollama://localhost:11434Extension points
RegisterProvider(info)RegisterAlias(name, spec)RegisterResolver(res)Follow-up
mort migration (registering tier aliases as resolvers, lane-wrapped factories via RegisterProvider) is a separate PR.
Test plan
go build ./...passesgo vet ./...cleango test -race -count=1 ./...all pass (18 new test cases in parse_test.go)go mod tidy+ no diff on go.mod/go.sumProviders()andProviderByName()still work, now include foreman