logic fix and ci improvement

This commit is contained in:
dal 2025-07-23 07:54:31 -06:00
parent 584387b9c1
commit 5f779a6fe1
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
2 changed files with 24 additions and 4 deletions

View File

@ -30,7 +30,7 @@ jobs:
uses: useblacksmith/setup-node@v5
with:
node-version: 22
cache: 'pnpm'
# Remove cache here since we're using stickydisk for pnpm store
- name: Get pnpm store directory
shell: bash
@ -49,8 +49,21 @@ jobs:
key: ${{ github.repository }}-turbo-cache
path: ./.turbo
- name: Check if lockfile changed
id: lockfile-check
run: |
if git diff HEAD~1 HEAD --name-only | grep -q "pnpm-lock.yaml"; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Fetch dependencies (if lockfile changed)
if: steps.lockfile-check.outputs.changed == 'true'
run: pnpm fetch --frozen-lockfile
- name: Install dependencies
run: pnpm install --frozen-lockfile
run: pnpm install --frozen-lockfile --prefer-offline
- name: Build all packages (excluding web)
run: pnpm build --filter='!@buster-app/web'

View File

@ -174,6 +174,9 @@ export class FallbackModel implements LanguageModelV1 {
const result = await currentModel.doStream(options);
let hasStreamedAny = false;
let streamRetryAttempts = 0;
const maxStreamRetries = self.settings.models.length - 1; // -1 because we already tried one
// Wrap the stream to handle errors and switch providers if needed
const wrappedStream = new ReadableStream<LanguageModelV1StreamPart>({
async start(controller) {
@ -191,9 +194,13 @@ export class FallbackModel implements LanguageModelV1 {
if (self.settings.onError) {
await self.settings.onError(error as Error, self.modelId);
}
if (!hasStreamedAny || self.retryAfterOutput) {
// If nothing was streamed yet, switch models and retry
if (
(!hasStreamedAny || self.retryAfterOutput) &&
streamRetryAttempts < maxStreamRetries
) {
// If nothing was streamed yet and we haven't exhausted retries, switch models and retry
self.switchToNextModel();
streamRetryAttempts++;
try {
const nextResult = await self.doStream(options);
const nextReader = nextResult.stream.getReader();