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 0e54078
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 48 deletions.
15 changes: 0 additions & 15 deletions src/functions/pre_fetch_processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +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(
'Found both vertexAiSearch and vertexRagStore field are set in tool. Either set vertexAiSearch or vertexRagStore.'
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 0e54078

Please sign in to comment.