Skip to content

Commit

Permalink
fix: remove restriction on gsc uri for file data part.
Browse files Browse the repository at this point in the history
FUTURE_COPYBARA_INTEGRATE_REVIEW=#469 from invertase:main f846c11
PiperOrigin-RevId: 702052601
  • Loading branch information
yyyu-google authored and copybara-github committed Dec 2, 2024
1 parent a16b9d4 commit c2f7a81
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 47 deletions.
14 changes: 0 additions & 14 deletions src/functions/pre_fetch_processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,6 @@ export function formatContentRequest(
export function validateGenerateContentRequest(
request: GenerateContentRequest
) {
const contents = request.contents;
for (const content of contents) {
for (const part of content.parts) {
if ('fileData' in part) {
// @ts-ignore
const uri = part['fileData']['fileUri'];
if (!uri.startsWith('gs://')) {
throw new URIError(
`Found invalid Google Cloud Storage URI ${uri}, Google Cloud Storage URIs must start with gs://`
);
}
}
}
}

if (hasVertexAISearch(request) && hasVertexRagStore(request)) {
throw new ClientError(
Expand Down
15 changes: 0 additions & 15 deletions src/functions/test/functions_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,21 +437,6 @@ describe('generateContent', () => {
expect(resp).toEqual(expectedResult);
});

it('raises an error when passed an invalid GCS URI', async () => {
const req: GenerateContentRequest = {
contents: TEST_USER_CHAT_MESSAGE_WITH_INVALID_GCS_FILE,
};
await expectAsync(
generateContent(
TEST_LOCATION,
TEST_RESOURCE_PATH,
TEST_TOKEN_PROMISE,
req,
TEST_API_ENDPOINT
)
).toBeRejectedWithError(URIError);
});

it('returns a GenerateContentResponse when passed safetySettings and generationConfig', async () => {
const req: GenerateContentRequest = {
contents: TEST_USER_CHAT_MESSAGE,
Expand Down
18 changes: 0 additions & 18 deletions src/models/test/models_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1018,15 +1018,6 @@ describe('GenerativeModel generateContent', () => {
expect(resp).toEqual(expectedResult);
});

it('raises an error when passed an invalid GCS URI', async () => {
const req: GenerateContentRequest = {
contents: TEST_USER_CHAT_MESSAGE_WITH_INVALID_GCS_FILE,
};
await expectAsync(model.generateContent(req)).toBeRejectedWithError(
URIError
);
});

it('returns a GenerateContentResponse when passed safetySettings and generationConfig', async () => {
const req: GenerateContentRequest = {
contents: TEST_USER_CHAT_MESSAGE,
Expand Down Expand Up @@ -1496,15 +1487,6 @@ describe('GenerativeModelPreview generateContent', () => {
expect(resp).toEqual(expectedResult);
});

it('raises an error when passed an invalid GCS URI', async () => {
const req: GenerateContentRequest = {
contents: TEST_USER_CHAT_MESSAGE_WITH_INVALID_GCS_FILE,
};
await expectAsync(model.generateContent(req)).toBeRejectedWithError(
URIError
);
});

it('returns a GenerateContentResponse when passed safetySettings and generationConfig', async () => {
const req: GenerateContentRequest = {
contents: TEST_USER_CHAT_MESSAGE,
Expand Down

0 comments on commit c2f7a81

Please sign in to comment.