Skip to content

Commit 8b3baac

Browse files
committed
format and docs
1 parent 49461e1 commit 8b3baac

File tree

5 files changed

+25
-14
lines changed

5 files changed

+25
-14
lines changed

docs-devsite/ai.templategenerativemodel.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export declare class TemplateGenerativeModel
3939

4040
| Method | Modifiers | Description |
4141
| --- | --- | --- |
42-
| [generateContent(templateId, templateVariables)](./ai.templategenerativemodel.md#templategenerativemodelgeneratecontent) | | <b><i>(Public Preview)</i></b> Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./ai.generatecontentresponse.md#generatecontentresponse_interface)<!-- -->. |
43-
| [generateContentStream(templateId, templateVariables)](./ai.templategenerativemodel.md#templategenerativemodelgeneratecontentstream) | | <b><i>(Public Preview)</i></b> Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. |
42+
| [generateContent(templateId, templateVariables, singleRequestOptions)](./ai.templategenerativemodel.md#templategenerativemodelgeneratecontent) | | <b><i>(Public Preview)</i></b> Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./ai.generatecontentresponse.md#generatecontentresponse_interface)<!-- -->. |
43+
| [generateContentStream(templateId, templateVariables, singleRequestOptions)](./ai.templategenerativemodel.md#templategenerativemodelgeneratecontentstream) | | <b><i>(Public Preview)</i></b> Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. |
4444

4545
## TemplateGenerativeModel.(constructor)
4646

@@ -85,7 +85,8 @@ Makes a single non-streaming call to the model and returns an object containing
8585
<b>Signature:</b>
8686

8787
```typescript
88-
generateContent(templateId: string, templateVariables: object): Promise<GenerateContentResult>;
88+
generateContent(templateId: string, templateVariables: object, // anything!
89+
singleRequestOptions?: SingleRequestOptions): Promise<GenerateContentResult>;
8990
```
9091

9192
#### Parameters
@@ -94,6 +95,7 @@ generateContent(templateId: string, templateVariables: object): Promise<Generate
9495
| --- | --- | --- |
9596
| templateId | string | The ID of the server-side template to execute. |
9697
| templateVariables | object | A key-value map of variables to populate the template with. |
98+
| singleRequestOptions | [SingleRequestOptions](./ai.singlerequestoptions.md#singlerequestoptions_interface) | |
9799

98100
<b>Returns:</b>
99101

@@ -109,7 +111,7 @@ Makes a single streaming call to the model and returns an object containing an i
109111
<b>Signature:</b>
110112

111113
```typescript
112-
generateContentStream(templateId: string, templateVariables: object): Promise<GenerateContentStreamResult>;
114+
generateContentStream(templateId: string, templateVariables: object, singleRequestOptions?: SingleRequestOptions): Promise<GenerateContentStreamResult>;
113115
```
114116

115117
#### Parameters
@@ -118,6 +120,7 @@ generateContentStream(templateId: string, templateVariables: object): Promise<Ge
118120
| --- | --- | --- |
119121
| templateId | string | The ID of the server-side template to execute. |
120122
| templateVariables | object | A key-value map of variables to populate the template with. |
123+
| singleRequestOptions | [SingleRequestOptions](./ai.singlerequestoptions.md#singlerequestoptions_interface) | |
121124

122125
<b>Returns:</b>
123126

docs-devsite/ai.templateimagenmodel.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export declare class TemplateImagenModel
3939

4040
| Method | Modifiers | Description |
4141
| --- | --- | --- |
42-
| [generateImages(templateId, templateVariables)](./ai.templateimagenmodel.md#templateimagenmodelgenerateimages) | | <b><i>(Public Preview)</i></b> Makes a single call to the model and returns an object containing a single [ImagenGenerationResponse](./ai.imagengenerationresponse.md#imagengenerationresponse_interface)<!-- -->. |
42+
| [generateImages(templateId, templateVariables, singleRequestOptions)](./ai.templateimagenmodel.md#templateimagenmodelgenerateimages) | | <b><i>(Public Preview)</i></b> Makes a single call to the model and returns an object containing a single [ImagenGenerationResponse](./ai.imagengenerationresponse.md#imagengenerationresponse_interface)<!-- -->. |
4343

4444
## TemplateImagenModel.(constructor)
4545

@@ -84,7 +84,7 @@ Makes a single call to the model and returns an object containing a single [Imag
8484
<b>Signature:</b>
8585

8686
```typescript
87-
generateImages(templateId: string, templateVariables: object): Promise<ImagenGenerationResponse<ImagenInlineImage>>;
87+
generateImages(templateId: string, templateVariables: object, singleRequestOptions?: SingleRequestOptions): Promise<ImagenGenerationResponse<ImagenInlineImage>>;
8888
```
8989

9090
#### Parameters
@@ -93,6 +93,7 @@ generateImages(templateId: string, templateVariables: object): Promise<ImagenGen
9393
| --- | --- | --- |
9494
| templateId | string | The ID of the server-side template to execute. |
9595
| templateVariables | object | A key-value map of variables to populate the template with. |
96+
| singleRequestOptions | [SingleRequestOptions](./ai.singlerequestoptions.md#singlerequestoptions_interface) | |
9697

9798
<b>Returns:</b>
9899

packages/ai/integration/prompt-templates.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe('Prompt templates', function () {
6666
testConfig.ai.backend.backendType
6767
)}`,
6868
{ animal: 'Rhino' },
69-
{ timeout: 100}
69+
{ timeout: 100 }
7070
);
7171
expect(images.length).to.equal(2); // We ask for two images in the prompt template
7272
});

packages/ai/src/requests/request.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,7 @@ describe('request methods', () => {
531531
await clock.tickAsync(0);
532532
controller.abort(abortReason);
533533

534-
await expect(requestPromise).to.be.rejectedWith(
535-
'AbortError',
536-
);
534+
await expect(requestPromise).to.be.rejectedWith('AbortError');
537535
});
538536

539537
it('should abort fetch if timeout expires during request', async () => {
@@ -564,7 +562,9 @@ describe('request methods', () => {
564562

565563
expect(internalSignal?.aborted).to.be.true;
566564
expect((internalSignal?.reason as Error).name).to.equal('AbortError');
567-
expect((internalSignal?.reason as Error).message).to.equal('Timeout has expired.');
565+
expect((internalSignal?.reason as Error).message).to.equal(
566+
'Timeout has expired.'
567+
);
568568
});
569569

570570
it('should succeed and clear timeout if fetch completes before timeout', async () => {
@@ -648,7 +648,10 @@ describe('request methods', () => {
648648
await clock.tickAsync(timeoutDuration / 2);
649649
controller.abort(abortReason);
650650

651-
await expect(requestPromise).to.be.rejectedWith('AbortError', abortReason);
651+
await expect(requestPromise).to.be.rejectedWith(
652+
'AbortError',
653+
abortReason
654+
);
652655
});
653656

654657
it('should use timeout reason if it occurs before external signal abort', async () => {

packages/ai/src/requests/request.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ export async function makeRequest(
189189
: DEFAULT_FETCH_TIMEOUT_MS;
190190
const internalAbortController = new AbortController();
191191
const fetchTimeoutId = setTimeout(() => {
192-
internalAbortController.abort(new DOMException(TIMEOUT_EXPIRED_MESSAGE, ABORT_ERROR_NAME));
192+
internalAbortController.abort(
193+
new DOMException(TIMEOUT_EXPIRED_MESSAGE, ABORT_ERROR_NAME)
194+
);
193195
logger.debug(
194196
`Aborting request to ${url} due to timeout (${timeoutMillis}ms)`
195197
);
@@ -198,7 +200,9 @@ export async function makeRequest(
198200
const externalAbortListener = (): void => {
199201
logger.debug(`Aborting request to ${url} due to external abort signal.`);
200202
// If this listener was invoked, an external signal was aborted, so externalSignal must be defined.
201-
internalAbortController.abort(new DOMException(externalSignal!.reason, ABORT_ERROR_NAME));
203+
internalAbortController.abort(
204+
new DOMException(externalSignal!.reason, ABORT_ERROR_NAME)
205+
);
202206
};
203207

204208
if (externalSignal) {

0 commit comments

Comments
 (0)