forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
117 lines (116 loc) · 3.78 KB
/
Copy pathutils.ts
File metadata and controls
117 lines (116 loc) · 3.78 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
export type ProviderDefinition = {
id: string;
title: string;
} & { [key: string]: any };
export type ProvidersConfig = {
[key: string]: ProviderDefinition;
}
export const quickStartProviders: ProvidersConfig = {
"openai": {
id: "openai",
title: "OpenAI",
icon: '/icons/openai.png',
envVarName: "OPENAI_API_KEY",
adapterImport: "OpenAIAdapter",
adapterSetup: 'const serviceAdapter = new OpenAIAdapter();'
},
"azure": {
id: "azure",
title: "Azure OpenAI",
icon: '/icons/azure.png',
packageName: "openai",
envVarName: "AZURE_OPENAI_API_KEY",
adapterImport: "OpenAIAdapter",
extraImports: `
import OpenAI from 'openai';
`,
clientSetup: `
const apiKey = process.env["AZURE_OPENAI_API_KEY"];
if (!apiKey) {
throw new Error("The AZURE_OPENAI_API_KEY environment variable is missing or empty.");
}
const openai = new OpenAI({
apiKey: process.env.AZURE_OPENAI_API_KEY,
baseURL: 'https://<your instance name>.openai.azure.com/openai/deployments/<your model>',
defaultQuery: { "api-version": "2024-04-01-preview" },
defaultHeaders: { "api-key": apiKey },
});`,
adapterSetup: 'const serviceAdapter = new OpenAIAdapter({ openai });'
},
"anthropic": {
id: "anthropic",
title: "Anthropic (Claude)",
icon: '/icons/anthropic.png',
envVarName: "ANTHROPIC_API_KEY",
adapterImport: "AnthropicAdapter",
adapterSetup: 'const serviceAdapter = new AnthropicAdapter();'
},
"groq": {
id: "groq",
title: "Groq",
icon: '/icons/groq.png',
envVarName: "GROQ_API_KEY",
adapterImport: "GroqAdapter",
adapterSetup: 'const serviceAdapter = new GroqAdapter({ model: "<model-name>" });'
},
"google": {
id: "google",
title: "Google Generative AI (Gemini)",
icon: '/icons/google.png',
envVarName: "GOOGLE_API_KEY",
adapterImport: "GoogleGenerativeAIAdapter",
adapterSetup: 'const serviceAdapter = new GoogleGenerativeAIAdapter({ model: <optional model choice> });'
},
"langchain": {
id: 'langchain',
title: 'LangChain (any model)',
icon: '/icons/langchain.png',
packageName: "@langchain/openai",
envVarName: "OPENAI_API_KEY",
adapterImport: "LangChainAdapter",
extraImports: `
import { ChatOpenAI } from "@langchain/openai";
`,
clientSetup: 'const model = new ChatOpenAI({ model: "gpt-4o", apiKey: process.env.OPENAI_API_KEY });',
adapterSetup: `
const serviceAdapter = new LangChainAdapter({
chainFn: async ({ messages, tools }) => {
return model.bindTools(tools).stream(messages);
// or optionally enable strict mode
// return model.bindTools(tools, { strict: true }).stream(messages);
}
});`
},
"openai-assistants": {
id: "openai-assistants",
title: "OpenAI Assistants API",
icon: '/icons/openai.png',
packageName: "openai",
envVarName: "OPENAI_API_KEY",
adapterImport: "OpenAIAssistantAdapter",
extraImports: [
'import OpenAI from \'openai\';'
],
clientSetup: `
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
organization: "<your-organization-id>"
});
`,
adapterSetup: `
const serviceAdapter = new OpenAIAssistantAdapter({
openai,
assistantId: "<your-assistant-id>",
codeInterpreterEnabled: true,
fileSearchEnabled: true,
});
`
},
"empty": {
id: "empty",
title: "Empty Adapter (CoAgents Only)",
icon: '/icons/empty.svg',
adapterImport: "EmptyAdapter",
adapterSetup: 'const serviceAdapter = new EmptyAdapter();'
},
};