Skip to content

Commit

Permalink
fix image url parameter (#1721)
Browse files Browse the repository at this point in the history
  • Loading branch information
kovrichard authored May 15, 2024
1 parent 0c6f619 commit d60e1f3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/api/chat/anthropic/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ export async function POST(request: NextRequest) {
return { type: "text", text: content }
} else if (
content?.type === "image_url" &&
content?.image_url?.length
content?.image_url?.url?.length
) {
return {
type: "image",
source: {
type: "base64",
media_type: getMediaTypeFromDataURL(content.image_url),
data: getBase64FromDataURL(content.image_url)
media_type: getMediaTypeFromDataURL(content.image_url.url),
data: getBase64FromDataURL(content.image_url.url)
}
}
} else {
Expand Down
6 changes: 5 additions & 1 deletion app/api/chat/openai/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ export async function POST(request: Request) {
model: chatSettings.model as ChatCompletionCreateParamsBase["model"],
messages: messages as ChatCompletionCreateParamsBase["messages"],
temperature: chatSettings.temperature,
max_tokens: chatSettings.model === "gpt-4-vision-preview" ? 4096 : null, // TODO: Fix
max_tokens:
chatSettings.model === "gpt-4-vision-preview" ||
chatSettings.model === "gpt-4o"
? 4096
: null, // TODO: Fix
stream: true
})

Expand Down
4 changes: 3 additions & 1 deletion lib/build-prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ export async function buildFinalMessages(

return {
type: "image_url",
image_url: formedUrl
image_url: {
url: formedUrl
}
}
})
]
Expand Down

1 comment on commit d60e1f3

@ndroo
Copy link

@ndroo ndroo commented on d60e1f3 Jun 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this worked - any time I upload an image to the demo app it gives an error.

Please sign in to comment.