| 
1 | 1 | <script>  | 
2 |  | -    import { Button, Card, CardBody, CardHeader, Col, Table } from '@sveltestrap/sveltestrap';  | 
 | 2 | +    import { Card, CardBody, CardHeader, Input, Table } from '@sveltestrap/sveltestrap';  | 
3 | 3 |     import InPlaceEdit from '$lib/common/InPlaceEdit.svelte'  | 
4 | 4 |     import { format } from '$lib/helpers/datetime';  | 
 | 5 | +	import { onMount } from 'svelte';  | 
 | 6 | +	import { getAgentTools } from '$lib/services/agent-service';  | 
5 | 7 | 
  | 
6 | 8 |     /** @type {import('$types').AgentModel} */  | 
7 | 9 |     export let agent;  | 
8 | 10 | 
  | 
9 | 11 |     /** @type {string[]} */  | 
10 | 12 |     export let profiles = [];  | 
11 | 13 | 
  | 
 | 14 | +    /** @type {string[]} */  | 
 | 15 | +    export let tools = [];  | 
 | 16 | +
  | 
 | 17 | +    /** @type {string[]} */  | 
 | 18 | +    let toolOptions = [];  | 
 | 19 | +
  | 
12 | 20 |     const profileLimit = 10;  | 
 | 21 | +    const toolLimit = 10;  | 
 | 22 | +
  | 
 | 23 | +    onMount(() => {  | 
 | 24 | +        getAgentTools().then(data => {  | 
 | 25 | +            const tools = data?.filter(x => x?.trim()?.length > 0) || [];  | 
 | 26 | +            toolOptions = ["", ...tools];  | 
 | 27 | +        });  | 
 | 28 | +    });  | 
13 | 29 | 
  | 
14 | 30 |     function addProfile() {  | 
15 | 31 |         if (!!!agent) return;  | 
 | 
26 | 42 |         agent.profiles = profiles;  | 
27 | 43 |     }  | 
28 | 44 | 
  | 
 | 45 | +    function addTool() {  | 
 | 46 | +        if (!!!agent) return;  | 
 | 47 | +
  | 
 | 48 | +        tools = [...tools, ''];  | 
 | 49 | +        agent.tools = tools;  | 
 | 50 | +    }  | 
 | 51 | +
  | 
 | 52 | +    /**  | 
 | 53 | +	 * @param {number} index  | 
 | 54 | +	 */  | 
 | 55 | +    function removeTool(index) {  | 
 | 56 | +        tools = tools.filter((x, idx) => idx !== index);  | 
 | 57 | +        agent.tools = tools;  | 
 | 58 | +    }  | 
 | 59 | +
  | 
29 | 60 |     function chatWithAgent() {  | 
30 | 61 |         if (!!!agent?.id) return;  | 
31 | 62 |           | 
 | 
86 | 117 |                     <tr>  | 
87 | 118 |                         <th class="agent-prop-key">Profiles</th>  | 
88 | 119 |                         <td>  | 
89 |  | -                            <div class="agent-profile-container">  | 
 | 120 | +                            <div class="agent-prop-list-container">  | 
90 | 121 |                                 {#each profiles as profile, index}  | 
91 |  | -                                <div style="display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 5px;">  | 
 | 122 | +                                <div class="edit-wrapper">  | 
92 | 123 |                                     <input  | 
93 |  | -                                        class="form-control"  | 
94 |  | -                                        style="flex: 0.9; border: none; padding-left: 0px;"  | 
 | 124 | +                                        class="form-control edit-text-box"  | 
95 | 125 |                                         type="text"  | 
96 | 126 |                                         placeholder="Typing here..."  | 
97 |  | -                                        bind:value={profile} maxlength={30} />  | 
98 |  | -                                    <div style="flex: 0.1; display: flex; align-items: center;">  | 
 | 127 | +                                        maxlength={30}  | 
 | 128 | +                                        bind:value={profile}  | 
 | 129 | +                                    />  | 
 | 130 | +                                    <div class="delete-icon">  | 
99 | 131 |                                         <i  | 
100 | 132 |                                             class="bx bxs-no-entry"  | 
101 |  | -                                            style="cursor: pointer; font-size: 18px; color: red;"  | 
102 | 133 |                                             role="link"  | 
103 | 134 |                                             tabindex="0"  | 
104 | 135 |                                             on:keydown={() => {}}  | 
 | 
108 | 139 |                                 </div>  | 
109 | 140 |                                 {/each}  | 
110 | 141 |                                 {#if profiles?.length < profileLimit}  | 
111 |  | -                                <div style="font-size: 20px;">  | 
 | 142 | +                                <div class="list-add">  | 
112 | 143 |                                     <i  | 
113 | 144 |                                         class="bx bx bx-list-plus"  | 
114 |  | -                                        style="cursor: pointer;"  | 
115 | 145 |                                         role="link"  | 
116 | 146 |                                         tabindex="0"  | 
117 | 147 |                                         on:keydown={() => {}}  | 
 | 
122 | 152 |                             </div>  | 
123 | 153 |                         </td>  | 
124 | 154 |                     </tr>  | 
 | 155 | +                    <tr>  | 
 | 156 | +                        <th class="agent-prop-key">Tools</th>  | 
 | 157 | +                        <td>  | 
 | 158 | +                            <div class="agent-prop-list-container">  | 
 | 159 | +                                {#each tools as tool, index}  | 
 | 160 | +                                <div class="edit-wrapper">  | 
 | 161 | +                                    <Input type="select" class="edit-text-box" bind:value={tool}>  | 
 | 162 | +                                        {#each toolOptions as option}  | 
 | 163 | +                                            <option selected={tool === option}>{option}</option>  | 
 | 164 | +                                        {/each}  | 
 | 165 | +                                    </Input>  | 
 | 166 | +                                    <div class="delete-icon">  | 
 | 167 | +                                        <i  | 
 | 168 | +                                            class="bx bxs-no-entry"  | 
 | 169 | +                                            role="link"  | 
 | 170 | +                                            tabindex="0"  | 
 | 171 | +                                            on:keydown={() => {}}  | 
 | 172 | +                                            on:click={() => removeTool(index)}  | 
 | 173 | +                                        />  | 
 | 174 | +                                    </div>  | 
 | 175 | +                                </div>  | 
 | 176 | +                                {/each}  | 
 | 177 | +                                {#if tools?.length < toolLimit}  | 
 | 178 | +                                <div class="list-add">  | 
 | 179 | +                                    <i  | 
 | 180 | +                                        class="bx bx bx-list-plus"  | 
 | 181 | +                                        role="link"  | 
 | 182 | +                                        tabindex="0"  | 
 | 183 | +                                        on:keydown={() => {}}  | 
 | 184 | +                                        on:click={() => addTool()}  | 
 | 185 | +                                    />  | 
 | 186 | +                                </div>  | 
 | 187 | +                                {/if}  | 
 | 188 | +                            </div>  | 
 | 189 | +                        </td>  | 
 | 190 | +                    </tr>  | 
125 | 191 |                     <tr>  | 
126 | 192 |                         <th class="agent-prop-key">Status</th>  | 
127 | 193 |                         <td>							  | 
 | 
0 commit comments