Skip to content

Commit

Permalink
Merge pull request #89 from caillef/fix-vision
Browse files Browse the repository at this point in the history
fix: vision now uses content.data
  • Loading branch information
ponderingdemocritus authored Feb 6, 2025
2 parents 6a3d395 + d48135a commit 5b4469b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/example-vision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ async function main() {
execute: async (payload) => {
// Extract image URLs from content using a more robust regex pattern
const imageRegex = /<IMAGE:([^>]+)>/g;
const images = Array.from(payload.content.matchAll(imageRegex))
const images = Array.from(payload.data.content.matchAll(imageRegex))
.map((match) => (match as string[])[1])
.filter((url) => url.length > 0);

// Extract file information using regex with proper mime type and data parsing
const fileRegex = /<FILE:([^:]+):([^>]+)>/g;
const files = Array.from(payload.content.matchAll(fileRegex))
const files = Array.from(payload.data.content.matchAll(fileRegex))
.map((match) => ({
mimeType: (match as string[])[1].trim(),
data: (match as string[])[2].trim(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ export class MessageAndVisionProcessor extends BaseProcessor {
});

const contentStr =
typeof content === "string" ? content : content.content;
typeof content === "string" ? content : content.data.content;

const filesAndImages: Array<FilePart | ImagePart> = [
...(content.images?.map((image: DataContent | string) => ({
...(content.data.images?.map((image: DataContent | string) => ({
type: "image" as const,
image,
})) || []),
...(content.files?.map(
...(content.data.files?.map(
(data: { data: DataContent | string; mimeType: string }) => ({
type: "file" as const,
data: data.data,
Expand Down

0 comments on commit 5b4469b

Please sign in to comment.