mirror of
https://github.com/ArthurDanjou/artagents.git
synced 2026-01-14 04:04:32 +01:00
lint code
This commit is contained in:
@@ -47,7 +47,6 @@ pnpm build
|
||||
|
||||
## Deploy
|
||||
|
||||
|
||||
Deploy the application on the Edge with [NuxtHub](https://hub.nuxt.com) on your Cloudflare account:
|
||||
|
||||
```bash
|
||||
@@ -57,4 +56,3 @@ npx nuxthub deploy
|
||||
Then checkout your server logs, analaytics and more in the [NuxtHub Admin](https://admin.hub.nuxt.com).
|
||||
|
||||
You can also deploy using [Cloudflare Pages CI](https://hub.nuxt.com/docs/getting-started/deploy#cloudflare-pages-ci).
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@ export default defineAppConfig({
|
||||
ui: {
|
||||
colors: {
|
||||
primary: 'blue',
|
||||
neutral: 'neutral'
|
||||
neutral: 'neutral',
|
||||
},
|
||||
container: {
|
||||
base: 'max-w-4xl'
|
||||
}
|
||||
}
|
||||
base: 'max-w-4xl',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
<template>
|
||||
<div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div />
|
||||
</template>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -11,7 +11,7 @@ const agentRoutes = AGENTS.map(item => ({
|
||||
slug: item.slug,
|
||||
name: item.name,
|
||||
icon: item.icon,
|
||||
to: `/${item.slug}`
|
||||
to: `/${item.slug}`,
|
||||
}))
|
||||
|
||||
async function toggleTheme() {
|
||||
@@ -28,7 +28,7 @@ async function toggleTheme() {
|
||||
const router = useRouter()
|
||||
defineShortcuts({
|
||||
t: () => toggleTheme(),
|
||||
backspace: () => router.back()
|
||||
backspace: () => router.back(),
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
<script lang="ts" setup>
|
||||
import type { Message } from 'ai'
|
||||
import type { Agent } from '~~/types'
|
||||
|
||||
defineProps<{
|
||||
messages: Message[]
|
||||
initialMessages: Message[]
|
||||
currentAgent: Agent
|
||||
}>()
|
||||
|
||||
const messagesRef = ref<HTMLDivElement | null>(null)
|
||||
onMounted(() => {
|
||||
if (messagesRef.value) {
|
||||
messagesRef.value.scrollTo({ top: messagesRef.value.scrollHeight, behavior: 'smooth' })
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
ref="messagesRef"
|
||||
@@ -48,21 +66,3 @@
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { Message } from 'ai'
|
||||
import type { Agent } from '~~/types'
|
||||
|
||||
defineProps<{
|
||||
messages: Message[]
|
||||
initialMessages: Message[]
|
||||
currentAgent: Agent
|
||||
}>()
|
||||
|
||||
const messagesRef = ref<HTMLDivElement | null>(null)
|
||||
onMounted(() => {
|
||||
if (messagesRef.value) {
|
||||
messagesRef.value.scrollTo({ top: messagesRef.value.scrollHeight, behavior: 'smooth' })
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -10,7 +10,8 @@ export async function loadChat(slug: string): Promise<Message[]> {
|
||||
const data = await $fetch<string>(`/api/chats/${slug}`)
|
||||
const dataString = JSON.stringify(data)
|
||||
|
||||
if (dataString === '[]') return []
|
||||
if (dataString === '[]')
|
||||
return []
|
||||
return JSON.parse(dataString)
|
||||
}
|
||||
|
||||
@@ -20,9 +21,9 @@ async function createChat(slug: string) {
|
||||
body: {
|
||||
file: {
|
||||
name: `${slug}.json`,
|
||||
content: '[]'
|
||||
}
|
||||
}
|
||||
content: '[]',
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -30,7 +31,7 @@ export async function deleteChat(slug: string) {
|
||||
await $fetch('/api/files', {
|
||||
method: 'DELETE',
|
||||
body: {
|
||||
pathname: `chats/${slug}.json`
|
||||
}
|
||||
pathname: `chats/${slug}.json`,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import type { PROVIDERS } from '~~/types'
|
||||
import { useChat } from '@ai-sdk/vue'
|
||||
import { onStartTyping } from '@vueuse/core'
|
||||
import type { PROVIDERS } from '~~/types'
|
||||
import { AGENTS, MODELS } from '~~/types'
|
||||
|
||||
const toast = useToast()
|
||||
@@ -13,7 +13,7 @@ if (!currentAgent) {
|
||||
toast.add({
|
||||
title: 'Agent not found',
|
||||
description: `Please try again`,
|
||||
color: 'error'
|
||||
color: 'error',
|
||||
})
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ const { messages, input, handleSubmit, status, stop, error, reload } = useChat({
|
||||
},
|
||||
body: {
|
||||
model: model.value,
|
||||
agent: currentAgent
|
||||
}
|
||||
agent: currentAgent,
|
||||
},
|
||||
})
|
||||
|
||||
const inputRef = shallowRef<HTMLInputElement | null>(null)
|
||||
@@ -48,7 +48,7 @@ async function deleteConversation() {
|
||||
toast.add({
|
||||
title: 'Conversation deleted',
|
||||
description: `The conversation has been deleted`,
|
||||
color: 'success'
|
||||
color: 'success',
|
||||
})
|
||||
}
|
||||
</script>
|
||||
@@ -82,7 +82,7 @@ async function deleteConversation() {
|
||||
<UPopover
|
||||
:content="{
|
||||
align: 'end',
|
||||
side: 'bottom'
|
||||
side: 'bottom',
|
||||
}"
|
||||
>
|
||||
<UButton
|
||||
@@ -163,7 +163,7 @@ async function deleteConversation() {
|
||||
placeholder="Type what you want to ask..."
|
||||
class="w-full min-h-8"
|
||||
:ui="{
|
||||
base: 'min-h-8'
|
||||
base: 'min-h-8',
|
||||
}"
|
||||
color="primary"
|
||||
autoresize
|
||||
|
||||
5
eslint.config.js
Normal file
5
eslint.config.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import antfu from '@antfu/eslint-config'
|
||||
|
||||
export default antfu({
|
||||
vue: true,
|
||||
})
|
||||
@@ -1,6 +0,0 @@
|
||||
// @ts-check
|
||||
import withNuxt from './.nuxt/eslint.config.mjs'
|
||||
|
||||
export default withNuxt(
|
||||
// Your custom configs here
|
||||
)
|
||||
@@ -1,10 +1,9 @@
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
'@nuxthub/core',
|
||||
'@nuxt/eslint',
|
||||
'@nuxt/ui',
|
||||
'@nuxt/icon',
|
||||
'@nuxtjs/mdc'
|
||||
'@nuxtjs/mdc',
|
||||
],
|
||||
|
||||
devtools: { enabled: true },
|
||||
@@ -15,8 +14,8 @@ export default defineNuxtConfig({
|
||||
cloudflare: {
|
||||
email: '',
|
||||
apiKey: '',
|
||||
accountId: ''
|
||||
}
|
||||
accountId: '',
|
||||
},
|
||||
},
|
||||
|
||||
future: { compatibilityVersion: 4 },
|
||||
@@ -26,15 +25,6 @@ export default defineNuxtConfig({
|
||||
hub: {
|
||||
ai: true,
|
||||
cache: true,
|
||||
blob: true
|
||||
blob: true,
|
||||
},
|
||||
|
||||
eslint: {
|
||||
config: {
|
||||
stylistic: {
|
||||
quotes: 'single',
|
||||
commaDangle: 'never'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"name": "nuxt-app",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"packageManager": "pnpm@10.8.0",
|
||||
"scripts": {
|
||||
"build": "nuxt build",
|
||||
"dev": "nuxt dev",
|
||||
@@ -15,7 +16,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@ai-sdk/vue": "^1.2.8",
|
||||
"@nuxt/eslint": "^1.3.0",
|
||||
"@nuxt/icon": "1.12.0",
|
||||
"@nuxt/ui": "3.0.2",
|
||||
"@nuxthub/core": "^0.8.24",
|
||||
@@ -30,6 +30,7 @@
|
||||
"zod": "^3.24.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^4.12.0",
|
||||
"@iconify-json/heroicons": "^1.2.2",
|
||||
"@iconify-json/ph": "^1.2.2",
|
||||
"@nuxt/eslint-config": "^1.3.0",
|
||||
@@ -37,6 +38,5 @@
|
||||
"typescript": "^5.8.3",
|
||||
"vue-tsc": "^2.2.8",
|
||||
"wrangler": "^4.10.0"
|
||||
},
|
||||
"packageManager": "pnpm@10.8.0"
|
||||
}
|
||||
}
|
||||
|
||||
1484
pnpm-lock.yaml
generated
1484
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,12 @@
|
||||
import type { Message } from 'ai'
|
||||
import { appendResponseMessages, appendClientMessage, streamText } from 'ai'
|
||||
import { appendClientMessage, appendResponseMessages, streamText } from 'ai'
|
||||
import { createWorkersAI } from 'workers-ai-provider'
|
||||
import { loadChat } from '~~/server/utils/chat'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { id, message, model, agent } = await readBody(event)
|
||||
|
||||
console.log(model, agent)
|
||||
console.log(model, agent) //TODO: remove
|
||||
|
||||
const workersAI = createWorkersAI({ binding: hubAI() })
|
||||
|
||||
@@ -14,7 +14,7 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
const messages = appendClientMessage({
|
||||
messages: previousMessages,
|
||||
message
|
||||
message,
|
||||
})
|
||||
|
||||
const result = streamText({
|
||||
@@ -28,10 +28,10 @@ export default defineEventHandler(async (event) => {
|
||||
id,
|
||||
messages: appendResponseMessages({
|
||||
messages,
|
||||
responseMessages: response.messages
|
||||
})
|
||||
responseMessages: response.messages,
|
||||
}),
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
result.consumeStream()
|
||||
@@ -48,8 +48,8 @@ async function saveChat({ id, messages }: { id: string, messages: Message[] }) {
|
||||
body: {
|
||||
file: {
|
||||
name: `${id}.json`,
|
||||
content: JSON.stringify(messages, null, 2)
|
||||
}
|
||||
}
|
||||
content: JSON.stringify(messages, null, 2),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ export default eventHandler(async (event) => {
|
||||
const stream = await hubBlob().serve(event, `chats/${pathname}.json`)
|
||||
|
||||
if (!(stream instanceof ReadableStream)) {
|
||||
throw new Error('Le stream n\'est pas valide')
|
||||
throw new TypeError('Le stream n\'est pas valide')
|
||||
}
|
||||
|
||||
const read = await streamToText(stream)
|
||||
|
||||
@@ -8,11 +8,11 @@ export default eventHandler(async (event) => {
|
||||
|
||||
ensureBlob(file, {
|
||||
maxSize: '1MB',
|
||||
types: ['application/jsonml+json', 'application/json']
|
||||
types: ['application/jsonml+json', 'application/json'],
|
||||
})
|
||||
|
||||
return hubBlob().put(file.name, file, {
|
||||
addRandomSuffix: false,
|
||||
prefix: 'chats'
|
||||
prefix: 'chats',
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { z } from 'zod'
|
||||
import { useValidatedBody } from 'h3-zod'
|
||||
import { z } from 'zod'
|
||||
|
||||
export default eventHandler(async (event) => {
|
||||
const { pathname } = await useValidatedBody(event, {
|
||||
pathname: z.string()
|
||||
pathname: z.string(),
|
||||
})
|
||||
|
||||
await hubBlob().del(pathname)
|
||||
|
||||
@@ -8,11 +8,11 @@ export default eventHandler(async (event) => {
|
||||
|
||||
ensureBlob(file, {
|
||||
maxSize: '1MB',
|
||||
types: ['image', 'pdf', 'application/pdf']
|
||||
types: ['image', 'pdf', 'application/pdf'],
|
||||
})
|
||||
|
||||
return hubBlob().put(file.name, file, {
|
||||
addRandomSuffix: false,
|
||||
prefix: 'files'
|
||||
prefix: 'files',
|
||||
})
|
||||
})
|
||||
|
||||
@@ -10,7 +10,8 @@ export async function loadChat(slug: string): Promise<Message[]> {
|
||||
const data = await $fetch<string>(`/api/chats/${slug}`)
|
||||
const dataString = JSON.stringify(data)
|
||||
|
||||
if (dataString === '[]') return []
|
||||
if (dataString === '[]')
|
||||
return []
|
||||
return JSON.parse(dataString)
|
||||
}
|
||||
|
||||
@@ -20,14 +21,14 @@ async function createChat(slug: string) {
|
||||
body: {
|
||||
file: {
|
||||
name: `${slug}.json`,
|
||||
content: '[]'
|
||||
}
|
||||
}
|
||||
content: '[]',
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export async function deleteChat(slug: string) {
|
||||
await $fetch(`/api/chats/${slug}.json`, {
|
||||
method: 'DELETE'
|
||||
method: 'DELETE',
|
||||
})
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@ export async function streamToText(stream: ReadableStream<Uint8Array>) {
|
||||
|
||||
while (true) {
|
||||
const { done, value } = await reader.read()
|
||||
if (done) break
|
||||
if (done)
|
||||
break
|
||||
result += decoder.decode(value, { stream: true })
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ export enum PROVIDERS {
|
||||
META = '@cf/meta/llama-3.1-8b-instruct',
|
||||
MISTRAL = '@cf/mistral/mistral-7b-instruct-v0.1',
|
||||
GOOGLE = '@cf/google/gemma-3-12b-it',
|
||||
QWEN = '@cf/qwen/qwen2.5-coder-32b-instruct'
|
||||
QWEN = '@cf/qwen/qwen2.5-coder-32b-instruct',
|
||||
}
|
||||
|
||||
export const AGENTS: Agent[] = [
|
||||
@@ -29,7 +29,7 @@ export const AGENTS: Agent[] = [
|
||||
welcomeMessage: 'Hello, how can I help you today?',
|
||||
icon: 'i-heroicons-sparkles',
|
||||
description: 'This is a description',
|
||||
defaultModel: PROVIDERS.MISTRAL
|
||||
defaultModel: PROVIDERS.MISTRAL,
|
||||
},
|
||||
{
|
||||
slug: 'agent-2',
|
||||
@@ -38,7 +38,7 @@ export const AGENTS: Agent[] = [
|
||||
welcomeMessage: 'Hello, how can I help you today?',
|
||||
icon: 'i-heroicons-sparkles',
|
||||
description: 'This is a description',
|
||||
defaultModel: PROVIDERS.META
|
||||
defaultModel: PROVIDERS.META,
|
||||
},
|
||||
{
|
||||
slug: 'agent-3',
|
||||
@@ -47,7 +47,7 @@ export const AGENTS: Agent[] = [
|
||||
welcomeMessage: 'Hello, how can I help you today?',
|
||||
icon: 'i-heroicons-sparkles',
|
||||
description: 'This is a description',
|
||||
defaultModel: PROVIDERS.GOOGLE
|
||||
defaultModel: PROVIDERS.GOOGLE,
|
||||
},
|
||||
{
|
||||
slug: 'agent-4',
|
||||
@@ -56,24 +56,24 @@ export const AGENTS: Agent[] = [
|
||||
welcomeMessage: 'Hello, how can I help you today?',
|
||||
icon: 'i-heroicons-sparkles',
|
||||
description: 'This is a description',
|
||||
defaultModel: PROVIDERS.QWEN
|
||||
}
|
||||
defaultModel: PROVIDERS.QWEN,
|
||||
},
|
||||
]
|
||||
|
||||
export const MODELS: Array<Model> = [
|
||||
{
|
||||
name: 'Mistral Large',
|
||||
model: PROVIDERS.MISTRAL,
|
||||
icon: 'i-logos-mistral-ai-icon'
|
||||
icon: 'i-logos-mistral-ai-icon',
|
||||
},
|
||||
{
|
||||
name: 'Meta Llama',
|
||||
model: PROVIDERS.META,
|
||||
icon: 'i-logos-meta-icon'
|
||||
icon: 'i-logos-meta-icon',
|
||||
},
|
||||
{
|
||||
name: 'Google Gemini',
|
||||
model: PROVIDERS.GOOGLE,
|
||||
icon: 'i-logos-google-icon'
|
||||
}
|
||||
icon: 'i-logos-google-icon',
|
||||
},
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user