@@ -293,8 +293,34 @@ type ListModelsOptions struct {
293
293
CredentialOverrides []string
294
294
}
295
295
296
+ type Model struct {
297
+ CreatedAt int64 `json:"created"`
298
+ ID string `json:"id"`
299
+ Object string `json:"object"`
300
+ OwnedBy string `json:"owned_by"`
301
+ Permission []Permission `json:"permission"`
302
+ Root string `json:"root"`
303
+ Parent string `json:"parent"`
304
+ Metadata map [string ]string `json:"metadata"`
305
+ }
306
+
307
+ type Permission struct {
308
+ CreatedAt int64 `json:"created"`
309
+ ID string `json:"id"`
310
+ Object string `json:"object"`
311
+ AllowCreateEngine bool `json:"allow_create_engine"`
312
+ AllowSampling bool `json:"allow_sampling"`
313
+ AllowLogprobs bool `json:"allow_logprobs"`
314
+ AllowSearchIndices bool `json:"allow_search_indices"`
315
+ AllowView bool `json:"allow_view"`
316
+ AllowFineTuning bool `json:"allow_fine_tuning"`
317
+ Organization string `json:"organization"`
318
+ Group interface {} `json:"group"`
319
+ IsBlocking bool `json:"is_blocking"`
320
+ }
321
+
296
322
// ListModels will list all the available models.
297
- func (g * GPTScript ) ListModels (ctx context.Context , opts ... ListModelsOptions ) ([]string , error ) {
323
+ func (g * GPTScript ) ListModels (ctx context.Context , opts ... ListModelsOptions ) ([]Model , error ) {
298
324
var o ListModelsOptions
299
325
for _ , opt := range opts {
300
326
o .Providers = append (o .Providers , opt .Providers ... )
@@ -314,7 +340,12 @@ func (g *GPTScript) ListModels(ctx context.Context, opts ...ListModelsOptions) (
314
340
return nil , err
315
341
}
316
342
317
- return strings .Split (strings .TrimSpace (out ), "\n " ), nil
343
+ var models []Model
344
+ if err = json .Unmarshal ([]byte (out ), & models ); err != nil {
345
+ return nil , fmt .Errorf ("failed to parse models: %w" , err )
346
+ }
347
+
348
+ return models , nil
318
349
}
319
350
320
351
func (g * GPTScript ) Confirm (ctx context.Context , resp AuthResponse ) error {
0 commit comments