melhorias
This commit is contained in:
parent
0b77706caa
commit
7205477bfa
@ -31,7 +31,9 @@ if (props.tool.param_schema) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasParams = computed(() => props.tool.param_schema && props.tool.param_schema.length > 0);
|
const hasParams = computed(
|
||||||
|
() => props.tool.param_schema && props.tool.param_schema.length > 0
|
||||||
|
);
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
emit('close');
|
emit('close');
|
||||||
@ -41,7 +43,10 @@ const runTest = async () => {
|
|||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
testResult.value = null;
|
testResult.value = null;
|
||||||
try {
|
try {
|
||||||
const { data } = await CaptainCustomToolsAPI.test(props.tool.id, testParams.value);
|
const { data } = await CaptainCustomToolsAPI.test(
|
||||||
|
props.tool.id,
|
||||||
|
testParams.value
|
||||||
|
);
|
||||||
testResult.value = data;
|
testResult.value = data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
useAlert(t('CAPTAIN.CUSTOM_TOOLS.TEST.ERROR_MESSAGE'));
|
useAlert(t('CAPTAIN.CUSTOM_TOOLS.TEST.ERROR_MESSAGE'));
|
||||||
@ -64,12 +69,19 @@ defineExpose({ dialogRef });
|
|||||||
>
|
>
|
||||||
<div class="flex flex-col gap-6">
|
<div class="flex flex-col gap-6">
|
||||||
<!-- Params Section -->
|
<!-- Params Section -->
|
||||||
<div v-if="hasParams" class="flex flex-col gap-4 p-4 border rounded-lg border-n-slate-3 bg-n-slate-1">
|
<div
|
||||||
|
v-if="hasParams"
|
||||||
|
class="flex flex-col gap-4 p-4 border rounded-lg border-n-slate-3 bg-n-slate-1"
|
||||||
|
>
|
||||||
<h4 class="text-sm font-medium text-n-slate-12">
|
<h4 class="text-sm font-medium text-n-slate-12">
|
||||||
{{ $t('CAPTAIN.CUSTOM_TOOLS.TEST.PARAMETERS') }}
|
{{ $t('CAPTAIN.CUSTOM_TOOLS.TEST.PARAMETERS') }}
|
||||||
</h4>
|
</h4>
|
||||||
<div class="grid grid-cols-2 gap-4">
|
<div class="grid grid-cols-2 gap-4">
|
||||||
<div v-for="param in tool.param_schema" :key="param.name" class="flex flex-col gap-1">
|
<div
|
||||||
|
v-for="param in tool.param_schema"
|
||||||
|
:key="param.name"
|
||||||
|
class="flex flex-col gap-1"
|
||||||
|
>
|
||||||
<Label :label="param.name" :required="param.required" />
|
<Label :label="param.name" :required="param.required" />
|
||||||
<Input
|
<Input
|
||||||
v-model="testParams[param.name]"
|
v-model="testParams[param.name]"
|
||||||
@ -83,7 +95,11 @@ defineExpose({ dialogRef });
|
|||||||
<!-- Action Button -->
|
<!-- Action Button -->
|
||||||
<div class="flex justify-end">
|
<div class="flex justify-end">
|
||||||
<Button
|
<Button
|
||||||
:label="isLoading ? $t('CAPTAIN.CUSTOM_TOOLS.TEST.TESTING') : $t('CAPTAIN.CUSTOM_TOOLS.TEST.RUN_TEST')"
|
:label="
|
||||||
|
isLoading
|
||||||
|
? $t('CAPTAIN.CUSTOM_TOOLS.TEST.TESTING')
|
||||||
|
: $t('CAPTAIN.CUSTOM_TOOLS.TEST.RUN_TEST')
|
||||||
|
"
|
||||||
:icon="isLoading ? '' : 'i-lucide-play'"
|
:icon="isLoading ? '' : 'i-lucide-play'"
|
||||||
color="blue"
|
color="blue"
|
||||||
:disabled="isLoading"
|
:disabled="isLoading"
|
||||||
@ -106,7 +122,12 @@ defineExpose({ dialogRef });
|
|||||||
: 'bg-red-100 text-red-700'
|
: 'bg-red-100 text-red-700'
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
{{ testResult.status }} {{ testResult.success ? 'OK' : 'Fail' }}
|
{{ testResult.status }}
|
||||||
|
{{
|
||||||
|
testResult.success
|
||||||
|
? $t('INTEGRATION_SETTINGS.OPEN_AI.TESTER.STATUS.OK')
|
||||||
|
: $t('INTEGRATION_SETTINGS.OPEN_AI.TESTER.STATUS.FAIL')
|
||||||
|
}}
|
||||||
</span>
|
</span>
|
||||||
<span class="text-xs text-n-slate-11">
|
<span class="text-xs text-n-slate-11">
|
||||||
{{ $t('CAPTAIN.CUSTOM_TOOLS.TEST.RESPONSE_TIME', { ms: 'N/A' }) }}
|
{{ $t('CAPTAIN.CUSTOM_TOOLS.TEST.RESPONSE_TIME', { ms: 'N/A' }) }}
|
||||||
@ -120,7 +141,9 @@ defineExpose({ dialogRef });
|
|||||||
</span>
|
</span>
|
||||||
<pre
|
<pre
|
||||||
class="p-3 overflow-x-auto text-xs rounded bg-n-slate-2 text-n-slate-11 font-mono max-h-32"
|
class="p-3 overflow-x-auto text-xs rounded bg-n-slate-2 text-n-slate-11 font-mono max-h-32"
|
||||||
>{{ JSON.stringify(testResult.headers, null, 2) }}</pre>
|
>
|
||||||
|
{{ JSON.stringify(testResult.headers, null, 2) }}
|
||||||
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Body -->
|
<!-- Body -->
|
||||||
@ -130,11 +153,15 @@ defineExpose({ dialogRef });
|
|||||||
</span>
|
</span>
|
||||||
<pre
|
<pre
|
||||||
class="p-3 overflow-x-auto text-xs rounded bg-n-slate-2 text-n-slate-12 font-mono max-h-96"
|
class="p-3 overflow-x-auto text-xs rounded bg-n-slate-2 text-n-slate-12 font-mono max-h-96"
|
||||||
>{{ testResult.body }}</pre>
|
>
|
||||||
|
{{ testResult.body }}
|
||||||
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template #footer />
|
<template #footer>
|
||||||
|
<!-- Footer content -->
|
||||||
|
</template>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -8,7 +8,6 @@ const toolsStore = createStore({
|
|||||||
// Custom getters for tools with string IDs
|
// Custom getters for tools with string IDs
|
||||||
getters: {
|
getters: {
|
||||||
getRecords: state => {
|
getRecords: state => {
|
||||||
console.log('[DEBUG captainTools] getRecords called, records:', state.records);
|
|
||||||
return state.records;
|
return state.records;
|
||||||
},
|
},
|
||||||
getRecord: state => id =>
|
getRecord: state => id =>
|
||||||
@ -16,16 +15,13 @@ const toolsStore = createStore({
|
|||||||
},
|
},
|
||||||
actions: mutations => ({
|
actions: mutations => ({
|
||||||
getTools: async ({ commit }) => {
|
getTools: async ({ commit }) => {
|
||||||
console.log('[DEBUG captainTools] getTools action started');
|
|
||||||
commit(mutations.SET_UI_FLAG, { fetchingList: true });
|
commit(mutations.SET_UI_FLAG, { fetchingList: true });
|
||||||
try {
|
try {
|
||||||
const response = await CaptainToolsAPI.get();
|
const response = await CaptainToolsAPI.get();
|
||||||
console.log('[DEBUG captainTools] API response:', response.data);
|
|
||||||
commit(mutations.SET, response.data);
|
commit(mutations.SET, response.data);
|
||||||
commit(mutations.SET_UI_FLAG, { fetchingList: false });
|
commit(mutations.SET_UI_FLAG, { fetchingList: false });
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[DEBUG captainTools] API error:', error);
|
|
||||||
commit(mutations.SET_UI_FLAG, { fetchingList: false });
|
commit(mutations.SET_UI_FLAG, { fetchingList: false });
|
||||||
return throwErrorMessage(error);
|
return throwErrorMessage(error);
|
||||||
}
|
}
|
||||||
@ -34,4 +30,3 @@ const toolsStore = createStore({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export default toolsStore;
|
export default toolsStore;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user