File tree Expand file tree Collapse file tree 4 files changed +129
-0
lines changed
Expand file tree Collapse file tree 4 files changed +129
-0
lines changed Original file line number Diff line number Diff line change 1+ package evals
2+
3+ import (
4+ "github.com/1Password/shell-plugins/sdk"
5+ "github.com/1Password/shell-plugins/sdk/importer"
6+ "github.com/1Password/shell-plugins/sdk/provision"
7+ "github.com/1Password/shell-plugins/sdk/schema"
8+ "github.com/1Password/shell-plugins/sdk/schema/credname"
9+ "github.com/1Password/shell-plugins/sdk/schema/fieldname"
10+ )
11+
12+ func APIKey () schema.CredentialType {
13+ return schema.CredentialType {
14+ Name : credname .APIKey ,
15+ DocsURL : sdk .URL ("https://help.openai.com/en/articles/4936850-where-do-i-find-my-secret-api-key" ),
16+ ManagementURL : sdk .URL ("https://platform.openai.com/account/api-keys" ),
17+ Fields : []schema.CredentialField {
18+ {
19+ Name : fieldname .APIKey ,
20+ MarkdownDescription : "API Key used to authenticate to OpenAI platform." ,
21+ Secret : true ,
22+ Composition : & schema.ValueComposition {
23+ Length : 51 ,
24+ Prefix : "sk-" ,
25+ Charset : schema.Charset {
26+ Uppercase : true ,
27+ Lowercase : true ,
28+ Digits : true ,
29+ },
30+ },
31+ },
32+ },
33+ DefaultProvisioner : provision .EnvVars (defaultEnvVarMapping ),
34+ Importer : importer .TryAll (
35+ importer .TryEnvVarPair (defaultEnvVarMapping ),
36+ )}
37+ }
38+
39+ var defaultEnvVarMapping = map [string ]sdk.FieldName {
40+ "OPENAI_API_KEY" : fieldname .APIKey ,
41+ }
Original file line number Diff line number Diff line change 1+ package evals
2+
3+ import (
4+ "testing"
5+
6+ "github.com/1Password/shell-plugins/sdk"
7+ "github.com/1Password/shell-plugins/sdk/plugintest"
8+ "github.com/1Password/shell-plugins/sdk/schema/fieldname"
9+ )
10+
11+ func TestAPIKeyProvisioner (t * testing.T ) {
12+ plugintest .TestProvisioner (t , APIKey ().DefaultProvisioner , map [string ]plugintest.ProvisionCase {
13+ "default" : {
14+ ItemFields : map [sdk.FieldName ]string {
15+ fieldname .APIKey : "sk-ZJipjm9euld2QcpLIX3NCDUiLgexQkvdn0WGlKayAEXAMPLE" ,
16+ },
17+ ExpectedOutput : sdk.ProvisionOutput {
18+ Environment : map [string ]string {
19+ "OPENAI_API_KEY" : "sk-ZJipjm9euld2QcpLIX3NCDUiLgexQkvdn0WGlKayAEXAMPLE" ,
20+ },
21+ },
22+ },
23+ })
24+ }
25+
26+ func TestAPIKeyImporter (t * testing.T ) {
27+ plugintest .TestImporter (t , APIKey ().Importer , map [string ]plugintest.ImportCase {
28+ "environment" : {
29+ Environment : map [string ]string {
30+ "OPENAI_API_KEY" : "sk-ZJipjm9euld2QcpLIX3NCDUiLgexQkvdn0WGlKayAEXAMPLE" ,
31+ },
32+ ExpectedCandidates : []sdk.ImportCandidate {
33+ {
34+ Fields : map [sdk.FieldName ]string {
35+ fieldname .APIKey : "sk-ZJipjm9euld2QcpLIX3NCDUiLgexQkvdn0WGlKayAEXAMPLE" ,
36+ },
37+ },
38+ },
39+ },
40+ })
41+ }
Original file line number Diff line number Diff line change 1+ package evals
2+
3+ import (
4+ "github.com/1Password/shell-plugins/sdk"
5+ "github.com/1Password/shell-plugins/sdk/needsauth"
6+ "github.com/1Password/shell-plugins/sdk/schema"
7+ "github.com/1Password/shell-plugins/sdk/schema/credname"
8+ )
9+
10+ func OpenAIEvalsCLI () schema.Executable {
11+ return schema.Executable {
12+ Name : "OpenAI Evals CLI" ,
13+ Runs : []string {"oaieval" },
14+ DocsURL : sdk .URL ("https://github.com/openai/evals/blob/main/README.md" ),
15+ NeedsAuth : needsauth .IfAll (
16+ needsauth .NotForHelpOrVersion (),
17+ needsauth .NotWithoutArgs (),
18+ ),
19+ Uses : []schema.CredentialUsage {
20+ {
21+ Name : credname .APIKey ,
22+ },
23+ },
24+ }
25+ }
Original file line number Diff line number Diff line change 1+ package evals
2+
3+ import (
4+ "github.com/1Password/shell-plugins/sdk"
5+ "github.com/1Password/shell-plugins/sdk/schema"
6+ )
7+
8+ func New () schema.Plugin {
9+ return schema.Plugin {
10+ Name : "evals" ,
11+ Platform : schema.PlatformInfo {
12+ Name : "OpenAI Evals" ,
13+ Homepage : sdk .URL ("https://github.com/openai/evals" ),
14+ },
15+ Credentials : []schema.CredentialType {
16+ APIKey (),
17+ },
18+ Executables : []schema.Executable {
19+ OpenAIEvalsCLI (),
20+ },
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments