[SMG-GO] implement a Go SGLang Model Gateway - OpenAI Compatible API Server (#14770)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
sglang "github.com/sglang/sglang-go-grpc-sdk"
|
||||
)
|
||||
|
||||
// SGLangService wraps SGLang client
|
||||
type SGLangService struct {
|
||||
client *sglang.Client
|
||||
}
|
||||
|
||||
func NewSGLangService(endpoint, tokenizerPath string) (*SGLangService, error) {
|
||||
client, err := sglang.NewClient(sglang.ClientConfig{
|
||||
Endpoint: endpoint,
|
||||
TokenizerPath: tokenizerPath,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &SGLangService{
|
||||
client: client,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Client returns the underlying SGLang client
|
||||
func (s *SGLangService) Client() *sglang.Client {
|
||||
return s.client
|
||||
}
|
||||
|
||||
// Close closes the SGLang client
|
||||
func (s *SGLangService) Close() error {
|
||||
if s.client != nil {
|
||||
return s.client.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user