{"id":50800747,"url":"https://github.com/ronhuafeng/llmkit-go","last_synced_at":"2026-06-12T19:30:53.331Z","repository":{"id":363934409,"uuid":"1265567028","full_name":"ronhuafeng/llmkit-go","owner":"ronhuafeng","description":"Provider-neutral Go primitives for typed LLM programming","archived":false,"fork":false,"pushed_at":"2026-06-11T00:25:01.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-11T02:16:37.202Z","etag":null,"topics":["go","json-schema","llm","structured-output","typed-output"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ronhuafeng.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":"SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-10T22:25:00.000Z","updated_at":"2026-06-11T00:24:54.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ronhuafeng/llmkit-go","commit_stats":null,"previous_names":["ronhuafeng/llmkit-go"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ronhuafeng/llmkit-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronhuafeng%2Fllmkit-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronhuafeng%2Fllmkit-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronhuafeng%2Fllmkit-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronhuafeng%2Fllmkit-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ronhuafeng","download_url":"https://codeload.github.com/ronhuafeng/llmkit-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronhuafeng%2Fllmkit-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34260309,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","json-schema","llm","structured-output","typed-output"],"created_at":"2026-06-12T19:30:52.748Z","updated_at":"2026-06-12T19:30:53.319Z","avatar_url":"https://github.com/ronhuafeng.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# llmkit-go\n\nProvider-neutral Go primitives for typed LLM programming.\n\n`llmkit-go` is a small toolkit for code that wants structured LLM output\nwithout taking a dependency on a specific model provider SDK. It focuses on\nthree stable boundaries:\n\n- `settle`: a bounded stable loop primitive.\n- `llmschema`: Go type to structured output JSON Schema projection and decode.\n- `llmadapter`: prompt plus typed output request/value helpers.\n\nConcrete provider callers live in separate modules. This repository does not\nown provider transport, provider credentials, prompt libraries, tracing\nbackends, or business validation rules.\n\n## Status\n\nThis project is usable but still pre-v1. The public API is intentionally small;\nsee [API compatibility](#api-compatibility) before depending on it from a\nlibrary with a strict compatibility policy.\n\n## Packages\n\n| Package | Purpose | Provider dependencies |\n| --- | --- | --- |\n| `github.com/ronhuafeng/llmkit-go/settle` | Run an operation until its validator accepts the output or a bounded iteration limit is reached. | Standard library only. |\n| `github.com/ronhuafeng/llmkit-go/llmschema` | Project Go output types to provider-neutral JSON Schema and decode structured JSON responses. | Uses `github.com/google/jsonschema-go`. |\n| `github.com/ronhuafeng/llmkit-go/llmadapter` | Build typed LLM requests and decode typed values behind a tiny `Caller` interface. | Depends on `llmschema`; no concrete provider SDK. |\n\nThe `internal/` tree contains repository tests and is not public API.\n\n## Installation\n\nRequires Go 1.23 or newer.\n\n```sh\ngo get github.com/ronhuafeng/llmkit-go@latest\n```\n\n## Quick Start\n\n### settle\n\nUse `settle.Run` when an operation may need a few bounded attempts before the\noutput is acceptable.\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"strings\"\n\n\t\"github.com/ronhuafeng/llmkit-go/settle\"\n)\n\ntype op struct {\n\tattempt int\n}\n\nfunc (o *op) Run(ctx context.Context, input string) (string, error) {\n\to.attempt++\n\tif o.attempt == 1 {\n\t\treturn \"draft\", nil\n\t}\n\treturn input + \" final\", nil\n}\n\nfunc (o *op) Validate(ctx context.Context, input, result string) (bool, error) {\n\treturn strings.Contains(result, input), nil\n}\n\nfunc main() {\n\tgot, err := settle.Run(context.Background(), \u0026op{}, \"ship\", 3)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(got)\n}\n```\n\n### llmschema\n\nUse `llmschema` when you need the JSON Schema for an expected output type or\nneed to decode the provider's final structured JSON.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/ronhuafeng/llmkit-go/llmschema\"\n)\n\ntype Verdict struct {\n\tStatus string `json:\"status\" jsonschema:\"short final status\"`\n\tScore  int    `json:\"score,omitempty\"`\n}\n\nfunc main() {\n\tschema, err := llmschema.SchemaJSONFor[Verdict]()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(string(schema))\n\n\tvalue, err := llmschema.DecodeString[Verdict](`{\"status\":\"pass\",\"score\":2}`)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(value.Status)\n}\n```\n\n### llmadapter\n\nUse `llmadapter` to keep provider-specific transport behind a narrow interface.\nYour provider caller receives a prompt and schema, then returns the final JSON\ntext to decode.\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/ronhuafeng/llmkit-go/llmadapter\"\n)\n\ntype staticCaller struct{}\n\nfunc (staticCaller) Call(ctx context.Context, request llmadapter.Request) (llmadapter.Response, error) {\n\t// A real caller would send request.Prompt and request.OutputSchema to a provider.\n\treturn llmadapter.Response{FinalResponse: `{\"answer\":\"yes\"}`}, nil\n}\n\ntype Answer struct {\n\tAnswer string `json:\"answer\"`\n}\n\nfunc main() {\n\tanswer, err := llmadapter.Value[Answer](context.Background(), staticCaller{}, \"Return yes.\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(answer.Answer)\n}\n```\n\nFor a retry/review loop, build an `llmadapter.Op` with `NewOp` and pass it to\n`settle.Run`.\n\n## API Compatibility\n\nPublic API is limited to exported identifiers in these packages:\n\n- `settle`\n- `llmschema`\n- `llmadapter`\n\nEverything under `internal/` is private. README examples are illustrative and\nmay change, but exported package behavior should be treated as compatibility\nsurface.\n\nBefore v1.0.0, this project follows SemVer with a conservative pre-v1 policy:\npatch releases should be bug fixes only, minor releases may add API, and any\nknown breaking API change must be called out in `CHANGELOG.md` and the release\nnotes. After v1.0.0, breaking public API changes require a new major version.\n\n## Versioning\n\nReleases should be tagged as standard Go module tags. For a future release,\nreplace the version below with the next intended version:\n\n```sh\nVERSION=v0.2.0\ngit tag -a \"$VERSION\" -m \"llmkit-go $VERSION\"\ngit push origin \"$VERSION\"\n```\n\nSee [docs/release.md](docs/release.md) for the release checklist.\n\n## Testing\n\nRun the same checks used by CI:\n\n```sh\ngofmt -w $(find . -name '*.go' -not -path './vendor/*')\ntest -z \"$(gofmt -l $(find . -name '*.go' -not -path './vendor/*'))\"\ngo vet ./...\ngo test ./...\n```\n\nIf this repository is inside a larger local `go.work`, use `GOWORK=off` to\nverify it as a standalone module:\n\n```sh\nGOWORK=off go test ./...\n```\n\n## Security\n\nDo not report vulnerabilities by opening a public issue with exploit details.\nUse GitHub private vulnerability reporting:\n\n\u003chttps://github.com/ronhuafeng/llmkit-go/security/advisories/new\u003e\n\nSee [SECURITY.md](SECURITY.md) for supported versions and disclosure handling.\n\n## License and Dependency Provenance\n\n`llmkit-go` is released under the MIT License. See [LICENSE](LICENSE).\n\nDependency provenance is tracked in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)\nand should be reviewed before each release.\n\n## Contributing\n\nIssues and pull requests are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md)\nand [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) first.\n\n## Related Modules\n\nThis repository is intentionally provider-neutral. Provider-specific callers,\nSDK wrappers, application policy, and business validation should live in\nseparate modules that depend on this one.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fronhuafeng%2Fllmkit-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fronhuafeng%2Fllmkit-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fronhuafeng%2Fllmkit-go/lists"}