Skip to content

Commit

Permalink
feat: Gemini 1.5 Pro
Browse files Browse the repository at this point in the history
  • Loading branch information
Jazee6 committed Jun 23, 2024
1 parent 491e041 commit 675c11d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 21 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ WORKDIR /app

EXPOSE 3000

RUN npm i -g pnpm@9.1.4
RUN npm i -g pnpm

COPY package.json ./
ADD package.json pnpm-lock.yaml ./

COPY patches ./patches
ADD patches ./patches

RUN pnpm install

Expand Down
3 changes: 2 additions & 1 deletion components/ChatList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const md: MarkdownIt = markdownit({
</li>
</template>
<template v-else>
<li v-if="i.type === 'text'" v-html="md.render(i.content)" class="assistant chat-item assistant-text prose"
<li v-if="i.type === 'text'" v-html="md.render(i.content)"
class="assistant chat-item assistant-text prose prose-pre:break-words prose-pre:whitespace-pre-wrap"
:class="index+1===history.length && loading ? 'loading':''"/>
<li v-else-if="i.type === 'image'" class="assistant image-item">
<template v-for="img_url in i.src_url" :key="img_url">
Expand Down
13 changes: 0 additions & 13 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,6 @@ export default defineNuxtConfig({
]
}
},
vite: {
build: {
rollupOptions: {
output: {
manualChunks: (id) => {
if (id.includes('node_modules')) {
return 'vendor'
}
}
}
}
}
},
i18n: {
vueI18n: './i18n.config.ts',
strategy: 'no_prefix',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cloudflare-ai-web",
"version": "3.0.2",
"version": "3.1.0",
"private": true,
"type": "module",
"scripts": {
Expand Down
25 changes: 22 additions & 3 deletions server/api/auth/gemini.post.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {GoogleGenerativeAI} from '@google/generative-ai'
import {GoogleGenerativeAI, HarmBlockThreshold, HarmCategory, SafetySetting} from '@google/generative-ai'
import {headers} from '~/utils/helper';
import {OpenAIMessage} from "~/utils/types";

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

const m = genAI.getGenerativeModel({model})
const m = genAI.getGenerativeModel({model, safetySettings})
let msg = messages.slice(1)

let res
Expand Down Expand Up @@ -59,4 +59,23 @@ async function fileToGenerativePart(file: File) {
mimeType: file.type,
},
};
}
}

const safetySettings: SafetySetting[] = [
{
category: HarmCategory.HARM_CATEGORY_HARASSMENT,
threshold: HarmBlockThreshold.BLOCK_NONE,
},
{
category: HarmCategory.HARM_CATEGORY_HATE_SPEECH,
threshold: HarmBlockThreshold.BLOCK_NONE,
},
{
category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,
threshold: HarmBlockThreshold.BLOCK_NONE,
},
{
category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
threshold: HarmBlockThreshold.BLOCK_NONE,
},
]
6 changes: 6 additions & 0 deletions utils/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ export const uniModals: Model[] = [
name: 'Gemini 1.5 flash',
provider: 'google',
type: 'universal'
},
{
id: 'gemini-1.5-pro',
name: 'Gemini 1.5 Pro',
provider: 'google',
type: 'universal'
}
]

Expand Down

0 comments on commit 675c11d

Please sign in to comment.