Skip to content

Commit

Permalink
nit: formating updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sroussey committed Jan 31, 2025
1 parent a8adb36 commit 28dc254
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ describe("HFTransformersBinding", () => {
describe("InMemoryJobQueue", () => {
it("Should have an item queued", async () => {
const providerRegistry = getProviderRegistry();
const jobQueue = new InMemoryJobQueue(HFQUEUE, new ConcurrencyLimiter(1, 10), 10);
const jobQueue = new InMemoryJobQueue<TaskInput, TaskOutput>(
HFQUEUE,
new ConcurrencyLimiter(1, 10),
10
);
providerRegistry.registerQueue(LOCAL_ONNX_TRANSFORMERJS, jobQueue);

registerHuggingfaceLocalTasks();
Expand Down Expand Up @@ -82,7 +86,7 @@ describe("HFTransformersBinding", () => {
"ONNX Xenova/LaMini-Flan-T5-783M q8"
);
const providerRegistry = getProviderRegistry();
const jobQueue = new SqliteJobQueue(
const jobQueue = new SqliteJobQueue<TaskInput, TaskOutput>(
getDatabase(":memory:"),
HFQUEUE,
new ConcurrencyLimiter(1, 10),
Expand Down
8 changes: 4 additions & 4 deletions packages/ai/src/model/ModelRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class FallbackModelRegistry {
}
}

public async findModelsByTask(task: string): Promise<Model[]|undefined> {
public async findModelsByTask(task: string): Promise<Model[] | undefined> {
const models = this.task2models
.filter((t2m) => t2m.task === task)
.map((t2m) => this.models.find((m) => m.name === t2m.model));
Expand All @@ -36,7 +36,7 @@ export class FallbackModelRegistry {
console.warn(`Some models for task ${task} were not found`);
}

const found = models.filter((m): m is Model => m !== undefined)
const found = models.filter((m): m is Model => m !== undefined);
return found.length > 0 ? found : undefined;
}
public async findTasksByModel(name: string): Promise<string[]> {
Expand All @@ -51,7 +51,7 @@ export class FallbackModelRegistry {
}

public async enumerateAllTasks(): Promise<string[]> {
return Array.from(new Set(this.task2models.map(t2m => t2m.task)));
return Array.from(new Set(this.task2models.map((t2m) => t2m.task)));
}

public async size(): Promise<number> {
Expand All @@ -62,7 +62,7 @@ export class FallbackModelRegistry {
if (!this.findByName(modelName)) {
throw new Error(`Model ${modelName} not found when connecting to task ${task}`);
}

this.task2models.push({ task, model: modelName });
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class IndexedDbKVRepository<
* Returns an array of all entries in the repository
* @returns Array of all entries in the repository
*/
async getAll(): Promise<Combined[]| undefined> {
async getAll(): Promise<Combined[] | undefined> {
const db = await this.dbPromise;
const transaction = db.transaction(this.table, "readonly");
const store = transaction.objectStore(this.table);
Expand All @@ -121,7 +121,7 @@ export class IndexedDbKVRepository<
return new Promise((resolve, reject) => {
request.onerror = () => reject(request.error);
request.onsuccess = () => {
const values = request.result.map(item => ({ ...item.value, id: item.id }));
const values = request.result.map((item) => ({ ...item.value, id: item.id }));
resolve(values.length > 0 ? values : undefined);
};
});
Expand Down
20 changes: 9 additions & 11 deletions packages/storage/src/node/filesystem/base/FileKVRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,19 @@ export class FileKVRepository<
}
const results = await Promise.allSettled(
jsonFiles.map(async (file) => {
const content = await readFile(path.join(this.folderPath, file), 'utf-8');
const data = JSON.parse(content) as Combined;
return data;
}
)
const content = await readFile(path.join(this.folderPath, file), "utf-8");
const data = JSON.parse(content) as Combined;
return data;
})
);

const values = results
.filter((result) =>
result.status === 'fulfilled')
.map(result => result.value);

.filter((result) => result.status === "fulfilled")
.map((result) => result.value);

return values.length > 0 ? values : undefined;
} catch (error) {
console.error('Error in getAll:', error);
console.error("Error in getAll:", error);
throw error;
}
}
Expand Down

0 comments on commit 28dc254

Please sign in to comment.