Skip to content

Commit dfa9fb8

Browse files
committed
Format pass
1 parent 360cffd commit dfa9fb8

File tree

9 files changed

+28
-29
lines changed

9 files changed

+28
-29
lines changed

typescript/packages/toolshed/lib/response.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
export async function handleResponse<T>(response: Response): Promise<T> {
22
const data = await response.json();
33

4-
if ('error' in data) {
4+
if ("error" in data) {
55
throw new Error(data.error);
66
}
77

8-
if (data.type === 'json') {
8+
if (data.type === "json") {
99
return data.body;
1010
}
1111

typescript/packages/toolshed/routes/ai/llm/generateText.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
import { streamText } from "npm:ai";
22

3-
import {
4-
findModel,
5-
TASK_MODELS,
6-
} from "./models.ts";
3+
import { findModel, TASK_MODELS } from "./models.ts";
74

85
// Core generation logic separated from HTTP handling
96
export interface GenerateTextParams {
107
model?: string;
118
task?: string;
12-
messages: { role: 'user' | 'assistant'; content: string }[];
9+
messages: { role: "user" | "assistant"; content: string }[];
1310
system?: string;
1411
stream?: boolean;
1512
stop_token?: string;
1613
abortSignal?: AbortSignal;
1714
}
1815

1916
export interface GenerateTextResult {
20-
message: { role: 'user' | 'assistant'; content: string };
17+
message: { role: "user" | "assistant"; content: string };
2118
stream?: ReadableStream;
2219
}
2320

typescript/packages/toolshed/routes/ai/llm/llm.handlers.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import * as HttpStatusCodes from "stoker/http-status-codes";
22
import type { AppRouteHandler } from "@/lib/types.ts";
33
import type { GenerateTextRoute, GetModelsRoute } from "./llm.routes.ts";
4-
import {
5-
ALIAS_NAMES,
6-
ModelList,
7-
MODELS,
8-
TASK_MODELS,
9-
} from "./models.ts";
4+
import { ALIAS_NAMES, ModelList, MODELS, TASK_MODELS } from "./models.ts";
105
import * as cache from "./cache.ts";
116
import type { Context } from "hono";
127
import { generateText as generateTextCore } from "./generateText.ts";

typescript/packages/toolshed/routes/ai/spell/behavior/effects.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,33 @@ import { handleResponse } from "@/lib/response.ts";
44

55
const client = hc<AppType>("http://localhost:8000/");
66

7-
export async function generateText(query: Parameters<typeof client.api.ai.llm.$post>[0]["json"]) {
7+
export async function generateText(
8+
query: Parameters<typeof client.api.ai.llm.$post>[0]["json"],
9+
) {
810
const res = await client.api.ai.llm.$post({ json: query });
911
// cheating
10-
const data = (await res.json() as any) as { role: 'assistant', content: string } ;
12+
const data = (await res.json() as any) as {
13+
role: "assistant";
14+
content: string;
15+
};
1116

12-
return data.content
17+
return data.content;
1318
}
1419

1520
export async function getAllBlobs(): Promise<string[]> {
16-
const res = await client.api.storage.blobby.$get({ query: { all: 'true' }});
21+
const res = await client.api.storage.blobby.$get({ query: { all: "true" } });
1722
const data = await res.json();
18-
if ('error' in data) {
23+
if ("error" in data) {
1924
throw new Error(data.error);
2025
}
2126
return data.blobs;
2227
}
2328

2429
export async function getBlob(key: string): Promise<unknown> {
25-
const res = await client.api.storage.blobby[':key'].$get({ param: { key } });
30+
const res = await client.api.storage.blobby[":key"].$get({ param: { key } });
2631
const data = await res.json() as any;
2732

28-
if ('error' in data) {
33+
if ("error" in data) {
2934
throw new Error(data.error);
3035
}
3136

typescript/packages/toolshed/routes/ai/spell/behavior/strategies/scanByCollections.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { SearchResult } from "../search.ts";
22
import { Logger, PrefixedLogger } from "@/lib/prefixed-logger.ts";
3-
import { generateText, getBlob} from "../effects.ts";
3+
import { generateText, getBlob } from "../effects.ts";
44

55
async function generateKeywords(
66
query: string,
@@ -15,7 +15,8 @@ async function generateKeywords(
1515
content: query,
1616
},
1717
],
18-
system: "Generate exactly 3 single-word collection names that would be relevant for organizing content related to this query. Return only a JSON array of 3 strings.",
18+
system:
19+
"Generate exactly 3 single-word collection names that would be relevant for organizing content related to this query. Return only a JSON array of 3 strings.",
1920
stream: false,
2021
};
2122
const keywordText = await generateText(keywordPrompt);

typescript/packages/toolshed/routes/ai/spell/behavior/strategies/scanBySchema.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { checkSchemaMatch } from "@/lib/schema-match.ts";
22
import { SearchResult } from "../search.ts";
33
import { Logger, PrefixedLogger } from "@/lib/prefixed-logger.ts";
44
import type { RedisClientType } from "redis";
5-
import { generateText, getBlob, getAllBlobs } from "../effects.ts";
6-
import { Schema } from 'jsonschema'
5+
import { generateText, getAllBlobs, getBlob } from "../effects.ts";
6+
import { Schema } from "jsonschema";
77

88
export async function generateSchema(
99
query: string,
@@ -19,7 +19,8 @@ export async function generateSchema(
1919
content: query,
2020
},
2121
],
22-
system: "Generate a minimal JSON schema to match data that relates to this search query, aim for the absolute minimal number of fields that cature the essence of the data. (e.g. articles are really just title and url) Return only valid JSON schema.",
22+
system:
23+
"Generate a minimal JSON schema to match data that relates to this search query, aim for the absolute minimal number of fields that cature the essence of the data. (e.g. articles are really just title and url) Return only valid JSON schema.",
2324
stream: false,
2425
};
2526

typescript/packages/toolshed/routes/ai/spell/behavior/strategies/scanForKey.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { SearchResult } from "../search.ts";
22
import { Logger, PrefixedLogger } from "@/lib/prefixed-logger.ts";
3-
import { getBlob, getAllBlobs } from "../effects.ts";
3+
import { getAllBlobs, getBlob } from "../effects.ts";
44

55
export async function scanForKey(
66
phrase: string,

typescript/packages/toolshed/routes/ai/spell/behavior/strategies/scanForText.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Logger, PrefixedLogger } from "@/lib/prefixed-logger.ts";
22
import { SearchResult } from "../search.ts";
3-
import { getBlob, getAllBlobs } from "../effects.ts";
3+
import { getAllBlobs, getBlob } from "../effects.ts";
44

55
export async function scanForText(
66
phrase: string,

typescript/packages/toolshed/routes/ai/spell/spell.handlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as HttpStatusCodes from "stoker/http-status-codes";
22
import { z } from "zod";
3-
import { generateText, getBlob, getAllBlobs } from "./behavior/effects.ts";
3+
import { generateText, getAllBlobs, getBlob } from "./behavior/effects.ts";
44

55
import type { AppRouteHandler } from "@/lib/types.ts";
66
import type { ProcessSchemaRoute, SearchSchemaRoute } from "./spell.routes.ts";

0 commit comments

Comments
 (0)