stash code

This commit is contained in:
lloydzhou
2024-08-29 19:55:09 +08:00
parent d2cb984ced
commit 571ce11e53
5 changed files with 213 additions and 5 deletions

View File

@@ -54,6 +54,7 @@ import {
useAppConfig,
DEFAULT_TOPIC,
ModelType,
usePluginStore,
} from "../store";
import {
@@ -440,6 +441,71 @@ export function ChatActions(props: {
const config = useAppConfig();
const navigate = useNavigate();
const chatStore = useChatStore();
const pluginStore = usePluginStore();
console.log("pluginStore", pluginStore.getAll());
// test
if (pluginStore.getAll().length == 0) {
pluginStore.create({
title: "Pet API",
version: "1.0.0",
content: `{
"openapi": "3.0.2",
"info": {
"title": "Pet API",
"version": "1.0.0"
},
"paths": {
"/api/pets": {
"get": {
"operationId": "getPets",
"description": "Returns all pets from the system that the user has access to",
"responses": {
"200": {
"description": "List of Pets",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Pet"
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Pet": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"type": {
"type": "string",
"enum": [
"cat",
"dog"
]
},
"name": {
"type": "string"
}
},
"required": [
"id",
"type"
]
}
}
}
}`,
});
}
// switch themes
const theme = config.theme;
@@ -738,15 +804,22 @@ export function ChatActions(props: {
title: Locale.Plugin.Artifacts,
value: Plugin.Artifacts,
},
]}
].concat(
pluginStore
.getAll()
.map((item) => ({
title: `${item.title}@${item.version}`,
value: item.id,
})),
)}
onClose={() => setShowPluginSelector(false)}
onSelection={(s) => {
const plugin = s[0];
chatStore.updateCurrentSession((session) => {
session.mask.plugin = s;
});
if (plugin) {
showToast(plugin);
if (s.includes(Plugin.Artifacts)) {
showToast(Plugin.Artifacts);
}
}}
/>