{"id":27921528,"url":"https://github.com/xiaoconstantine/dspy-go","last_synced_at":"2026-04-11T15:09:31.144Z","repository":{"id":250757846,"uuid":"833397840","full_name":"XiaoConstantine/dspy-go","owner":"XiaoConstantine","description":"DSPy Go implementation","archived":false,"fork":false,"pushed_at":"2025-05-06T02:27:52.000Z","size":560,"stargazers_count":34,"open_issues_count":6,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-06T21:08:36.671Z","etag":null,"topics":["agent-framework","agents","ai","dspy","golang","llms","workflows"],"latest_commit_sha":null,"homepage":"","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/XiaoConstantine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-07-25T01:13:25.000Z","updated_at":"2025-05-01T13:02:02.000Z","dependencies_parsed_at":"2024-08-12T23:32:14.172Z","dependency_job_id":"0dc9a0b2-35e1-4d1a-ac2a-4c519f31f555","html_url":"https://github.com/XiaoConstantine/dspy-go","commit_stats":null,"previous_names":["xiaoconstantine/dspy-go"],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XiaoConstantine%2Fdspy-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XiaoConstantine%2Fdspy-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XiaoConstantine%2Fdspy-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XiaoConstantine%2Fdspy-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/XiaoConstantine","download_url":"https://codeload.github.com/XiaoConstantine/dspy-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252769422,"owners_count":21801378,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["agent-framework","agents","ai","dspy","golang","llms","workflows"],"created_at":"2025-05-06T21:09:03.616Z","updated_at":"2026-04-11T15:09:31.128Z","avatar_url":"https://github.com/XiaoConstantine.png","language":"Go","readme":"# DSPy-Go\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/XiaoConstantine/dspy-go)](https://goreportcard.com/report/github.com/XiaoConstantine/dspy-go)\n[![codecov](https://codecov.io/gh/XiaoConstantine/dspy-go/graph/badge.svg?token=GGKRLMLXJ9)](https://codecov.io/gh/XiaoConstantine/dspy-go)\n[![Go Reference](https://pkg.go.dev/badge/github.com/XiaoConstantine/dspy-go)](https://pkg.go.dev/github.com/XiaoConstantine/dspy-go)\n\n## What is DSPy-Go?\n\nDSPy-Go is a native Go implementation of the DSPy framework, bringing systematic prompt engineering and automated reasoning capabilities to Go applications. Build reliable LLM applications through composable modules and workflows.\n\n**[Full Documentation](https://xiaocui.me/dspy-go/)** | **[API Reference](https://pkg.go.dev/github.com/XiaoConstantine/dspy-go)** | **[Examples](examples/)**\n\n### Key Features\n\n| Feature | Description |\n|---------|-------------|\n| **Modular Architecture** | Compose simple, reusable components into complex applications |\n| **Multiple LLM Providers** | Anthropic, OpenAI, Google Gemini, Ollama, LlamaCPP, and more |\n| **Advanced Modules** | Predict, ChainOfThought, ReAct, RLM, Refine, Parallel |\n| **Intelligent Agents** | ReAct patterns, ACE framework for self-improving agents |\n| **A2A Protocol** | Multi-agent orchestration with hierarchical composition |\n| **Smart Tool Management** | Bayesian selection, chaining, composition, MCP integration |\n| **Quality Optimizers** | GEPA, MIPRO, SIMBA, BootstrapFewShot, COPRO |\n| **Structured Output** | JSON structured output and XML adapters with security controls |\n\n## Installation\n\n```bash\ngo get github.com/XiaoConstantine/dspy-go\n```\n\n## Quick Start\n\n### CLI (Zero Code)\n\n```bash\ncd cmd/dspy-cli \u0026\u0026 go build -o dspy-cli\nexport GEMINI_API_KEY=\"your-api-key\"\n\n./dspy-cli list                           # See all optimizers\n./dspy-cli try mipro --dataset gsm8k      # Test optimizer instantly\n./dspy-cli view session.jsonl --stats     # View RLM session logs\n```\n\n**[CLI Documentation](cmd/dspy-cli/README.md)**\n\n### Programming\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"github.com/XiaoConstantine/dspy-go/pkg/core\"\n    \"github.com/XiaoConstantine/dspy-go/pkg/llms\"\n    \"github.com/XiaoConstantine/dspy-go/pkg/modules\"\n)\n\nfunc main() {\n    // Configure LLM\n    llm, err := llms.NewGeminiLLM(\"\", core.ModelGoogleGeminiPro)\n    if err != nil {\n        panic(err)\n    }\n    core.SetDefaultLLM(llm)\n\n    // Create signature and module\n    signature := core.NewSignature(\n        []core.InputField{{Field: core.NewField(\"question\")}},\n        []core.OutputField{{Field: core.NewField(\"answer\")}},\n    )\n    cot := modules.NewChainOfThought(signature)\n\n    // Execute\n    result, _ := cot.Process(context.Background(), map[string]interface{}{\n        \"question\": \"What is the capital of France?\",\n    })\n    fmt.Println(result[\"answer\"])\n}\n```\n\nPrefer helper functions such as `core.SetDefaultLLM`, `core.SetTeacherLLM`, and `core.GetConcurrencyLevel` over mutating `core.GlobalConfig` directly.\n\n## Core Concepts\n\n### Signatures\nDefine input/output contracts for modules:\n```go\nsignature := core.NewSignature(\n    []core.InputField{{Field: core.NewField(\"question\", core.WithDescription(\"Question to answer\"))}},\n    []core.OutputField{{Field: core.NewField(\"answer\", core.WithDescription(\"Detailed answer\"))}},\n).WithInstruction(\"Answer accurately and concisely.\")\n```\n\n### Modules\n\n| Module | Description |\n|--------|-------------|\n| `Predict` | Direct prediction |\n| `ChainOfThought` | Step-by-step reasoning |\n| `ReAct` | Reasoning + tool use |\n| `RLM` | Large context exploration via REPL |\n| `Refine` | Quality improvement through iteration |\n| `Parallel` | Concurrent batch processing |\n\n### Structured Output\n```go\n// JSON structured output\ncot := modules.NewChainOfThought(signature).WithStructuredOutput()\n\n// XML adapter (alternative)\ninterceptors.ApplyXMLInterceptors(predict, interceptors.DefaultXMLConfig())\n```\n\n**[Core Concepts Guide](https://xiaocui.me/dspy-go/docs/guides/core-concepts/)**\n\n## Documentation\n\n| Guide | Description |\n|-------|-------------|\n| **[Getting Started](https://xiaocui.me/dspy-go/docs/guides/getting-started/)** | Installation and first program |\n| **[Core Concepts](https://xiaocui.me/dspy-go/docs/guides/core-concepts/)** | Signatures, Modules, Programs |\n| **[Building Agents](https://xiaocui.me/dspy-go/docs/guides/agents/)** | ReAct, ACE framework, memory |\n| **[A2A Protocol](https://xiaocui.me/dspy-go/docs/guides/a2a-protocol/)** | Multi-agent orchestration |\n| **[RLM Module](https://xiaocui.me/dspy-go/docs/guides/rlm/)** | Large context exploration |\n| **[XML Adapters](https://xiaocui.me/dspy-go/docs/guides/xml-adapters/)** | Structured output parsing |\n| **[Tool Management](https://xiaocui.me/dspy-go/docs/guides/tools/)** | Smart registry, chaining, MCP |\n| **[Optimizers](https://xiaocui.me/dspy-go/docs/guides/optimizers/)** | GEPA, MIPRO, SIMBA, Bootstrap |\n\n## Examples\n\n### Agent Frameworks\n- **[ace_basic](examples/ace_basic/)** - Self-improving agents with ACE\n- **[a2a_composition](examples/a2a_composition/)** - Multi-agent deep research\n- **[agents](examples/agents/)** - ReAct patterns and orchestration\n\n### Modules\n- **[rlm](examples/rlm/)** - Large context exploration\n- **[xml_adapter](examples/xml_adapter/)** - XML structured output\n- **[parallel](examples/parallel/)** - Batch processing\n- **[refine](examples/refine/)** - Quality improvement\n\n### Tools\n- **[smart_tool_registry](examples/smart_tool_registry/)** - Intelligent tool selection\n- **[tool_chaining](examples/tool_chaining/)** - Pipeline building\n- **[tool_composition](examples/tool_composition/)** - Composite tools\n\n### Optimizers\n- **[mipro](examples/others/mipro/)** - TPE-based optimization\n- **[simba](examples/others/simba/)** - Introspective learning\n- **[gepa](examples/others/gepa/)** - Evolutionary optimization\n\n## LLM Providers\n\n```go\n// Anthropic Claude\nllm, _ := llms.NewAnthropicLLM(\"api-key\", core.ModelAnthropicSonnet)\n\n// Google Gemini\nllm, _ := llms.NewGeminiLLM(\"api-key\", core.ModelGoogleGeminiPro)\n\n// OpenAI\nllm, _ := llms.NewOpenAI(core.ModelOpenAIGPT4, \"api-key\")\n\n// Ollama (local)\nllm, _ := llms.NewOllamaLLM(core.ModelOllamaLlama3_8B)\n\n// OpenAI-compatible (LiteLLM, LocalAI, etc.)\nllm, _ := llms.NewOpenAILLM(core.ModelOpenAIGPT4,\n    llms.WithAPIKey(\"api-key\"),\n    llms.WithOpenAIBaseURL(\"http://localhost:4000\"))\n```\n\n**[Providers Reference](https://xiaocui.me/dspy-go/docs/reference/providers/)**\n\n## Community\n\n- **Documentation**: [xiaocui.me/dspy-go](https://xiaocui.me/dspy-go/)\n- **API Reference**: [pkg.go.dev](https://pkg.go.dev/github.com/XiaoConstantine/dspy-go)\n- **Example App**: [Maestro](https://github.com/XiaoConstantine/maestro) - Code review agent\n\n## License\n\nDSPy-Go is released under the MIT License. See the [LICENSE](LICENSE) file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiaoconstantine%2Fdspy-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxiaoconstantine%2Fdspy-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiaoconstantine%2Fdspy-go/lists"}