Skip to content

Commit

Permalink
fix: mime-type was fixed to jpeg (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkarw authored Dec 10, 2024
1 parent a6d24d0 commit e6ae07f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/tools/src/vision.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'node:fs/promises'
import path from 'node:path'

import { Provider } from '@dead-simple-ai-agent/framework/models'
import { tool } from '@dead-simple-ai-agent/framework/tool'
Expand All @@ -8,7 +9,7 @@ import { z } from 'zod'

const encodeImage = async (imagePath: string): Promise<string> => {
const imageBuffer = await fs.readFile(imagePath)
return `data:image/jpeg;base64,${imageBuffer.toString('base64')}`
return `data:image/${path.extname(imagePath).toLowerCase().replace('.', '')};base64,${imageBuffer.toString('base64')}`
}

async function callOpenAI(
Expand Down

0 comments on commit e6ae07f

Please sign in to comment.