Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gogwilt committed Dec 17, 2023
1 parent 0c0138a commit ef0a62d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 30 deletions.
4 changes: 1 addition & 3 deletions packages/core/src/plugins/google/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ export async function* streamChatCompletions({
});
const response = await generativeModel.generateContentStream({
contents: prompt,
// TODO Figure out how to abort
// signal: signal ?? defaultSignal,
});

let hadChunks = false;
Expand All @@ -105,7 +103,7 @@ export async function* streamChatCompletions({
console.log('streaming google responses')
hadChunks = true;

if (chunk.candidates[0]?.content.parts[0]?.text) {
if (!signal?.aborted && chunk.candidates[0]?.content.parts[0]?.text) {
yield {
completion: chunk.candidates[0]?.content.parts[0]?.text,
finish_reason: chunk.candidates[0]?.finishReason as any,
Expand Down
28 changes: 1 addition & 27 deletions packages/core/src/plugins/google/nodes/ChatGoogleNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { dedent } from 'ts-dedent';
import retry from 'p-retry';
import { match } from 'ts-pattern';
import { coerceType, coerceTypeOptional } from '../../../utils/coerceType.js';
import { expectTypeOptional } from '../../../utils/expectType.js';
import { addWarning } from '../../../utils/outputs.js';
import { getError } from '../../../utils/errors.js';
import { pluginNodeDefinition } from '../../../model/NodeDefinition.js';
Expand Down Expand Up @@ -430,8 +429,7 @@ export const ChatGoogleNodeImpl: PluginNodeImpl<ChatGoogleNode> = {
return output;
},
{
forever: true,
retries: 10000,
retries: 10,
maxRetryTime: 1000 * 60 * 5,
factor: 2.5,
minTimeout: 500,
Expand All @@ -444,30 +442,6 @@ export const ChatGoogleNodeImpl: PluginNodeImpl<ChatGoogleNode> = {
if (context.signal.aborted) {
throw new Error('Aborted');
}

const { retriesLeft } = err;

// TODO
// if (!(err instanceof OpenAIError)) {
// return; // Just retry?
// }

// if (err.status === 429) {
// if (retriesLeft) {
// context.onPartialOutputs?.({
// ['response' as PortId]: {
// type: 'string',
// value: 'OpenAI API rate limit exceeded, retrying...',
// },
// });
// return;
// }
// }

// // We did something wrong (besides rate limit)
// if (err.status >= 400 && err.status < 500) {
// throw new Error(err.message);
// }
},
},
);
Expand Down

0 comments on commit ef0a62d

Please sign in to comment.