Skip to content

Commit

Permalink
feat(llm): add fromTemplate factory to the JSON driver
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas2D committed Sep 23, 2024
1 parent 05d6dbb commit 6d3b356
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/llms/drivers/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ IMPORTANT: Every message must be a parsable JSON string without additional outpu
this.register();
}

static fromTemplate<T extends JsonDriver["template"]>(
template: T,
...parameters: ConstructorParameters<typeof this>
) {
const driver = new JsonDriver(...parameters);
driver.template = template;
return driver;
}

protected parseResponse(textResponse: string): unknown {
return parseBrokenJson(textResponse);
}
Expand Down

0 comments on commit 6d3b356

Please sign in to comment.