-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Renamed
SmartThreadDataAdapter
to ThreadSourceAdapter
for clarity.
- Updated `SmartThreadJsonDataAdapter` to extend from the new `ThreadSourceAdapter`. - Introduced `FileSourceAdapter` for file handling, replacing the deprecated `TextSourceAdapter`. - Modified `MarkdownSourceAdapter` to extend from `FileSourceAdapter`, enhancing file operations. - Added new `JsonTemplateSourceAdapter` for JSON file persistence in templates. - Created a new lookup JSON template for structured data handling. - Commented out unimplemented methods in `SourceAdapter` to clarify intended functionality.
- Loading branch information
Brian Joseph Petro
committed
Dec 3, 2024
1 parent
f46230b
commit 1756140
Showing
8 changed files
with
60 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { SourceAdapter } from "./_adapter.js"; | ||
export class FileSourceAdapter extends SourceAdapter { | ||
async update(content) { | ||
await this.fs.write(this.file_path, content); | ||
} | ||
async read() { | ||
return await this.fs.read(this.file_path); | ||
} | ||
get file_path() { return this.item.file_path; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { FileSourceAdapter } from "smart-sources/adapters/file.js"; | ||
|
||
/** | ||
* @class SmartTemplateJsonSourceAdapter | ||
* @extends SmartTemplateDataAdapter | ||
* @description for persisting OpenAI chat completion responses to JSON files | ||
*/ | ||
export class JsonTemplateSourceAdapter extends FileSourceAdapter { | ||
static extension = 'json'; | ||
extension = 'json'; | ||
async to_source_file(){ | ||
const file_content = { | ||
...this.item.data, | ||
}; | ||
await this.update(JSON.stringify(file_content, null, 2)); | ||
} | ||
async from_source_file() { | ||
const source_file = await this.read(); | ||
const parsed_data = JSON.parse(source_file); | ||
this.item.data = { | ||
...this.item.data, | ||
...parsed_data, | ||
blocks: undefined | ||
}; | ||
// parsed_data.blocks.forEach(block => { | ||
// this.item.env.template_outputs.items[block.key] = new this.item.env.template_outputs.item_type( | ||
// this.item.env, | ||
// block | ||
// ); | ||
// }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"opts": {}, | ||
"tool": {}, | ||
"output": {} | ||
} |