mirror of
https://github.com/ArthurDanjou/artchat.git
synced 2026-01-14 15:54:03 +01:00
- 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.
41 lines
1.0 KiB
TypeScript
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,
|
|
}
|
|
}
|