Refactor model interface to high-level idiomatic Go API#2863
Merged
Conversation
Co-authored-by: asim <[email protected]>
Co-authored-by: asim <[email protected]>
Co-authored-by: asim <[email protected]>
Co-authored-by: asim <[email protected]>
Co-authored-by: asim <[email protected]>
Copilot
AI
changed the title
[WIP] Add model packager with Model interface
Add model provider abstraction layer
Feb 14, 2026
Co-authored-by: asim <[email protected]>
Co-authored-by: asim <[email protected]>
Co-authored-by: asim <[email protected]>
Copilot
AI
changed the title
Add model provider abstraction layer
Refactor model interface to high-level idiomatic Go API
Feb 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The model interface exposed low-level methods (
BuildRequest,ParseResponse,SetAuthHeaders, etc.) requiring manual HTTP handling, request building, and tool execution loops. It used Java-like terms ("Factory", "Executor") and didn't follow go-micro patterns.Changes
Interface redesign following Registry/Client/Broker patterns:
Init(...Option) error- configure post-creationOptions() Options- get current configString() string- provider nameGenerate(ctx, req, opts...) (*Response, error)- single method replaces 6 low-level methodsStream(ctx, req, opts...) (Stream, error)- future streaming supportOptions pattern for configuration:
WithAPIKey(),WithModel(),WithBaseURL(),WithToolHandler()Automatic tool execution:
ToolHandlerexecutes tools and returns final answer inResponse.AnswerTerminology fixes:
ProviderFactory→NewFuncToolExecutor→ToolHandlerProvider implementations (Anthropic, OpenAI):
Generate()call handles full request/response/tool cycleExample
Before:
After:
Server code reduced from 184 to 118 lines (-36%).
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
api.anthropic.com/tmp/go-build4006390183/b060/anthropic.test /tmp/go-build4006390183/b060/anthropic.test -test.testlogfile=/tmp/go-build4006390183/b060/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true(dns block)/tmp/go-build3913422460/b060/anthropic.test /tmp/go-build3913422460/b060/anthropic.test -test.testlogfile=/tmp/go-build3913422460/b060/testlog.txt -test.paniconexit0 -test.timeout=10m0s ortc�� x64/src/runtime/-p x64/src/log/log.google.golang.org/protobuf/reflect/protodesc(dns block)api.openai.com/tmp/go-build4006390183/b197/openai.test /tmp/go-build4006390183/b197/openai.test -test.testlogfile=/tmp/go-build4006390183/b197/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true(dns block)/tmp/go-build3913422460/b197/openai.test /tmp/go-build3913422460/b197/openai.test -test.testlogfile=/tmp/go-build3913422460/b197/testlog.txt -test.paniconexit0 -test.timeout=10m0s ortc�� x64/src/runtime/-p x64/src/vendor/ggolang.org/x/net/http2/h2c(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.