Skip to content

Commit

Permalink
♻️ refactor: refactor with OpenAPIConvertor
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx authored and canisminor1990 committed Dec 15, 2023
1 parent 04ff2d5 commit 605b3bf
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 1,810 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
"nanoid": "^5",
"next": "^14.0.2",
"openai": "^4.17.3",
"openapi-jsonschema-parameters": "^12.1.3",
"polished": "^4",
"posthog-js": "^1",
"query-string": "^8",
Expand All @@ -118,7 +117,6 @@
"remark-html": "^15",
"semver": "^7",
"sharp": "^0.33",
"swagger-client": "^3.24.5",
"swr": "^2",
"systemjs": "^6",
"ts-md5": "^1",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/default/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default {
confirmDeleteDevPlugin: '即将删除该本地插件,删除后将无法找回,是否删除该插件?',
customParams: {
useProxy: {
label: '使用代理请求安装插件(如错误提示跨域访问,可开启后重试)',
label: '通过代理安装(如遇到跨域访问错误,可尝试开启该选项后重新安装)',
},
},
deleteSuccess: '插件删除成功',
Expand Down
346 changes: 0 additions & 346 deletions src/services/__tests__/__snapshots__/plugin.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -28,352 +28,6 @@ exports[`PluginService > can parse the OpenAI plugin 1`] = `
}
`;

exports[`PluginService > convertOpenAPIToPluginSchema > can convert OpenAPI v2 MJ openAPI 1`] = `
[
{
"description": "查询所有账号",
"name": "listUsingGET",
"parameters": {
"properties": {},
"type": "object",
},
},
{
"description": "指定ID获取账号",
"name": "fetchUsingGET",
"parameters": {
"properties": {
"id": {
"description": "账号ID",
"type": "string",
},
},
"required": [],
"type": "object",
},
},
{
"description": "提交Blend任务",
"name": "blendUsingPOST",
"parameters": {
"$$ref": "http://localhost:3000/#/definitions/Blend提交参数",
"properties": {
"base64Array": {
"description": "图片base64数组",
"example": [
"data:image/png;base64,xxx1",
"data:image/png;base64,xxx2",
],
"items": {
"type": "string",
},
"refType": "string",
"type": "array",
},
"dimensions": {
"description": "比例: PORTRAIT(2:3); SQUARE(1:1); LANDSCAPE(3:2)",
"enum": [
"PORTRAIT",
"SQUARE",
"LANDSCAPE",
],
"example": "SQUARE",
"refType": null,
"type": "string",
},
"notifyHook": {
"description": "回调地址, 为空时使用全局notifyHook",
"refType": null,
"type": "string",
},
"state": {
"description": "自定义参数",
"refType": null,
"type": "string",
},
},
"required": [
"base64Array",
],
"title": "Blend提交参数",
"type": "object",
},
},
{
"description": "绘图变化",
"name": "changeUsingPOST",
"parameters": {
"$$ref": "http://localhost:3000/#/definitions/变化任务提交参数",
"properties": {
"action": {
"description": "UPSCALE(放大); VARIATION(变换); REROLL(重新生成)",
"enum": [
"UPSCALE",
"VARIATION",
"REROLL",
],
"example": "UPSCALE",
"type": "string",
},
"index": {
"description": "序号(1~4), action为UPSCALE,VARIATION时必传",
"example": 1,
"exclusiveMaximum": false,
"exclusiveMinimum": false,
"format": "int32",
"maximum": 4,
"minimum": 1,
"type": "integer",
},
"notifyHook": {
"description": "回调地址, 为空时使用全局notifyHook",
"type": "string",
},
"state": {
"description": "自定义参数",
"type": "string",
},
"taskId": {
"description": "任务ID",
"example": "1320098173412546",
"type": "string",
},
},
"required": [
"action",
"taskId",
],
"title": "变化任务提交参数",
"type": "object",
},
},
{
"description": "提交Describe任务",
"name": "describeUsingPOST",
"parameters": {
"$$ref": "http://localhost:3000/#/definitions/Describe提交参数",
"properties": {
"base64": {
"description": "图片base64",
"example": "data:image/png;base64,xxx",
"type": "string",
},
"notifyHook": {
"description": "回调地址, 为空时使用全局notifyHook",
"type": "string",
},
"state": {
"description": "自定义参数",
"type": "string",
},
},
"required": [
"base64",
],
"title": "Describe提交参数",
"type": "object",
},
},
{
"description": "提交Imagine任务",
"name": "imagineUsingPOST",
"parameters": {
"$$ref": "http://localhost:3000/#/definitions/Imagine提交参数",
"properties": {
"base64Array": {
"description": "垫图base64数组",
"items": {
"type": "string",
},
"type": "array",
},
"notifyHook": {
"description": "回调地址, 为空时使用全局notifyHook",
"type": "string",
},
"prompt": {
"description": "提示词",
"example": "Cat",
"type": "string",
},
"state": {
"description": "自定义参数",
"type": "string",
},
},
"required": [
"prompt",
],
"title": "Imagine提交参数",
"type": "object",
},
},
{
"description": "绘图变化-simple",
"name": "simpleChangeUsingPOST",
"parameters": {
"$$ref": "http://localhost:3000/#/definitions/变化任务提交参数-simple",
"properties": {
"content": {
"description": "变化描述: ID $action$index",
"example": "1320098173412546 U2",
"type": "string",
},
"notifyHook": {
"description": "回调地址, 为空时使用全局notifyHook",
"type": "string",
},
"state": {
"description": "自定义参数",
"type": "string",
},
},
"required": [
"content",
],
"title": "变化任务提交参数-simple",
"type": "object",
},
},
{
"description": "查询所有任务",
"name": "listUsingGET_1",
"parameters": {
"properties": {},
"type": "object",
},
},
{
"description": "根据ID列表查询任务",
"name": "listByIdsUsingPOST",
"parameters": {
"$$ref": "http://localhost:3000/#/definitions/任务查询参数",
"properties": {
"ids": {
"items": {
"type": "string",
},
"type": "array",
},
},
"title": "任务查询参数",
"type": "object",
},
},
{
"description": "查询任务队列",
"name": "queueUsingGET",
"parameters": {
"properties": {},
"type": "object",
},
},
{
"description": "指定ID获取任务",
"name": "fetchUsingGET_1",
"parameters": {
"properties": {
"id": {
"description": "任务ID",
"type": "string",
},
},
"required": [],
"type": "object",
},
},
]
`;

exports[`PluginService > convertOpenAPIToPluginSchema > can convert OpenAPI v3.1 to lobe apis 1`] = `
[
{
"description": "Read Course Segments",
"name": "read_course_segments_course_segments__get",
"parameters": {
"properties": {},
"type": "object",
},
},
{
"description": "Read Problem Set Item",
"name": "read_problem_set_item_problem_set__problem_set_id___question_number__get",
"parameters": {
"properties": {
"problem_set_id": {
"title": "Problem Set Id",
"type": "integer",
},
"question_number": {
"title": "Question Number",
"type": "integer",
},
},
"required": [
"problem_set_id",
"question_number",
],
"type": "object",
},
},
{
"description": "Read Random Problem Set Items",
"name": "read_random_problem_set_items_problem_set_random__problem_set_id___n_items__get",
"parameters": {
"properties": {
"n_items": {
"title": "N Items",
"type": "integer",
},
"problem_set_id": {
"title": "Problem Set Id",
"type": "integer",
},
},
"required": [
"problem_set_id",
"n_items",
],
"type": "object",
},
},
{
"description": "Read Range Of Problem Set Items",
"name": "read_range_of_problem_set_items_problem_set_range__problem_set_id___start___end__get",
"parameters": {
"properties": {
"end": {
"title": "End",
"type": "integer",
},
"problem_set_id": {
"title": "Problem Set Id",
"type": "integer",
},
"start": {
"title": "Start",
"type": "integer",
},
},
"required": [
"problem_set_id",
"start",
"end",
],
"type": "object",
},
},
{
"description": "Read User Id",
"name": "read_user_id_user__get",
"parameters": {
"properties": {},
"type": "object",
},
},
]
`;

exports[`PluginService > getPluginManifest > support OpenAPI manifest > should get plugin manifest 1`] = `
{
"$schema": "../node_modules/@lobehub/chat-plugin-sdk/schema.json",
Expand Down
Loading

0 comments on commit 605b3bf

Please sign in to comment.