Skip to content

Commit 675c11d

Browse files
committed
feat: Gemini 1.5 Pro
1 parent 491e041 commit 675c11d

File tree

6 files changed

+34
-21
lines changed

6 files changed

+34
-21
lines changed

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ WORKDIR /app
44

55
EXPOSE 3000
66

7-
RUN npm i -g pnpm@9.1.4
7+
RUN npm i -g pnpm
88

9-
COPY package.json ./
9+
ADD package.json pnpm-lock.yaml ./
1010

11-
COPY patches ./patches
11+
ADD patches ./patches
1212

1313
RUN pnpm install
1414

components/ChatList.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ const md: MarkdownIt = markdownit({
3939
</li>
4040
</template>
4141
<template v-else>
42-
<li v-if="i.type === 'text'" v-html="md.render(i.content)" class="assistant chat-item assistant-text prose"
42+
<li v-if="i.type === 'text'" v-html="md.render(i.content)"
43+
class="assistant chat-item assistant-text prose prose-pre:break-words prose-pre:whitespace-pre-wrap"
4344
:class="index+1===history.length && loading ? 'loading':''"/>
4445
<li v-else-if="i.type === 'image'" class="assistant image-item">
4546
<template v-for="img_url in i.src_url" :key="img_url">

nuxt.config.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,6 @@ export default defineNuxtConfig({
3333
]
3434
}
3535
},
36-
vite: {
37-
build: {
38-
rollupOptions: {
39-
output: {
40-
manualChunks: (id) => {
41-
if (id.includes('node_modules')) {
42-
return 'vendor'
43-
}
44-
}
45-
}
46-
}
47-
}
48-
},
4936
i18n: {
5037
vueI18n: './i18n.config.ts',
5138
strategy: 'no_prefix',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cloudflare-ai-web",
3-
"version": "3.0.2",
3+
"version": "3.1.0",
44
"private": true,
55
"type": "module",
66
"scripts": {

server/api/auth/gemini.post.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {GoogleGenerativeAI} from '@google/generative-ai'
1+
import {GoogleGenerativeAI, HarmBlockThreshold, HarmCategory, SafetySetting} from '@google/generative-ai'
22
import {headers} from '~/utils/helper';
33
import {OpenAIMessage} from "~/utils/types";
44

@@ -10,7 +10,7 @@ export default defineEventHandler(async (event) => {
1010
const messages: OpenAIMessage[] = JSON.parse(<string>body.get('messages'))
1111
const files = body.getAll('files') as File[]
1212

13-
const m = genAI.getGenerativeModel({model})
13+
const m = genAI.getGenerativeModel({model, safetySettings})
1414
let msg = messages.slice(1)
1515

1616
let res
@@ -59,4 +59,23 @@ async function fileToGenerativePart(file: File) {
5959
mimeType: file.type,
6060
},
6161
};
62-
}
62+
}
63+
64+
const safetySettings: SafetySetting[] = [
65+
{
66+
category: HarmCategory.HARM_CATEGORY_HARASSMENT,
67+
threshold: HarmBlockThreshold.BLOCK_NONE,
68+
},
69+
{
70+
category: HarmCategory.HARM_CATEGORY_HATE_SPEECH,
71+
threshold: HarmBlockThreshold.BLOCK_NONE,
72+
},
73+
{
74+
category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,
75+
threshold: HarmBlockThreshold.BLOCK_NONE,
76+
},
77+
{
78+
category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
79+
threshold: HarmBlockThreshold.BLOCK_NONE,
80+
},
81+
]

utils/db.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ export const uniModals: Model[] = [
7373
name: 'Gemini 1.5 flash',
7474
provider: 'google',
7575
type: 'universal'
76+
},
77+
{
78+
id: 'gemini-1.5-pro',
79+
name: 'Gemini 1.5 Pro',
80+
provider: 'google',
81+
type: 'universal'
7682
}
7783
]
7884

0 commit comments

Comments
 (0)