-
Notifications
You must be signed in to change notification settings - Fork 355
Expand file tree
/
Copy pathgradientai.go
More file actions
1876 lines (1609 loc) · 69.7 KB
/
gradientai.go
File metadata and controls
1876 lines (1609 loc) · 69.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package godo
import (
"context"
"encoding/json"
"fmt"
"net/http"
"strings"
)
const (
gradientBasePath = "/v2/gen-ai/agents"
agentModelBasePath = "/v2/gen-ai/models"
datacenterRegionsPath = "/v2/gen-ai/regions"
agentRouteBasePath = gradientBasePath + "/%s/child_agents/%s"
KnowledgeBasePath = "/v2/gen-ai/knowledge_bases"
functionRouteBasePath = gradientBasePath + "/%s/functions"
KnowledgeBaseDataSourcesPath = KnowledgeBasePath + "/%s/data_sources"
GetKnowledgeBaseByIDPath = KnowledgeBasePath + "/%s"
UpdateKnowledgeBaseByIDPath = KnowledgeBasePath + "/%s"
DeleteKnowledgeBaseByIDPath = KnowledgeBasePath + "/%s"
AgentKnowledgeBasePath = "/v2/gen-ai/agents" + "/%s/knowledge_bases/%s"
DeleteDataSourcePath = KnowledgeBasePath + "/%s/data_sources/%s"
IndexingJobsPath = "/v2/gen-ai/indexing_jobs"
IndexingJobByIDPath = IndexingJobsPath + "/%s"
IndexingJobCancelPath = IndexingJobsPath + "/%s/cancel"
IndexingJobDataSourcesPath = IndexingJobsPath + "/%s/data_sources"
AnthropicAPIKeysPath = "/v2/gen-ai/anthropic/keys"
AnthropicAPIKeyByIDPath = AnthropicAPIKeysPath + "/%s"
OpenAIAPIKeysPath = "/v2/gen-ai/openai/keys"
UpdateFunctionRoutePath = functionRouteBasePath + "/%s"
DeleteFunctionRoutePath = functionRouteBasePath + "/%s"
)
// GradientAIService is an interface for interfacing with the Gradient AI Agent endpoints
// of the DigitalOcean API.
// See https://docs.digitalocean.com/reference/api/digitalocean/#tag/GradientAI-Platform for more details.
type GradientAIService interface {
ListAgents(context.Context, *ListOptions) ([]*Agent, *Response, error)
CreateAgent(context.Context, *AgentCreateRequest) (*Agent, *Response, error)
ListAgentAPIKeys(context.Context, string, *ListOptions) ([]*ApiKeyInfo, *Response, error)
CreateAgentAPIKey(context.Context, string, *AgentAPIKeyCreateRequest) (*ApiKeyInfo, *Response, error)
UpdateAgentAPIKey(context.Context, string, string, *AgentAPIKeyUpdateRequest) (*ApiKeyInfo, *Response, error)
DeleteAgentAPIKey(context.Context, string, string) (*ApiKeyInfo, *Response, error)
RegenerateAgentAPIKey(context.Context, string, string) (*ApiKeyInfo, *Response, error)
GetAgent(context.Context, string) (*Agent, *Response, error)
UpdateAgent(context.Context, string, *AgentUpdateRequest) (*Agent, *Response, error)
DeleteAgent(context.Context, string) (*Agent, *Response, error)
UpdateAgentVisibility(context.Context, string, *AgentVisibilityUpdateRequest) (*Agent, *Response, error)
ListKnowledgeBases(ctx context.Context, opt *ListOptions) ([]KnowledgeBase, *Response, error)
CreateKnowledgeBase(ctx context.Context, knowledgeBaseCreate *KnowledgeBaseCreateRequest) (*KnowledgeBase, *Response, error)
ListKnowledgeBaseDataSources(ctx context.Context, knowledgeBaseID string, opt *ListOptions) ([]KnowledgeBaseDataSource, *Response, error)
AddKnowledgeBaseDataSource(ctx context.Context, knowledgeBaseID string, addDataSource *AddKnowledgeBaseDataSourceRequest) (*KnowledgeBaseDataSource, *Response, error)
DeleteKnowledgeBaseDataSource(ctx context.Context, knowledgeBaseID string, dataSourceID string) (string, string, *Response, error)
GetKnowledgeBase(ctx context.Context, knowledgeBaseID string) (*KnowledgeBase, string, *Response, error)
UpdateKnowledgeBase(ctx context.Context, knowledgeBaseID string, update *UpdateKnowledgeBaseRequest) (*KnowledgeBase, *Response, error)
DeleteKnowledgeBase(ctx context.Context, knowledgeBaseID string) (string, *Response, error)
ListIndexingJobs(ctx context.Context, opt *ListOptions) (*IndexingJobsResponse, *Response, error)
GetIndexingJob(ctx context.Context, indexingJobUUID string) (*IndexingJobResponse, *Response, error)
CancelIndexingJob(ctx context.Context, indexingJobUUID string) (*IndexingJobResponse, *Response, error)
ListIndexingJobDataSources(ctx context.Context, indexingJobUUID string) (*IndexingJobDataSourcesResponse, *Response, error)
AttachKnowledgeBaseToAgent(ctx context.Context, agentID string, knowledgeBaseID string) (*Agent, *Response, error)
DetachKnowledgeBaseToAgent(ctx context.Context, agentID string, knowledgeBaseID string) (*Agent, *Response, error)
AddAgentRoute(context.Context, string, string, *AgentRouteCreateRequest) (*AgentRouteResponse, *Response, error)
UpdateAgentRoute(context.Context, string, string, *AgentRouteUpdateRequest) (*AgentRouteResponse, *Response, error)
DeleteAgentRoute(context.Context, string, string) (*AgentRouteResponse, *Response, error)
ListAgentVersions(context.Context, string, *ListOptions) ([]*AgentVersion, *Response, error)
RollbackAgentVersion(context.Context, string, string) (string, *Response, error)
ListAnthropicAPIKeys(context.Context, *ListOptions) ([]*AnthropicApiKeyInfo, *Response, error)
CreateAnthropicAPIKey(ctx context.Context, anthropicAPIKeyCreateRequest *AnthropicAPIKeyCreateRequest) (*AnthropicApiKeyInfo, *Response, error)
GetAnthropicAPIKey(ctx context.Context, id string) (*AnthropicApiKeyInfo, *Response, error)
UpdateAnthropicAPIKey(ctx context.Context, id string, anthropicAPIKeyUpdateRequest *AnthropicAPIKeyUpdateRequest) (*AnthropicApiKeyInfo, *Response, error)
DeleteAnthropicAPIKey(ctx context.Context, id string) (*AnthropicApiKeyInfo, *Response, error)
ListAgentsByAnthropicAPIKey(ctx context.Context, id string, opt *ListOptions) ([]*Agent, *Response, error)
ListOpenAIAPIKeys(context.Context, *ListOptions) ([]*OpenAiApiKey, *Response, error)
CreateOpenAIAPIKey(ctx context.Context, openaiAPIKeyCreate *OpenAIAPIKeyCreateRequest) (*OpenAiApiKey, *Response, error)
GetOpenAIAPIKey(ctx context.Context, openaiApiKeyId string) (*OpenAiApiKey, *Response, error)
UpdateOpenAIAPIKey(ctx context.Context, openaiApiKeyId string, openaiAPIKeyUpdate *OpenAIAPIKeyUpdateRequest) (*OpenAiApiKey, *Response, error)
DeleteOpenAIAPIKey(ctx context.Context, openaiApiKeyId string) (*OpenAiApiKey, *Response, error)
ListAgentsByOpenAIAPIKey(ctx context.Context, openaiApiKeyId string, opt *ListOptions) ([]*Agent, *Response, error)
CreateFunctionRoute(context.Context, string, *FunctionRouteCreateRequest) (*Agent, *Response, error)
DeleteFunctionRoute(context.Context, string, string) (*Agent, *Response, error)
UpdateFunctionRoute(context.Context, string, string, *FunctionRouteUpdateRequest) (*Agent, *Response, error)
ListAvailableModels(context.Context, *ListOptions) ([]*Model, *Response, error)
ListDatacenterRegions(context.Context, *bool, *bool) ([]*DatacenterRegions, *Response, error)
}
var _ GradientAIService = &GradientAIServiceOp{}
// GradientAIServiceOp interfaces with the Gradient AI Service endpoints in the DigitalOcean API.
type GradientAIServiceOp struct {
client *Client
}
type gradientAgentsRoot struct {
Agents []*Agent `json:"agents"`
Links *Links `json:"links"`
Meta *Meta `json:"meta"`
}
type gradientAgentRoot struct {
Agent *Agent `json:"agent"`
}
type gradientModelsRoot struct {
Models []*Model `json:"models"`
Links *Links `json:"links"`
Meta *Meta `json:"meta"`
}
type agentAPIKeysRoot struct {
ApiKeys []*ApiKeyInfo `json:"api_key_infos"`
Links *Links `json:"links"`
Meta *Meta `json:"meta"`
}
type agentAPIKeyRoot struct {
ApiKey *ApiKeyInfo `json:"api_key_info,omitempty"`
}
type agentVersionsRoot struct {
AgentVersions []*AgentVersion `json:"agent_versions,omitempty"`
Links *Links `json:"links,omitempty"`
Meta *Meta `json:"meta,omitempty"`
}
type anthropicAPIKeysRoot struct {
AnthropicApiKeys []*AnthropicApiKeyInfo `json:"api_key_infos"`
Links *Links `json:"links"`
Meta *Meta `json:"meta"`
}
type openaiAPIKeysRoot struct {
OpenAIApiKeys []*OpenAiApiKey `json:"api_key_infos"`
Links *Links `json:"links"`
Meta *Meta `json:"meta"`
}
type anthropicAPIKeyRoot struct {
AnthropicApiKey *AnthropicApiKeyInfo `json:"api_key_info,omitempty"`
}
type openaiAPIKeyRoot struct {
OpenAIAPIKey *OpenAiApiKey `json:"api_key_info,omitempty"`
}
// Agent represents a Gradient AI Agent
type Agent struct {
AnthropicApiKey *AnthropicApiKeyInfo `json:"anthropic_api_key,omitempty"`
ApiKeyInfos []*ApiKeyInfo `json:"api_key_infos,omitempty"`
ApiKeys []*ApiKey `json:"api_keys,omitempty"`
ChatBot *ChatBot `json:"chatbot,omitempty"`
ChatbotIdentifiers []*AgentChatbotIdentifier `json:"chatbot_identifiers,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
ChildAgents []*Agent `json:"child_agents,omitempty"`
ConversationLogsEnabled bool `json:"conversation_logs_enabled,omitempty"`
Deployment *AgentDeployment `json:"deployment,omitempty"`
Description string `json:"description,omitempty"`
Functions []*AgentFunction `json:"functions,omitempty"`
Guardrails []*AgentGuardrail `json:"guardrails,omitempty"`
IfCase string `json:"if_case,omitempty"`
Instruction string `json:"instruction,omitempty"`
K int `json:"k,omitempty"`
KnowledgeBases []*KnowledgeBase `json:"knowledge_bases,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
Model *Model `json:"model,omitempty"`
Name string `json:"name,omitempty"`
OpenAiApiKey *OpenAiApiKey `json:"open_ai_api_key,omitempty"`
ParentAgents []*Agent `json:"parent_agents,omitempty"`
ProjectId string `json:"project_id,omitempty"`
ProvideCitations bool `json:"provide_citations,omitempty"`
Region string `json:"region,omitempty"`
RetrievalMethod string `json:"retrieval_method,omitempty"`
RouteCreatedAt *Timestamp `json:"route_created_at,omitempty"`
RouteCreatedBy string `json:"route_created_by,omitempty"`
RouteUuid string `json:"route_uuid,omitempty"`
RouteName string `json:"route_name,omitempty"`
Tags []string `json:"tags,omitempty"`
Template *AgentTemplate `json:"template,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
Url string `json:"url,omitempty"`
UserId string `json:"user_id,omitempty"`
Uuid string `json:"uuid,omitempty"`
VersionHash string `json:"version_hash,omitempty"`
VPCEgressIPs []string `json:"vpc_egress_ips,omitempty"`
VPCUuid string `json:"vpc_uuid,omitempty"`
Workspace Workspace `json:"workspace,omitempty"`
}
// AgentVersion represents a version of a Gradient AI Agent
type AgentVersion struct {
AgentUuid string `json:"agent_uuid,omitempty"`
AttachedChildAgents []*AttachedChildAgent `json:"attached_child_agents,omitempty"`
AttachedFunctions []*AgentFunction `json:"attached_functions,omitempty"`
AttachedGuardrails []*AgentGuardrail `json:"attached_guardrails,omitempty"`
AttachedKnowledgeBases []*KnowledgeBase `json:"attached_knowledgebases,omitempty"`
CanRollback bool `json:"can_rollback,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
CreatedByEmail string `json:"created_by_email,omitempty"`
CurrentlyApplied bool `json:"currently_applied,omitempty"`
Description string `json:"description,omitempty"`
ID string `json:"id,omitempty"`
Instruction string `json:"instruction,omitempty"`
K int64 `json:"k,omitempty"`
MaxTokens int64 `json:"max_tokens,omitempty"`
ModelName string `json:"model_name,omitempty"`
Name string `json:"name,omitempty"`
ProvideCitations bool `json:"provide_citations,omitempty"`
RetrievalMethod string `json:"retrieval_method,omitempty"`
Tags []string `json:"tags,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
TriggerAction string `json:"trigger_action,omitempty"`
VersionHash string `json:"version_hash,omitempty"`
}
type AttachedChildAgent struct {
AgentName string `json:"agent_name,omitempty"`
ChildAgentUuid string `json:"child_agent_uuid,omitempty"`
IfCase string `json:"if_case,omitempty"`
IsDeleted bool `json:"is_deleted,omitempty"`
RouteName string `json:"route_name,omitempty"`
}
type auditResponse struct {
AuditHeader AuditHeader `json:"audit_header,omitempty"`
VersionHash string `json:"version_hash,omitempty"`
}
// AuditHeader represents audit metadata for an action.
type AuditHeader struct {
ActorID string `json:"actor_id,omitempty"`
ActorIP string `json:"actor_ip,omitempty"`
ActorUUID string `json:"actor_uuid,omitempty"`
ContextURN string `json:"context_urn,omitempty"`
OriginApplication string `json:"origin_application,omitempty"`
UserID string `json:"user_id,omitempty"`
UserUUID string `json:"user_uuid,omitempty"`
}
// RollbackVersionRequest represents the request to rollback a Gradient AI Agent to a previous version
type RollbackVersionRequest struct {
AgentUuid string `json:"uuid,omitempty"`
VersionHash string `json:"version_hash,omitempty"`
}
// AgentFunction represents a Gradient AI Agent Function
type AgentFunction struct {
ApiKey string `json:"api_key,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
Description string `json:"description,omitempty"`
GuardrailUuid string `json:"guardrail_uuid,omitempty"`
FaasName string `json:"faas_name,omitempty"`
FaasNamespace string `json:"faas_namespace,omitempty"`
Name string `json:"name,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
Url string `json:"url,omitempty"`
Uuid string `json:"uuid,omitempty"`
IsDeleted bool `json:"is_deleted,omitempty"`
}
// AgentGuardrail represents a Guardrail attached to Gradient AI Agent
type AgentGuardrail struct {
AgentUuid string `json:"agent_uuid,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
DefaultResponse string `json:"default_response,omitempty"`
Description string `json:"description,omitempty"`
GuardrailUuid string `json:"guardrail_uuid,omitempty"`
IsAttached bool `json:"is_attached,omitempty"`
IsDefault bool `json:"is_default,omitempty"`
Name string `json:"name,omitempty"`
Priority int `json:"priority,omitempty"`
Type string `json:"type,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
Uuid string `json:"uuid,omitempty"`
IsDeleted bool `json:"is_deleted,omitempty"`
}
type ApiKey struct {
ApiKey string `json:"api_key,omitempty"`
}
// AnthropicApiKeyInfo represents the Anthropic API Key information
type AnthropicApiKeyInfo struct {
CreatedAt *Timestamp `json:"created_at,omitempty"`
CreatedBy string `json:"created_by,omitempty"`
DeletedAt *Timestamp `json:"deleted_at,omitempty"`
Name string `json:"name,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
Uuid string `json:"uuid,omitempty"`
}
// ApiKeyInfo represents the information of an API key
type ApiKeyInfo struct {
CreatedAt *Timestamp `json:"created_at,omitempty"`
CreatedBy string `json:"created_by,omitempty"`
DeletedAt *Timestamp `json:"deleted_at,omitempty"`
Name string `json:"name,omitempty"`
SecretKey string `json:"secret_key,omitempty"`
Uuid string `json:"uuid,omitempty"`
}
// OpenAiApiKey represents the OpenAI API Key information
type OpenAiApiKey struct {
CreatedAt *Timestamp `json:"created_at,omitempty"`
CreatedBy string `json:"created_by,omitempty"`
DeletedAt *Timestamp `json:"deleted_at,omitempty"`
Models []*Model `json:"models,omitempty"`
Name string `json:"name,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
Uuid string `json:"uuid,omitempty"`
}
// AgentVersionUpdateRequest represents the request to update the version of an agent
type AgentVisibilityUpdateRequest struct {
Uuid string `json:"uuid,omitempty"`
Visibility string `json:"visibility,omitempty"`
}
// AgentTemplate represents the template of a Gradient AI Agent
type AgentTemplate struct {
CreatedAt *Timestamp `json:"created_at,omitempty"`
Instruction string `json:"instruction,omitempty"`
Description string `json:"description,omitempty"`
K int `json:"k,omitempty"`
KnowledgeBases []*KnowledgeBase `json:"knowledge_bases,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
Model *Model `json:"model,omitempty"`
Name string `json:"name,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
Uuid string `json:"uuid,omitempty"`
}
// EvaluationMetricType represents the type of evaluation metric.
type EvaluationMetricType string
const (
MetricTypeUnspecified EvaluationMetricType = "METRIC_TYPE_UNSPECIFIED"
MetricTypeGeneralQuality EvaluationMetricType = "METRIC_TYPE_GENERAL_QUALITY"
MetricTypeRAGAndTool EvaluationMetricType = "METRIC_TYPE_RAG_AND_TOOL"
)
// EvaluationMetricValueType represents the value type of an evaluation metric.
type EvaluationMetricValueType string
const (
MetricValueTypeUnspecified EvaluationMetricValueType = "METRIC_VALUE_TYPE_UNSPECIFIED"
MetricValueTypeNumber EvaluationMetricValueType = "METRIC_VALUE_TYPE_NUMBER"
MetricValueTypeString EvaluationMetricValueType = "METRIC_VALUE_TYPE_STRING"
MetricValueTypePercentage EvaluationMetricValueType = "METRIC_VALUE_TYPE_PERCENTAGE"
)
// EvaluationMetricCategory represents the category of an evaluation metric.
type EvaluationMetricCategory string
const (
MetricCategoryUnspecified EvaluationMetricCategory = "METRIC_CATEGORY_UNSPECIFIED"
MetricCategoryCorrectness EvaluationMetricCategory = "METRIC_CATEGORY_CORRECTNESS"
MetricCategoryUserOutcomes EvaluationMetricCategory = "METRIC_CATEGORY_USER_OUTCOMES"
MetricCategorySafetyAndSecurity EvaluationMetricCategory = "METRIC_CATEGORY_SAFETY_AND_SECURITY"
MetricCategoryContextQuality EvaluationMetricCategory = "METRIC_CATEGORY_CONTEXT_QUALITY"
MetricCategoryModelFit EvaluationMetricCategory = "METRIC_CATEGORY_MODEL_FIT"
)
// Workspace represents a workspace containing agents and evaluation test cases.
type Workspace struct {
UUID string `json:"uuid,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
CreatedByEmail string `json:"created_by_email,omitempty"`
CreatedBy string `json:"created_by,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
DeletedAt *Timestamp `json:"deleted_at,omitempty"`
Agents []*Agent `json:"agents,omitempty"`
EvaluationTestCases []*EvaluationTestCase `json:"evaluation_test_cases,omitempty"`
}
// EvaluationTestCase represents an evaluation test case configuration.
type EvaluationTestCase struct {
TestCaseUUID string `json:"test_case_uuid,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Version uint32 `json:"version,omitempty"`
DatasetUUID string `json:"dataset_uuid,omitempty"` // Deprecated
DatasetName string `json:"dataset_name,omitempty"` // Deprecated
Metrics []*EvaluationMetric `json:"metrics,omitempty"`
StarMetric *StarMetric `json:"star_metric,omitempty"`
TotalRuns int32 `json:"total_runs,omitempty"`
LatestVersionNumberOfRuns int32 `json:"latest_version_number_of_runs,omitempty"`
UpdatedByUserID uint64 `json:"updated_by_user_id,omitempty"`
UpdatedByUserEmail string `json:"updated_by_user_email,omitempty"`
CreatedByUserEmail string `json:"created_by_user_email,omitempty"`
CreatedByUserID uint64 `json:"created_by_user_id,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
ArchivedAt *Timestamp `json:"archived_at,omitempty"`
Dataset *EvaluationDataset `json:"dataset,omitempty"`
}
// EvaluationMetric represents an evaluation metric definition.
type EvaluationMetric struct {
MetricUUID string `json:"metric_uuid,omitempty"`
MetricName string `json:"metric_name,omitempty"`
Description string `json:"description,omitempty"`
MetricType EvaluationMetricType `json:"metric_type,omitempty"`
MetricValueType EvaluationMetricValueType `json:"metric_value_type,omitempty"`
RangeMin float32 `json:"range_min,omitempty"`
RangeMax float32 `json:"range_max,omitempty"`
Inverted bool `json:"inverted,omitempty"`
Category EvaluationMetricCategory `json:"category,omitempty"`
IsMetricGoal bool `json:"is_metric_goal,omitempty"`
MetricRank uint32 `json:"metric_rank,omitempty"`
}
// EvaluationDataset represents the dataset information for an evaluation.
type EvaluationDataset struct {
DatasetUUID string `json:"dataset_uuid,omitempty"`
DatasetName string `json:"dataset_name,omitempty"`
RowCount uint32 `json:"row_count,omitempty"`
HasGroundTruth bool `json:"has_ground_truth,omitempty"`
FileSize uint64 `json:"file_size,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
}
// StarMetric represents a star metric configuration.
type StarMetric struct {
MetricUUID string `json:"metric_uuid,omitempty"`
Name string `json:"name,omitempty"`
SuccessThresholdPct *int32 `json:"success_threshold_pct,omitempty"` // Deprecated
SuccessThreshold *float32 `json:"success_threshold,omitempty"`
}
// KnowledgeBase represents a Gradient AI Knowledge Base
type KnowledgeBase struct {
AddedToAgentAt *Timestamp `json:"added_to_agent_at,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
DatabaseId string `json:"database_id,omitempty"`
EmbeddingModelUuid string `json:"embedding_model_uuid,omitempty"`
IsPublic bool `json:"is_public,omitempty"`
LastIndexingJob *LastIndexingJob `json:"last_indexing_job,omitempty"`
Name string `json:"name,omitempty"`
ProjectId string `json:"project_id,omitempty"`
Region string `json:"region,omitempty"`
Tags []string `json:"tags,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
UserId string `json:"user_id,omitempty"`
Uuid string `json:"uuid,omitempty"`
IsDeleted bool `json:"is_deleted,omitempty"`
}
// LastIndexingJob represents the last indexing job description of a Gradient AI Knowledge Base
type LastIndexingJob struct {
CompletedDatasources int `json:"completed_datasources,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
DataSourceUuids []string `json:"data_source_uuids,omitempty"`
FinishedAt *Timestamp `json:"finished_at,omitempty"`
KnowledgeBaseUuid string `json:"knowledge_base_uuid,omitempty"`
Phase string `json:"phase,omitempty"`
StartedAt *Timestamp `json:"started_at,omitempty"`
Status string `json:"status,omitempty"`
Tokens int `json:"tokens,omitempty"`
TotalDatasources int `json:"total_datasources,omitempty"`
TotalItemsFailed string `json:"total_items_failed,omitempty"`
TotalItemsIndexed string `json:"total_items_indexed,omitempty"`
TotalItemsSkipped string `json:"total_items_skipped,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
Uuid string `json:"uuid,omitempty"`
}
// IndexingJobsResponse represents the response from listing indexing jobs
type IndexingJobsResponse struct {
Jobs []LastIndexingJob `json:"jobs"`
Links *Links `json:"links,omitempty"`
Meta *Meta `json:"meta,omitempty"`
}
// IndexingJobResponse represents the response from retrieving a single indexing job
type IndexingJobResponse struct {
Job LastIndexingJob `json:"job"`
}
// CancelIndexingJobRequest represents the request payload for cancelling an indexing job
type CancelIndexingJobRequest struct {
UUID string `json:"uuid"`
}
// IndexedDataSource represents a data source within an indexing job
type IndexedDataSource struct {
CompletedAt *Timestamp `json:"completed_at,omitempty"`
DataSourceUuid string `json:"data_source_uuid,omitempty"`
ErrorDetails string `json:"error_details,omitempty"`
ErrorMsg string `json:"error_msg,omitempty"`
FailedItemCount string `json:"failed_item_count,omitempty"`
IndexedFileCount string `json:"indexed_file_count,omitempty"`
IndexedItemCount string `json:"indexed_item_count,omitempty"`
RemovedItemCount string `json:"removed_item_count,omitempty"`
SkippedItemCount string `json:"skipped_item_count,omitempty"`
StartedAt *Timestamp `json:"started_at,omitempty"`
Status string `json:"status,omitempty"`
TotalBytes string `json:"total_bytes,omitempty"`
TotalBytesIndexed string `json:"total_bytes_indexed,omitempty"`
TotalFileCount string `json:"total_file_count,omitempty"`
}
// IndexingJobDataSourcesResponse represents the response from listing data sources for an indexing job
type IndexingJobDataSourcesResponse struct {
IndexedDataSources []IndexedDataSource `json:"indexed_data_sources"`
}
type AgentChatbotIdentifier struct {
AgentChatbotIdentifier string `json:"agent_chatbot_identifier,omitempty"`
}
// AgentDeployment represents the deployment information of a Gradient AI Agent
type AgentDeployment struct {
CreatedAt *Timestamp `json:"created_at,omitempty"`
Name string `json:"name,omitempty"`
Status string `json:"status,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
Url string `json:"url,omitempty"`
Uuid string `json:"uuid,omitempty"`
Visibility string `json:"visibility,omitempty"`
}
// ChatBot represents the chatbot information of a Gradient AI Agent
type ChatBot struct {
ButtonBackgroundColor string `json:"button_background_color,omitempty"`
Logo string `json:"logo,omitempty"`
Name string `json:"name,omitempty"`
PrimaryColor string `json:"primary_color,omitempty"`
SecondaryColor string `json:"secondary_color,omitempty"`
StartingMessage string `json:"starting_message,omitempty"`
}
// Model represents a Gradient AI Model
type Model struct {
Agreement *Agreement `json:"agreement,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
InferenceName string `json:"inference_name,omitempty"`
InferenceVersion string `json:"inference_version,omitempty"`
IsFoundational bool `json:"is_foundational,omitempty"`
Name string `json:"name,omitempty"`
ParentUuid string `json:"parent_uuid,omitempty"`
Provider string `json:"provider,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
UploadComplete bool `json:"upload_complete,omitempty"`
Url string `json:"url,omitempty"`
Usecases []string `json:"usecases,omitempty"`
Uuid string `json:"uuid,omitempty"`
Version *ModelVersion `json:"version,omitempty"`
}
// Agreement represents the agreement information of a Gradient AI Model
type Agreement struct {
Description string `json:"description,omitempty"`
Name string `json:"name,omitempty"`
Url string `json:"url,omitempty"`
Uuid string `json:"uuid,omitempty"`
}
type ModelVersion struct {
Major int `json:"major,omitempty"`
Minor int `json:"minor,omitempty"`
Patch int `json:"patch,omitempty"`
}
// AgentCreateRequest represents the request to create a new Gradient AI Agent
type AgentCreateRequest struct {
AnthropicKeyUuid string `json:"anthropic_key_uuid,omitempty"`
Description string `json:"description,omitempty"`
Instruction string `json:"instruction,omitempty"`
KnowledgeBaseUuid []string `json:"knowledge_base_uuid,omitempty"`
ModelProviderKeyUuid string `json:"model_provider_key_uuid,omitempty"`
ModelUuid string `json:"model_uuid,omitempty"`
Name string `json:"name,omitempty"`
OpenAiKeyUuid string `json:"open_ai_key_uuid,omitempty"`
ProjectId string `json:"project_id,omitempty"`
Region string `json:"region,omitempty"`
Tags []string `json:"tags,omitempty"`
WorkspaceUuid string `json:"workspace_uuid,omitempty"`
}
// AgentAPIKeyCreateRequest represents the request to create a new Gradient AI Agent API Key
type AgentAPIKeyCreateRequest struct {
AgentUuid string `json:"agent_uuid,omitempty"`
Name string `json:"name,omitempty"`
}
// AgentUpdateRequest represents the request to update an existing Gradient AI Agent
type AgentUpdateRequest struct {
AnthropicKeyUuid string `json:"anthropic_key_uuid,omitempty"`
Description string `json:"description,omitempty"`
Instruction string `json:"instruction,omitempty"`
K int `json:"k,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
ModelUuid string `json:"model_uuid,omitempty"`
Name string `json:"name,omitempty"`
OpenAiKeyUuid string `json:"open_ai_key_uuid,omitempty"`
ProjectId string `json:"project_id,omitempty"`
RetrievalMethod string `json:"retrieval_method,omitempty"`
Region string `json:"region,omitempty"`
Tags []string `json:"tags,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
Uuid string `json:"uuid,omitempty"`
ProvideCitations bool `json:"provide_citations,omitempty"`
}
// AgentAPIKeyUpdateRequest represents the request to update an existing Gradient AI Agent API Key
type AgentAPIKeyUpdateRequest struct {
AgentUuid string `json:"agent_uuid,omitempty"`
APIKeyUuid string `json:"api_key_uuid,omitempty"`
Name string `json:"name,omitempty"`
}
type AnthropicAPIKeyCreateRequest struct {
Name string `json:"name,omitempty"`
ApiKey string `json:"api_key,omitempty"`
}
type AnthropicAPIKeyUpdateRequest struct {
Name string `json:"name,omitempty"`
ApiKey string `json:"api_key,omitempty"`
ApiKeyUuid string `json:"api_key_uuid,omitempty"`
}
type OpenAIAPIKeyCreateRequest struct {
Name string `json:"name,omitempty"`
ApiKey string `json:"api_key,omitempty"`
}
type OpenAIAPIKeyUpdateRequest struct {
Name string `json:"name,omitempty"`
ApiKey string `json:"api_key,omitempty"`
ApiKeyUuid string `json:"api_key_uuid,omitempty"`
}
type KnowledgeBaseCreateRequest struct {
DatabaseID string `json:"database_id"`
DataSources []KnowledgeBaseDataSource `json:"datasources"`
EmbeddingModelUuid string `json:"embedding_model_uuid"`
Name string `json:"name"`
ProjectID string `json:"project_id"`
Region string `json:"region"`
Tags []string `json:"tags"`
VPCUuid string `json:"vpc_uuid"`
}
// KnowledgeBaseDataSource represents a Gradient AI Knowledge Base Data Source
type KnowledgeBaseDataSource struct {
CreatedAt *Timestamp `json:"created_at,omitempty"`
FileUploadDataSource *FileUploadDataSource `json:"file_upload_data_source,omitempty"`
LastIndexingJob *LastIndexingJob `json:"last_indexing_job,omitempty"`
SpacesDataSource *SpacesDataSource `json:"spaces_data_source,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
Uuid string `json:"uuid,omitempty"`
WebCrawlerDataSource *WebCrawlerDataSource `json:"web_crawler_data_source,omitempty"`
}
// WebCrawlerDataSource represents the web crawler data source information
type WebCrawlerDataSource struct {
BaseUrl string `json:"base_url,omitempty"`
CrawlingOption string `json:"crawling_option,omitempty"`
EmbedMedia bool `json:"embed_media,omitempty"`
}
// SpacesDataSource represents the spaces data source information
type SpacesDataSource struct {
BucketName string `json:"bucket_name,omitempty"`
ItemPath string `json:"item_path,omitempty"`
Region string `json:"region,omitempty"`
}
// FileUploadDataSource represents the file upload data source information
type FileUploadDataSource struct {
OriginalFileName string `json:"original_file_name,omitempty"`
Size string `json:"size_in_bytes,omitempty"`
StoredObjectKey string `json:"stored_object_key,omitempty"`
}
type KnowledgeBaseDataSourcesRoot struct {
KnowledgeBaseDatasources []KnowledgeBaseDataSource `json:"knowledge_base_data_sources"`
Links *Links `json:"links"`
Meta *Meta `json:"meta"`
}
type SingleKnowledgeBaseDataSourceRoot struct {
KnowledgeBaseDatasource *KnowledgeBaseDataSource `json:"knowledge_base_data_source"`
Links *Links `json:"links"`
Meta *Meta `json:"meta"`
}
type knowledgebasesRoot struct {
KnowledgeBases []KnowledgeBase `json:"knowledge_bases"`
Links *Links `json:"links"`
Meta *Meta `json:"meta"`
}
type indexingJobsRoot struct {
Jobs []LastIndexingJob `json:"jobs"`
Links *Links `json:"links"`
Meta *Meta `json:"meta"`
}
type knowledgebaseRoot struct {
KnowledgeBase *KnowledgeBase `json:"knowledge_base"`
DatabaseStatus string `json:"database_status,omitempty"`
}
type DeleteDataSourceRoot struct {
DataSourceUuid string `json:"data_source_uuid"`
KnowledgeBaseUuid string `json:"knowledge_base_uuid"`
}
type AgentRouteResponse struct {
ChildAgentUuid string `json:"child_agent_uuid,omitempty"`
ParentAgentUuid string `json:"parent_agent_uuid,omitempty"`
Rollback bool `json:"rollback,omitempty"`
UUID string `json:"uuid,omitempty"`
}
type DeleteKnowledgeBaseRoot struct {
KnowledgeBaseUuid string `json:"uuid"`
}
type DeletedKnowledgeBaseResponse struct {
DataSourceUuid string `json:"data_source_uuid"`
KnowledgeBaseUuid string `json:"knowledge_base_uuid"`
}
type AddKnowledgeBaseDataSourceRequest struct {
KnowledgeBaseUuid string `json:"knowledge_base_uuid"`
SpacesDataSource *SpacesDataSource `json:"spaces_data_source"`
WebCrawlerDataSource *WebCrawlerDataSource `json:"web_crawler_data_source"`
}
type UpdateKnowledgeBaseRequest struct {
DatabaseID string `json:"database_id"`
EmbeddingModelUuid string `json:"embedding_model_uuid"`
Name string `json:"name"`
ProjectID string `json:"project_id"`
Tags []string `json:"tags"`
KnowledgeBaseUUID string `json:"uuid"`
}
// AgentRouteCreateRequest represents a route between a parent and child agent.
type AgentRouteCreateRequest struct {
ChildAgentUuid string `json:"child_agent_uuid,omitempty"`
IfCase string `json:"if_case,omitempty"`
ParentAgentUuid string `json:"parent_agent_uuid,omitempty"`
RouteName string `json:"route_name,omitempty"`
}
// AgentRouteUpdateRequest represents the request to update an existing route between a parent and child agent.
type AgentRouteUpdateRequest struct {
ChildAgentUuid string `json:"child_agent_uuid,omitempty"`
IfCase string `json:"if_case,omitempty"`
ParentAgentUuid string `json:"parent_agent_uuid,omitempty"`
RouteName string `json:"route_name,omitempty"`
UUID string `json:"uuid,omitempty"`
}
type NestedSchema struct {
Type string `json:"type" validate:"required,oneof=string boolean number integer array object"`
Items *NestedSchema `json:"items,omitempty"`
Properties map[string]*NestedSchema `json:"properties,omitempty"`
Enum []string `json:"enum,omitempty"`
Description string `json:"description,omitempty"`
}
type OpenAPIParameterSchema struct {
Name string `json:"name" validate:"required"`
In string `json:"in" validate:"omitempty,oneof=query header path cookie"`
Schema NestedSchema `json:"schema" validate:"required"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
}
type FunctionInputSchema struct {
Parameters []OpenAPIParameterSchema `json:"parameters" validate:"required,min=1,dive"`
}
type FunctionRouteCreateRequest struct {
AgentUuid string `json:"agent_uuid,omitempty"`
Description string `json:"description,omitempty"`
FaasName string `json:"faas_name,omitempty"`
FaasNamespace string `json:"faas_namespace,omitempty"`
FunctionName string `json:"function_name,omitempty"`
InputSchema FunctionInputSchema `json:"input_schema,omitempty"`
OutputSchema json.RawMessage `json:"output_schema,omitempty"`
}
type FunctionRouteUpdateRequest struct {
AgentUuid string `json:"agent_uuid,omitempty"`
Description string `json:"description,omitempty"`
FaasName string `json:"faas_name,omitempty"`
FaasNamespace string `json:"faas_namespace,omitempty"`
FunctionName string `json:"function_name,omitempty"`
FunctionUuid string `json:"function_uuid,omitempty"`
InputSchema FunctionInputSchema `json:"input_schema,omitempty"`
OutputSchema json.RawMessage `json:"output_schema,omitempty"`
}
type DatacenterRegions struct {
Region string `json:"region"`
InferenceUrl string `json:"inference_url"`
ServesBatch bool `json:"serves_batch"`
ServesInference bool `json:"serves_inference"`
StreamInferenceUrl string `json:"stream_inference_url"`
}
type datacenterRegionsRoot struct {
DatacenterRegions []*DatacenterRegions `json:"regions"`
}
type gradientAgentKBRoot struct {
Agent *Agent `json:"agent"`
}
// ListAgents returns a list of Gradient AI Agents
func (s *GradientAIServiceOp) ListAgents(ctx context.Context, opt *ListOptions) ([]*Agent, *Response, error) {
path, err := addOptions(gradientBasePath, opt)
if err != nil {
return nil, nil, err
}
req, err := s.client.NewRequest(ctx, http.MethodGet, path, nil)
if err != nil {
return nil, nil, err
}
root := new(gradientAgentsRoot)
resp, err := s.client.Do(ctx, req, root)
if err != nil {
return nil, resp, err
}
if l := root.Links; l != nil {
resp.Links = l
}
if m := root.Meta; m != nil {
resp.Meta = m
}
return root.Agents, resp, nil
}
// CreateAgent creates a new Gradient AI Agent by providing the AgentCreateRequest object
func (s *GradientAIServiceOp) CreateAgent(ctx context.Context, create *AgentCreateRequest) (*Agent, *Response, error) {
path := gradientBasePath
if create.ProjectId == "" {
return nil, nil, fmt.Errorf("Project ID is required")
}
if create.Region == "" {
return nil, nil, fmt.Errorf("Region is required")
}
if create.Instruction == "" {
return nil, nil, fmt.Errorf("Instruction is required")
}
if create.ModelUuid == "" {
return nil, nil, fmt.Errorf("ModelUuid is required")
}
if create.Name == "" {
return nil, nil, fmt.Errorf("Name is required")
}
req, err := s.client.NewRequest(ctx, http.MethodPost, path, create)
if err != nil {
return nil, nil, err
}
root := new(gradientAgentRoot)
resp, err := s.client.Do(ctx, req, root)
if err != nil {
return nil, resp, err
}
return root.Agent, resp, nil
}
// ListAgentAPIKeys retrieves list of API Keys associated with the specified Gradient AI agent
func (s *GradientAIServiceOp) ListAgentAPIKeys(ctx context.Context, agentId string, opt *ListOptions) ([]*ApiKeyInfo, *Response, error) {
path := fmt.Sprintf("%s/%s/api_keys", gradientBasePath, agentId)
req, err := s.client.NewRequest(ctx, http.MethodGet, path, nil)
if err != nil {
return nil, nil, err
}
root := new(agentAPIKeysRoot)
resp, err := s.client.Do(ctx, req, root)
if err != nil {
return nil, resp, err
}
if l := root.Links; l != nil {
resp.Links = l
}
if m := root.Meta; m != nil {
resp.Meta = m
}
return root.ApiKeys, resp, nil
}
// CreateAgentAPIKey creates a new API key for the specified Gradient AI agent
func (s *GradientAIServiceOp) CreateAgentAPIKey(ctx context.Context, agentId string, createRequest *AgentAPIKeyCreateRequest) (*ApiKeyInfo, *Response, error) {
path := fmt.Sprintf("%s/%s/api_keys", gradientBasePath, agentId)
createRequest.AgentUuid = agentId
req, err := s.client.NewRequest(ctx, http.MethodPost, path, createRequest)
if err != nil {
return nil, nil, err
}
root := new(agentAPIKeyRoot)
resp, err := s.client.Do(ctx, req, root)
if err != nil {
return nil, resp, err
}
return root.ApiKey, resp, err
}
// UpdateAgentAPIKey updates an existing API key for the specified Gradient AI agent
func (s *GradientAIServiceOp) UpdateAgentAPIKey(ctx context.Context, agentId, apiKeyId string, updateRequest *AgentAPIKeyUpdateRequest) (*ApiKeyInfo, *Response, error) {
path := fmt.Sprintf("%s/%s/api_keys/%s", gradientBasePath, agentId, apiKeyId)
updateRequest.AgentUuid = agentId
req, err := s.client.NewRequest(ctx, http.MethodPut, path, updateRequest)
if err != nil {
return nil, nil, err
}
root := new(agentAPIKeyRoot)
resp, err := s.client.Do(ctx, req, root)
if err != nil {
return nil, resp, err
}
return root.ApiKey, resp, nil
}
// DeleteAgentAPIKey deletes an existing API key for the specified Gradient AI agent
func (s *GradientAIServiceOp) DeleteAgentAPIKey(ctx context.Context, agentId, apiKeyId string) (*ApiKeyInfo, *Response, error) {
path := fmt.Sprintf("%s/%s/api_keys/%s", gradientBasePath, agentId, apiKeyId)
req, err := s.client.NewRequest(ctx, http.MethodDelete, path, nil)
if err != nil {
return nil, nil, err
}
root := new(agentAPIKeyRoot)
resp, err := s.client.Do(ctx, req, root)
if err != nil {
return nil, resp, err
}
return root.ApiKey, resp, nil
}
// RegenerateAgentAPIKey regenerates an API key for the specified Gradient AI agent
func (s *GradientAIServiceOp) RegenerateAgentAPIKey(ctx context.Context, agentId, apiKeyId string) (*ApiKeyInfo, *Response, error) {
path := fmt.Sprintf("%s/%s/api_keys/%s/regenerate", gradientBasePath, agentId, apiKeyId)
req, err := s.client.NewRequest(ctx, http.MethodPut, path, nil)
if err != nil {
return nil, nil, err
}
root := new(agentAPIKeyRoot)
resp, err := s.client.Do(ctx, req, root)
if err != nil {
return nil, resp, err
}
return root.ApiKey, resp, nil
}
// GetAgent returns the details of a Gradient AI Agent based on the Agent UUID
func (s *GradientAIServiceOp) GetAgent(ctx context.Context, id string) (*Agent, *Response, error) {
path := fmt.Sprintf("%s/%s", gradientBasePath, id)
req, err := s.client.NewRequest(ctx, http.MethodGet, path, nil)
if err != nil {
return nil, nil, err
}
root := new(gradientAgentRoot)
resp, err := s.client.Do(ctx, req, root)
if err != nil {
return nil, resp, err
}
return root.Agent, resp, nil
}
// UpdateAgent function updates a Gradient AI Agent properties for the given UUID
func (s *GradientAIServiceOp) UpdateAgent(ctx context.Context, id string, update *AgentUpdateRequest) (*Agent, *Response, error) {