mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-25 01:06:15 -04:00
parent
80e46c9292
commit
2da74fa121
6 changed files with 95 additions and 39 deletions
55
src/tools/ai-prompt-splitter/ai-prompt-splitter.vue
Normal file
55
src/tools/ai-prompt-splitter/ai-prompt-splitter.vue
Normal file
|
@ -0,0 +1,55 @@
|
|||
<script setup lang="ts">
|
||||
import promptSplitter from 'chatgpt-prompt-splitter';
|
||||
import { useValidation } from '@/composable/validation';
|
||||
|
||||
const prompt = ref('');
|
||||
const splitLength = ref(1024);
|
||||
|
||||
const splittedPrompts = computed(() => {
|
||||
try {
|
||||
return promptSplitter({
|
||||
prompt: prompt.value,
|
||||
splitLength: splitLength.value,
|
||||
newLine: true,
|
||||
});
|
||||
}
|
||||
catch (e: any) {
|
||||
return [e.toString()];
|
||||
}
|
||||
});
|
||||
|
||||
const promptValidation = useValidation({
|
||||
source: prompt,
|
||||
rules: [
|
||||
{
|
||||
validator: v => v !== '',
|
||||
message: 'Prompt must not be empty',
|
||||
},
|
||||
],
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div style="max-width: 600px;">
|
||||
<c-card title="Prompt and options" mb-2>
|
||||
<c-input-text
|
||||
v-model:value="prompt"
|
||||
label="Full Prompt"
|
||||
multiline
|
||||
placeholder="Put your full prompt here..."
|
||||
rows="10"
|
||||
:validation="promptValidation"
|
||||
mb-2
|
||||
/>
|
||||
<n-form-item label="Character length for each chunk">
|
||||
<n-input-number v-model:value="splitLength" :min="1" />
|
||||
</n-form-item>
|
||||
</c-card>
|
||||
|
||||
<c-card title="Splitted prompts">
|
||||
<div v-for="(splittedPrompt, index) in splittedPrompts" :key="index">
|
||||
<TextareaCopyable :value="splittedPrompt" />
|
||||
</div>
|
||||
</c-card>
|
||||
</div>
|
||||
</template>
|
12
src/tools/ai-prompt-splitter/index.ts
Normal file
12
src/tools/ai-prompt-splitter/index.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { Prompt } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'AI Prompt Splitter',
|
||||
path: '/ai-prompt-splitter',
|
||||
description: 'Split a long document to multiple chat (ie ChatGPT) priompts',
|
||||
keywords: ['ai', 'chatgpt', 'gpt', 'prompt', 'splitter'],
|
||||
component: () => import('./ai-prompt-splitter.vue'),
|
||||
icon: Prompt,
|
||||
createdAt: new Date('2024-07-14'),
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue