Skip to content

Commit a013b20

Browse files
committed
fix: use default config in embedded SDK server
Signed-off-by: Donnie Adams <[email protected]>
1 parent f3194f7 commit a013b20

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

pkg/gptscript/gptscript.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ type Options struct {
5151
Env []string
5252
}
5353

54-
func complete(opts ...Options) Options {
54+
func Complete(opts ...Options) Options {
5555
var result Options
5656
for _, opt := range opts {
5757
result.Cache = cache.Complete(result.Cache, opt.Cache)
@@ -80,7 +80,7 @@ func complete(opts ...Options) Options {
8080
}
8181

8282
func New(ctx context.Context, o ...Options) (*GPTScript, error) {
83-
opts := complete(o...)
83+
opts := Complete(o...)
8484
registry := llm.NewRegistry()
8585

8686
cacheClient, err := cache.New(opts.Cache)

pkg/sdkserver/server.go

+18
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ func Run(ctx context.Context, opts Options) error {
5656
// EmbeddedStart allows running the server as an embedded process that may use Stdin for input.
5757
// It returns the address the server is listening on.
5858
func EmbeddedStart(ctx context.Context, opts Options) (string, error) {
59+
opts = complete(opts)
60+
5961
listener, err := newListener(opts)
6062
if err != nil {
6163
return "", err
@@ -138,3 +140,19 @@ func run(ctx context.Context, listener net.Listener, opts Options) error {
138140
<-done
139141
return nil
140142
}
143+
144+
func complete(opts ...Options) Options {
145+
var result Options
146+
147+
for _, opt := range opts {
148+
result.Options = gptscript.Complete(result.Options, opt.Options)
149+
result.ListenAddress = types.FirstSet(opt.ListenAddress, result.ListenAddress)
150+
result.Debug = types.FirstSet(opt.Debug, result.Debug)
151+
}
152+
153+
if result.ListenAddress == "" {
154+
result.ListenAddress = "127.0.0.1:0"
155+
}
156+
157+
return result
158+
}

0 commit comments

Comments
 (0)