mirror of
https://github.com/jasonxu114514/opencode2api.git
synced 2026-12-05 08:02:53 +00:00
Move the command to cmd/opencode2api and group production code into configuration, gateway, protocol, model, admin, telemetry and helper packages. Keep shared state private behind context, metrics and runtime interfaces. Remove the requested test files and replace test-only CI jobs with vet/build checks. Update Docker and release build paths, preserve version injection and make the WebUI an explicit embedded asset package. Add directory trees and source reading guides to both READMEs. Anchor binary ignore rules so the command package is tracked.
26 lines
506 B
Go
26 lines
506 B
Go
// Package protocol translates Chat, Responses, and Anthropic payloads and streams.
|
|
package protocol
|
|
|
|
type Protocol string
|
|
|
|
const (
|
|
Chat Protocol = "chat"
|
|
Responses Protocol = "responses"
|
|
Anthropic Protocol = "anthropic"
|
|
)
|
|
|
|
func Valid(p Protocol) bool {
|
|
return p == Chat || p == Responses || p == Anthropic
|
|
}
|
|
|
|
func Path(protocol Protocol) string {
|
|
switch protocol {
|
|
case Responses:
|
|
return "/v1/responses"
|
|
case Anthropic:
|
|
return "/v1/messages"
|
|
default:
|
|
return "/v1/chat/completions"
|
|
}
|
|
}
|