@@ -12,21 +12,31 @@ import (
12
12
13
13
const relativeToBinaryPath = "<me>"
14
14
15
- type Client struct {
15
+ type ClientOpts struct {
16
16
GPTScriptURL string
17
17
GPTScriptBin string
18
18
}
19
19
20
- func (c * Client ) Complete () {
21
- if c .GPTScriptBin == "" {
22
- c .GPTScriptBin = getCommand ()
20
+ type Client struct {
21
+ opts ClientOpts
22
+ }
23
+
24
+ func NewClient (opts ClientOpts ) * Client {
25
+ c := & Client {opts : opts }
26
+ c .complete ()
27
+ return c
28
+ }
29
+
30
+ func (c * Client ) complete () {
31
+ if c .opts .GPTScriptBin == "" {
32
+ c .opts .GPTScriptBin = getCommand ()
23
33
}
24
34
}
25
35
26
36
func (c * Client ) Evaluate (ctx context.Context , opts Opts , tools ... fmt.Stringer ) (* Run , error ) {
27
37
return (& Run {
28
- url : c .GPTScriptURL ,
29
- binPath : c .GPTScriptBin ,
38
+ url : c .opts . GPTScriptURL ,
39
+ binPath : c .opts . GPTScriptBin ,
30
40
requestPath : "evaluate" ,
31
41
state : Creating ,
32
42
opts : opts ,
@@ -37,8 +47,8 @@ func (c *Client) Evaluate(ctx context.Context, opts Opts, tools ...fmt.Stringer)
37
47
38
48
func (c * Client ) Run (ctx context.Context , toolPath string , opts Opts ) (* Run , error ) {
39
49
return (& Run {
40
- url : c .GPTScriptURL ,
41
- binPath : c .GPTScriptBin ,
50
+ url : c .opts . GPTScriptURL ,
51
+ binPath : c .opts . GPTScriptBin ,
42
52
requestPath : "run" ,
43
53
state : Creating ,
44
54
opts : opts ,
@@ -86,8 +96,8 @@ func (c *Client) Fmt(ctx context.Context, nodes []Node) (string, error) {
86
96
87
97
run := & runSubCommand {
88
98
Run : Run {
89
- url : c .GPTScriptURL ,
90
- binPath : c .GPTScriptBin ,
99
+ url : c .opts . GPTScriptURL ,
100
+ binPath : c .opts . GPTScriptBin ,
91
101
requestPath : "fmt" ,
92
102
state : Creating ,
93
103
toolPath : "" ,
@@ -148,8 +158,8 @@ func (c *Client) ListModels(ctx context.Context) ([]string, error) {
148
158
func (c * Client ) runBasicCommand (ctx context.Context , command , requestPath , toolPath , content string ) (string , error ) {
149
159
run := & runSubCommand {
150
160
Run : Run {
151
- url : c .GPTScriptURL ,
152
- binPath : c .GPTScriptBin ,
161
+ url : c .opts . GPTScriptURL ,
162
+ binPath : c .opts . GPTScriptBin ,
153
163
requestPath : requestPath ,
154
164
state : Creating ,
155
165
toolPath : toolPath ,
0 commit comments