Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature plugin (GPTs like action based on function call) #5331

Merged
merged 41 commits into from
Sep 6, 2024
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
c99cd31
add openapi-client-axios
lloydzhou Aug 24, 2024
f5209fc
stash code
lloydzhou Aug 28, 2024
29b5cd9
ts error
lloydzhou Aug 28, 2024
f3f6dc5
stash code
lloydzhou Aug 28, 2024
d212df8
stash code
lloydzhou Aug 28, 2024
f7a5f83
stash code
lloydzhou Aug 28, 2024
d58b99d
stash code
lloydzhou Aug 28, 2024
341a52a
stash code
lloydzhou Aug 28, 2024
7fc0d11
create common function stream for fetchEventSource
lloydzhou Aug 29, 2024
d2cb984
add processToolMessage callback
lloydzhou Aug 29, 2024
571ce11
stash code
lloydzhou Aug 29, 2024
cac99e3
add Plugin page
lloydzhou Aug 30, 2024
271f58d
stash code
lloydzhou Aug 30, 2024
9326ff9
ts error
lloydzhou Aug 30, 2024
2214689
add gapier proxy
lloydzhou Aug 30, 2024
b2965e1
update
lloydzhou Aug 30, 2024
f652f73
plugin add auth config
lloydzhou Sep 2, 2024
877668b
hotfix
lloydzhou Sep 2, 2024
801b625
claude support function call
lloydzhou Sep 2, 2024
078305f
kimi support function call
lloydzhou Sep 2, 2024
6435e7a
update readme
lloydzhou Sep 2, 2024
3ec67f9
add load from url
lloydzhou Sep 2, 2024
2b317f6
add config auth location
lloydzhou Sep 3, 2024
236736d
remove no need code
lloydzhou Sep 3, 2024
4fdd997
hotfix
lloydzhou Sep 3, 2024
d30351e
update readme
lloydzhou Sep 3, 2024
c7bc93b
Merge remote-tracking branch 'connectai/main' into feature/plugin
lloydzhou Sep 3, 2024
0a5522d
update
lloydzhou Sep 3, 2024
7180ed9
hotfix
lloydzhou Sep 3, 2024
6ab6b3d
remove no need code
lloydzhou Sep 3, 2024
04e1ab6
update readme
lloydzhou Sep 4, 2024
f9a047a
using tauri http api run plugin to fixed cors in App
lloydzhou Sep 4, 2024
09aec7b
using tauri http api run plugin to fixed cors in App
lloydzhou Sep 4, 2024
9820193
Merge pull request #6 from ConnectAI-E/feature/plugin-app-cors
lloydzhou Sep 4, 2024
b590d08
disable nextjs proxy, then can using dalle as plugin
lloydzhou Sep 5, 2024
caf50b6
move artifacts into mask settings
lloydzhou Sep 5, 2024
80b8f95
move artifacts into mask settings
lloydzhou Sep 5, 2024
f32dd69
Merge pull request #7 from ConnectAI-E/feature/plugin-artifact
lloydzhou Sep 5, 2024
7c0acc7
hotfix tools empty array
lloydzhou Sep 5, 2024
7455978
default enable artifact
lloydzhou Sep 6, 2024
9275f2d
add awesome plugin repo url
lloydzhou Sep 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add config auth location
lloydzhou committed Sep 3, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 2b317f60c87aca80b1a2c7b5b36c13817618d818
1 change: 1 addition & 0 deletions app/components/plugin.module.scss
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
max-height: 240px;
overflow-y: auto;
white-space: pre-wrap;
min-width: 300px;
}
}

24 changes: 24 additions & 0 deletions app/components/plugin.tsx
Original file line number Diff line number Diff line change
@@ -249,6 +249,30 @@ export function PluginPage() {
<option value="custom">{Locale.Plugin.Auth.Custom}</option>
</select>
</ListItem>
{["bearer", "basic", "custom"].includes(
editingPlugin.authType as string,
) && (
<ListItem title={Locale.Plugin.Auth.Location}>
<select
value={editingPlugin?.authLocation}
onChange={(e) => {
pluginStore.updatePlugin(editingPlugin.id, (plugin) => {
plugin.authLocation = e.target.value;
});
}}
>
<option value="header">
{Locale.Plugin.Auth.LocationHeader}
</option>
<option value="query">
{Locale.Plugin.Auth.LocationQuery}
</option>
<option value="body">
{Locale.Plugin.Auth.LocationBody}
</option>
</select>
</ListItem>
)}
{editingPlugin.authType == "custom" && (
<ListItem title={Locale.Plugin.Auth.CustomHeader}>
<input
6 changes: 5 additions & 1 deletion app/locales/cn.ts
Original file line number Diff line number Diff line change
@@ -551,10 +551,14 @@ const cn = {
Basic: "Basic",
Bearer: "Bearer",
Custom: "自定义",
CustomHeader: "自定义头",
CustomHeader: "自定义参数名称",
Token: "Token",
Proxy: "使用代理",
ProxyDescription: "使用代理解决 CORS 错误",
Location: "位置",
LocationHeader: "Header",
LocationQuery: "Query",
LocationBody: "Body",
},
EditModal: {
Title: (readonly: boolean) => `编辑插件 ${readonly ? "(只读)" : ""}`,
6 changes: 5 additions & 1 deletion app/locales/en.ts
Original file line number Diff line number Diff line change
@@ -559,10 +559,14 @@ const en: LocaleType = {
Basic: "Basic",
Bearer: "Bearer",
Custom: "Custom",
CustomHeader: "Custom Header",
CustomHeader: "Parameter Name",
Token: "Token",
Proxy: "Using Proxy",
ProxyDescription: "Using proxies to solve CORS error",
Location: "Location",
LocationHeader: "Header",
LocationQuery: "Query",
LocationBody: "Body",
},
EditModal: {
Title: (readonly: boolean) =>
32 changes: 20 additions & 12 deletions app/store/plugin.ts
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ export type Plugin = {
content: string;
builtin: boolean;
authType?: string;
authLocation?: string;
authHeader?: string;
authToken?: string;
usingProxy?: boolean;
@@ -50,16 +51,17 @@ export const FunctionToolService = {
const definition = yaml.load(plugin.content) as any;
const serverURL = definition?.servers?.[0]?.url;
const baseURL = !!plugin?.usingProxy ? "/api/proxy" : serverURL;
const headers: Record<string, string | undefined> = {
"X-Base-URL": !!plugin?.usingProxy ? serverURL : undefined,
};
if (plugin?.authLocation == "header") {
headers[headerName] = tokenValue;
}
const api = new OpenAPIClientAxios({
definition: yaml.load(plugin.content) as any,
axiosConfigDefaults: {
baseURL,
headers: {
// 'Cache-Control': 'no-cache',
// 'Content-Type': 'application/json', // TODO
[headerName]: tokenValue,
"X-Base-URL": !!plugin?.usingProxy ? serverURL : undefined,
},
headers,
},
});
try {
@@ -111,20 +113,26 @@ export const FunctionToolService = {
funcs: operations.reduce((s, o) => {
// @ts-ignore
s[o.operationId] = function (args) {
const argument = [];
const parameters: Record<string, any> = {};
if (o.parameters instanceof Array) {
o.parameters.forEach((p) => {
// @ts-ignore
argument.push(args[p?.name]);
parameters[p?.name] = args[p?.name];
// @ts-ignore
delete args[p?.name];
});
} else {
argument.push(null);
}
argument.push(args);
if (plugin?.authLocation == "query") {
parameters[headerName] = tokenValue;
} else if (plugin?.authLocation == "body") {
args[headerName] = tokenValue;
}
// @ts-ignore
return api.client[o.operationId].apply(null, argument);
return api.client[o.operationId](
parameters,
args,
api.axiosConfigDefaults,
);
};
return s;
}, {}),