Skip to content

Commit 1921c7f

Browse files
russellwheatleymikehardy
authored andcommitted
request-helpers
1 parent 3c02144 commit 1921c7f

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

packages/ai/lib/requests/request-helpers.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { Content, GenerateContentRequest, Part, VertexAIErrorCode } from '../types';
19-
import { VertexAIError } from '../errors';
18+
import { Content, GenerateContentRequest, Part, AIErrorCode } from '../types';
19+
import { AIError } from '../errors';
2020

2121
export function formatSystemInstruction(input?: string | Part | Content): Content | undefined {
2222
if (input == null) {
@@ -32,7 +32,6 @@ export function formatSystemInstruction(input?: string | Part | Content): Conten
3232
return input as Content;
3333
}
3434
}
35-
3635
return undefined;
3736
}
3837

@@ -76,15 +75,15 @@ function assignRoleToPartsAndValidateSendMessageRequest(parts: Part[]): Content
7675
}
7776

7877
if (hasUserContent && hasFunctionContent) {
79-
throw new VertexAIError(
80-
VertexAIErrorCode.INVALID_CONTENT,
78+
throw new AIError(
79+
AIErrorCode.INVALID_CONTENT,
8180
'Within a single message, FunctionResponse cannot be mixed with other type of Part in the request for sending chat message.',
8281
);
8382
}
8483

8584
if (!hasUserContent && !hasFunctionContent) {
86-
throw new VertexAIError(
87-
VertexAIErrorCode.INVALID_CONTENT,
85+
throw new AIError(
86+
AIErrorCode.INVALID_CONTENT,
8887
'No Content is provided for sending chat message.',
8988
);
9089
}

0 commit comments

Comments
 (0)