Files
artchat/app/composables/chat.ts
Arthur DANJOU ff28b719de feat: enhance command palette with new "uses" feature and update chat types
- Added "View setup" command to the command palette in English, French, and Spanish.
- Removed "Tech Stack" command from the command palette.
- Updated MessageContainer to handle new "uses" message type.
- Refactored chat.ts to use a new ChatMessages function for better organization.
- Created new Uses.vue component to display a list of software and gadgets.
- Added Item.vue and List.vue components for rendering individual items and categories.
- Updated content configuration to include new skills and uses categories.
- Added new JSON files for programming languages, frontend, backend, devops, and python frameworks.
- Updated existing JSON files for homelab items with improved descriptions.
- Removed obsolete stack JSON files.
2025-09-02 21:19:32 +02:00

41 lines
1.0 KiB
TypeScript

import { ChatFetchState, ChatMessages, ChatSender, ChatType } from '~~/types/chat'
export function useChat(t: any) {
const messages = computed(() => ChatMessages(t))
const { addMessage, checkForDuplicateMessages, deleteMessage, cleanDuplicatedMessages } = useChatStore()
async function submitMessage(type: ChatType, prompt: string, fetchStates: ChatFetchState[]) {
const duplicates = checkForDuplicateMessages(type)
addMessage(
type,
prompt,
ChatSender.USER,
[],
)
await new Promise(resolve => setTimeout(resolve, 700))
if (duplicates.length > 0) {
duplicates.forEach(msg => deleteMessage(msg.id, msg.type))
cleanDuplicatedMessages()
addMessage(
ChatType.DUPLICATED,
'',
ChatSender.ARTHUR,
[ChatFetchState.THINKING, ChatFetchState.DONE],
)
await new Promise(resolve => setTimeout(resolve, 700))
}
addMessage(
type,
'',
ChatSender.ARTHUR,
fetchStates,
)
}
return {
messages,
submitMessage,
}
}