Skip to content

Commit d560d9a

Browse files
committed
refactor(api): drop llm config from js sdk
1 parent c5bf757 commit d560d9a

5 files changed

Lines changed: 19 additions & 25 deletions

File tree

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export type {
1212
ApiHistoryFilterInput,
1313
ApiHistoryService,
1414
ApiHtmlMode,
15-
ApiLlmConfig,
1615
ApiModelName,
1716
ApiMonitorCreateInput,
1817
ApiMonitorCreateRequest,

src/lib/utils.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,26 @@ function normalizeSchema(schema: unknown) {
1616
return schema ? toJsonSchema(schema) : undefined;
1717
}
1818

19+
const ALLOWED_FORMAT_KEYS = {
20+
markdown: new Set(["type", "mode"]),
21+
html: new Set(["type", "mode"]),
22+
screenshot: new Set(["type", "fullPage", "width", "height", "quality"]),
23+
links: new Set(["type"]),
24+
images: new Set(["type"]),
25+
summary: new Set(["type"]),
26+
branding: new Set(["type"]),
27+
json: new Set(["type", "prompt", "schema", "mode"]),
28+
} as const;
29+
1930
function normalizeScrapeFormatEntry(format: ApiScrapeFormatEntry): ApiScrapeFormatEntry {
20-
if (format.type !== "json" || !format.schema) return format;
31+
const allowedKeys = ALLOWED_FORMAT_KEYS[format.type];
32+
const normalized = Object.fromEntries(
33+
Object.entries(format).filter(([key]) => allowedKeys.has(key)),
34+
) as ApiScrapeFormatEntry;
35+
if (normalized.type !== "json" || !normalized.schema) return normalized;
2136
return {
22-
...format,
23-
schema: normalizeSchema(format.schema),
37+
...normalized,
38+
schema: normalizeSchema(normalized.schema),
2439
};
2540
}
2641

@@ -146,7 +161,6 @@ export function buildMonitorBody(monitorCreateInput: ApiMonitorCreateInput) {
146161
type: "json" as const,
147162
prompt: legacyMonitorInput.prompt,
148163
schema: normalizeSchema(legacyMonitorInput.schema),
149-
llmConfig: legacyMonitorInput.llmConfig,
150164
mode: "normal" as const,
151165
},
152166
],

src/schemas.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,6 @@ export const apiFetchConfigSchema = z.object({
8383
.default(false),
8484
});
8585

86-
export const apiChunkerSchema = z.object({
87-
size: z.union([z.number().int().min(2048), z.literal("dynamic")]).optional(),
88-
overlap: z.number().int().min(0).max(512).optional(),
89-
});
90-
91-
export const apiLlmConfigSchema = z.object({
92-
model: z.enum(MODEL_NAMES).optional(),
93-
temperature: z.number().min(0).max(1).default(0),
94-
maxTokens: z.number().int().min(1).max(16384).default(4096),
95-
chunker: apiChunkerSchema.optional(),
96-
});
97-
9886
export const apiHistoryFilterSchema = z.object({
9987
page: z.coerce.number().int().positive().default(1),
10088
limit: z.coerce.number().int().min(1).max(100).default(20),
@@ -134,13 +122,10 @@ export const apiScreenshotConfigSchema = z.object({
134122
export const apiScrapeJsonConfigSchema = z.object({
135123
prompt: apiUserPromptSchema,
136124
schema: z.record(z.string(), z.unknown()).optional(),
137-
llmConfig: apiLlmConfigSchema.optional(),
138125
mode: apiHtmlModeSchema.default("normal"),
139126
});
140127

141-
export const apiScrapeSummaryConfigSchema = z.object({
142-
llmConfig: apiLlmConfigSchema.optional(),
143-
});
128+
export const apiScrapeSummaryConfigSchema = z.object({});
144129

145130
const scrapeBase = {
146131
url: apiUrlSchema,

src/types/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import type {
88
apiHistoryFilterSchema,
99
apiHtmlConfigSchema,
1010
apiHtmlModeSchema,
11-
apiLlmConfigSchema,
1211
apiMarkdownConfigSchema,
1312
apiMonitorCreateSchema,
1413
apiMonitorUpdateSchema,
@@ -42,7 +41,6 @@ export interface RequestOptions {
4241
}
4342

4443
export type ApiFetchConfig = z.infer<typeof apiFetchConfigSchema>;
45-
export type ApiLlmConfig = z.infer<typeof apiLlmConfigSchema>;
4644
export type ApiScrapeFormat = z.infer<typeof apiScrapeFormatSchema>;
4745
export type ApiScrapeFormatEntry = z.infer<typeof apiScrapeFormatEntrySchema>;
4846
export type ApiScrapeRequest = z.infer<typeof apiScrapeRequestSchema>;
@@ -78,7 +76,6 @@ export type LegacyApiMonitorCreateInput = {
7876
webhookUrl?: string;
7977
interval: string;
8078
fetchConfig?: ApiFetchConfig;
81-
llmConfig?: ApiLlmConfig;
8279
};
8380
export type ApiMonitorCreateInput = ApiMonitorCreateRequest | LegacyApiMonitorCreateInput;
8481
export type ApiCrawlOptions = Partial<Omit<ApiCrawlRequest, "url">> & {

tests/client.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ describe("scrapegraphai", () => {
295295
properties: { price: { type: "number" } },
296296
required: ["price"],
297297
},
298-
llmConfig: undefined,
299298
mode: "normal",
300299
},
301300
],

0 commit comments

Comments
 (0)