From 6b565531f8afe1f71ac39f321bbe2e8ec7f3de84 Mon Sep 17 00:00:00 2001 From: joelhulen Date: Fri, 13 Dec 2024 10:51:13 -0500 Subject: [PATCH] Add prompt editor --- .../ManagementPortal/components/Sidebar.vue | 1 + src/ui/ManagementPortal/js/api.ts | 19 + .../ManagementPortal/pages/prompts/create.vue | 434 ++++++++++++++++++ .../pages/prompts/edit/[promptName].vue | 13 + .../ManagementPortal/pages/prompts/index.vue | 153 ++++++ 5 files changed, 620 insertions(+) create mode 100644 src/ui/ManagementPortal/pages/prompts/create.vue create mode 100644 src/ui/ManagementPortal/pages/prompts/edit/[promptName].vue create mode 100644 src/ui/ManagementPortal/pages/prompts/index.vue diff --git a/src/ui/ManagementPortal/components/Sidebar.vue b/src/ui/ManagementPortal/components/Sidebar.vue index 408c82ef31..841f994952 100644 --- a/src/ui/ManagementPortal/components/Sidebar.vue +++ b/src/ui/ManagementPortal/components/Sidebar.vue @@ -26,6 +26,7 @@
  • Create New Agent
  • All Agents
  • My Agents
  • +
  • Agent Prompts
  • diff --git a/src/ui/ManagementPortal/js/api.ts b/src/ui/ManagementPortal/js/api.ts index 166ab78800..6daf14b006 100644 --- a/src/ui/ManagementPortal/js/api.ts +++ b/src/ui/ManagementPortal/js/api.ts @@ -543,6 +543,25 @@ export default { /* Prompts */ + async getPrompts(): Promise[] | null> { + try { + const data = await this.fetch(`/instances/${this.instanceId}/providers/FoundationaLLM.Prompt/prompts?api-version=${this.apiVersion}`); + return data as ResourceProviderGetResult[]; + } catch (error) { + return null; + } + }, + + async getPromptByName(promptName: string): Promise | null> { + // Attempt to retrieve the prompt. If it doesn't exist, return an empty object. + try { + const data = await this.fetch(`/instances/${this.instanceId}/providers/FoundationaLLM.Prompt/prompts/${promptName}?api-version=${this.apiVersion}`); + return data[0]; + } catch (error) { + return null; + } + }, + async getPrompt(promptId: string): Promise | null> { // Attempt to retrieve the prompt. If it doesn't exist, return an empty object. try { diff --git a/src/ui/ManagementPortal/pages/prompts/create.vue b/src/ui/ManagementPortal/pages/prompts/create.vue new file mode 100644 index 0000000000..3a312fc784 --- /dev/null +++ b/src/ui/ManagementPortal/pages/prompts/create.vue @@ -0,0 +1,434 @@ +