Skip to content

Commit

Permalink
[OPIK-405] Fix case where data.input could be undefined (#640)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferc authored Nov 14, 2024
1 parent 2d52722 commit 0286415
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ const BASE64_PREFIXES_MAP = {
const IMAGE_CHARS_REGEX = "[A-Za-z0-9+/]+={0,2}";
const DATA_IMAGE_PREFIX = `"data:image/[^;]{3,4};base64,${IMAGE_CHARS_REGEX}"`;

function extractInputImages(input: object) {
function extractInputImages(input?: object) {
if (!input) return [];

const images: string[] = [];
const stringifiedInput = JSON.stringify(input);

Expand Down Expand Up @@ -85,7 +87,7 @@ function extractInputImages(input: object) {
return images;
}

function extractImageUrls(input: object) {
function extractImageUrls(input?: object) {
const openAIImages = extractOpenAIImages(get(input, "messages", []));
const inputImages = extractInputImages(input);

Expand Down

0 comments on commit 0286415

Please sign in to comment.