From 7cbc0ccde86d5c5ae5fdbc50eba1ad40b5e6547e Mon Sep 17 00:00:00 2001 From: Haiping Chen Date: Fri, 2 Feb 2024 16:35:23 -0600 Subject: [PATCH] AgentTask --- src/lib/helpers/types.js | 20 ++ src/lib/services/api-endpoints.js | 3 + src/lib/services/task-service.js | 18 ++ src/routes/(home)/+page.svelte | 2 +- src/routes/page/conversation/+page.svelte | 4 +- .../[conversationId]/conv-dialogs.svelte | 17 +- src/routes/page/task/+page.svelte | 236 ++++++++++++++++++ 7 files changed, 293 insertions(+), 7 deletions(-) create mode 100644 src/lib/services/task-service.js create mode 100644 src/routes/page/task/+page.svelte diff --git a/src/lib/helpers/types.js b/src/lib/helpers/types.js index e7cbeb78..ce26278b 100644 --- a/src/lib/helpers/types.js +++ b/src/lib/helpers/types.js @@ -124,6 +124,26 @@ * @property {AgentLlmConfig} llmConfig - LLM settings. */ +/** + * @typedef {Object} AgentTaskFilter + * @property {Pagination} pager - Pagination + * @property {string} [agentId] - The agent id. + */ + +/** + * @typedef {Object} AgentTaskViewModel + * @property {string} id - Task id. + * @property {string} name - Task name. + * @property {string} description - Description. + * @property {string} content - Task detail. + * @property {boolean} enabled + * @property {Date} created_datetime + * @property {Date} updated_datetime + * @property {string} agent_id - Description. + * @property {string} agent_name - Task detail. + */ + + /** * @typedef {Object} InstructMessageModel * @property {string} [instruction] - User provided prompt instead of predefined template. diff --git a/src/lib/services/api-endpoints.js b/src/lib/services/api-endpoints.js index 54691189..0974cd9a 100644 --- a/src/lib/services/api-endpoints.js +++ b/src/lib/services/api-endpoints.js @@ -23,6 +23,9 @@ export const endpoints = { agentDetailUrl: `${host}/agent/{id}`, agentRefreshUrl: `${host}/refresh-agents`, + // agent task + agentTaskListUrl: `${host}/agent/tasks`, + // agent instruct instructCompletionUrl: `${host}/instruct/{agentId}`, diff --git a/src/lib/services/task-service.js b/src/lib/services/task-service.js new file mode 100644 index 00000000..a852a3eb --- /dev/null +++ b/src/lib/services/task-service.js @@ -0,0 +1,18 @@ +import { endpoints } from '$lib/services/api-endpoints.js'; +import { replaceUrl } from '$lib/helpers/http'; +import axios from 'axios'; + +/** + * Get agent list + * @param {import('$types').AgentTaskFilter} filter + * @returns {Promise>} + */ +export async function getAgentTasks(filter) { + const response = await axios.get(endpoints.agentTaskListUrl, { params: filter, + paramsSerializer: { + dots: true, + indexes: null, + } + }); + return response.data; +} \ No newline at end of file diff --git a/src/routes/(home)/+page.svelte b/src/routes/(home)/+page.svelte index e6295916..a5ab0ebc 100644 --- a/src/routes/(home)/+page.svelte +++ b/src/routes/(home)/+page.svelte @@ -35,7 +35,7 @@ - +
diff --git a/src/routes/page/conversation/+page.svelte b/src/routes/page/conversation/+page.svelte index 69b50d82..bcd993a5 100644 --- a/src/routes/page/conversation/+page.svelte +++ b/src/routes/page/conversation/+page.svelte @@ -246,9 +246,9 @@
  • - openDeleteModal(conv.id)} class="btn btn-sm btn-soft-danger"> +
  • diff --git a/src/routes/page/conversation/[conversationId]/conv-dialogs.svelte b/src/routes/page/conversation/[conversationId]/conv-dialogs.svelte index 080d23a3..d78ea551 100644 --- a/src/routes/page/conversation/[conversationId]/conv-dialogs.svelte +++ b/src/routes/page/conversation/[conversationId]/conv-dialogs.svelte @@ -13,6 +13,15 @@ onMount(async () => { dialogs = await GetDialogs(conversation.id); }); + + /** + * @param {import('$types').ChatResponseModel} dialog + * @returns {boolean} + */ + function showInRight(dialog) { + const sender = dialog.sender; + return sender.role != "client" && sender.role != "user"; + } @@ -24,14 +33,14 @@
  • - +
    diff --git a/src/routes/page/task/+page.svelte b/src/routes/page/task/+page.svelte new file mode 100644 index 00000000..fd3780ba --- /dev/null +++ b/src/routes/page/task/+page.svelte @@ -0,0 +1,236 @@ + + + + + + + + + +
    +
    Task List
    +
    + searchTasks(e)}> + + + + + Action + + +
    +
    +
    + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + {#each tasks.items as task} + + + + + + + + + + {/each} + +
    NameDescriptionAgentContentUpdated DateStatusAction
    + {task.name} + {task.description}{task.agent_name}{@html replaceNewLine(task.content)}{utcToLocal(task.updated_datetime)}{task.enabled ? "Enabled" : "Disabled"} +
      +
    • + +
    • +
    +
    +
    + +
    +
    + +
    \ No newline at end of file