Skip to content

Commit

Permalink
fix ephemeral param typo
Browse files Browse the repository at this point in the history
  • Loading branch information
mazen-r committed Jul 11, 2024
1 parent 462cfdd commit 675a0e6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion __tests__/client/extraction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('extract', () => {
new ExtractionConfig({
body: html,
content_type: 'text/html',
epehemeral_template: { source: 'html' },
ephemeral_template: { source: 'html' },
template: 'template',
}),
),
Expand Down
4 changes: 2 additions & 2 deletions __tests__/config/extraction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ describe('url param generation', () => {
});
});

it('sets epehemeral_template', async () => {
it('sets ephemeral_template', async () => {
const config = new ExtractionConfig({
body: input_html,
content_type: input_content_type,
epehemeral_template: { source: 'html', selectors: [] },
ephemeral_template: { source: 'html', selectors: [] },
});
const params = await config.toApiParams({ key: '1234' });
expect(params).toEqual({
Expand Down
2 changes: 1 addition & 1 deletion examples/extraction/template_extraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const extractionResult = await client.extract(
body: html, // pass the HTML content
content_type: 'text/html', // content data type
charset: 'utf-8', // passed content charset, use `auto` if you aren't sure
epehemeral_template: extraction_template // declared template defintion
ephemeral_template: extraction_template // declared template defintion
}),
);

Expand Down
14 changes: 7 additions & 7 deletions src/extractionconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class ExtractionConfig {
url?: string = null;
charset?: string = null;
template?: string; // saved template name
epehemeral_template?: object; // epehemeraly declared json template
ephemeral_template?: object; // ephemeraly declared json template
extraction_prompt?: string = null;
extraction_model?: string = null;
is_document_compressed?: boolean = null;
Expand All @@ -40,7 +40,7 @@ export class ExtractionConfig {
url?: string;
charset?: string;
template?: string; // saved template name
epehemeral_template?: object; // epehemeraly declared json template
ephemeral_template?: object; // ephemeraly declared json template
extraction_prompt?: string;
extraction_model?: string;
is_document_compressed?: boolean;
Expand All @@ -52,7 +52,7 @@ export class ExtractionConfig {
this.url = options.url;
this.charset = options.charset;
this.template = options.template;
this.epehemeral_template = options.epehemeral_template;
this.ephemeral_template = options.ephemeral_template;
this.extraction_prompt = options.extraction_prompt;
this.extraction_model = options.extraction_model;
this.is_document_compressed = options.is_document_compressed;
Expand All @@ -75,18 +75,18 @@ export class ExtractionConfig {
params.charset = this.charset;
}

if (this.template && this.epehemeral_template) {
if (this.template && this.ephemeral_template) {
throw new ExtractionConfigError(
'You cannot pass both parameters template and epehemeral_template. You must choose',
'You cannot pass both parameters template and ephemeral_template. You must choose',
);
}

if (this.template) {
params.extraction_template = this.template;
}

if (this.epehemeral_template) {
params.extraction_template = 'ephemeral:' + urlsafe_b64encode(JSON.stringify(this.epehemeral_template));
if (this.ephemeral_template) {
params.extraction_template = 'ephemeral:' + urlsafe_b64encode(JSON.stringify(this.ephemeral_template));
}

if (this.extraction_prompt) {
Expand Down

0 comments on commit 675a0e6

Please sign in to comment.