Skip to content

Commit

Permalink
fix file format
Browse files Browse the repository at this point in the history
  • Loading branch information
pyama86 committed Nov 9, 2023
1 parent b60465d commit 37d1ed9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/mention.ts
Expand Up @@ -32,13 +32,18 @@ export const appMention: any = async ({ event, client, say }) => {
for (const file of message.files) {
if ('url_private_download' in file) {
const encodedImage = await downloadFileAsBase64(file.url_private_download)
let filetype = file.filetype
if (filetype === 'jpg') {
filetype = 'jpeg'
}

if (encodedImage) {
model = 'gpt-4-vision-preview'
max_tokens = 4096
contents.push(
{
image_url: {
url: 'data:image/jpeg;base64,' + encodedImage,
url: 'data:image/' + filetype + ';base64,' + encodedImage,
detail: 'auto'
},
type: 'image_url'
Expand Down

0 comments on commit 37d1ed9

Please sign in to comment.