Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TabularDataNode supports Replace and Extend for AiGen #312

Merged
merged 9 commits into from
Dec 19, 2024

Conversation

Kraft-Cheese
Copy link
Contributor

TabularDataNode now has the AiGen button available and can generate a table from a prompt.

modified:   src/AiPopover.tsx
            Added support for table replacement
            and future support for extension.
modified:   src/TabularDataNode.tsx
            Added the AiPopover button and
            functionality for table replacement.
modified:   src/backend/ai.ts
            Added specific prompts and decoding
            for markdown table generation.
new file:   src/backend/tableUtils.ts
            Seperated the parsing for tables into
            a seperate utility file for better
            organization and future extensibility.
modified:   src/AiPopover.tsx
            Added support for table replacement
            and future support for extension.
modified:   src/TabularDataNode.tsx
            Added the AiPopover button and
            functionality for table replacement.
modified:   src/backend/ai.ts
            Added specific prompts and decoding
            for markdown table generation.
new file:   src/backend/tableUtils.ts
            Seperated the parsing for tables into
            a seperate utility file for better
            organization and future extensibility.

Testing Values
@Kraft-Cheese
Copy link
Contributor Author

Kraft-Cheese commented Dec 16, 2024

There was also a typing issue that I fixed with Models in fromModelId in utils.ts but this can be dropped.

chainforge/react-server/src/AiPopover.tsx Outdated Show resolved Hide resolved
]),
];

console.log("System message: ", autofillSystemMessage(n, templateVariables));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to remove extraneous logs!

chainforge/react-server/src/backend/ai.ts Show resolved Hide resolved
chainforge/react-server/src/backend/ai.ts Outdated Show resolved Hide resolved
chainforge/react-server/src/AiPopover.tsx Show resolved Hide resolved
@Kraft-Cheese
Copy link
Contributor Author

Added changes for extend in the most recent commit, as well as removing the extraneous logs and imports.

@Kraft-Cheese Kraft-Cheese changed the title TabularDataNode supports replace for AiGen TabularDataNode supports Replace and Extend for AiGen Dec 17, 2024
modified:   src/AiPopover.tsx
            Removed unnecessary import.
            Changed handleCommandFill to work with
            autofillTable function in ai.ts.
modified:   src/TabularDataNode.tsx
            Removed Skeleton from Popover.
            Changed addMultipleRows such that it
            now renders the new rows correctly
            and removes the blank row.
modified:   src/backend/ai.ts
            Added autofillTable function and
            changed decodeTable so that they
            are flexible with both proper and
            improper markdown tables.
            Added new system message prompt
            specific to autofillTable.
            Removed unneccessary log statements.
removed:    src/backend/utils.ts
            Removed change.
modified:   src/AiPopover.tsx
            Added handleGenerateColumn so that
            a column can be generated given
            a prompt.
            Added changes to the TablePopover UI
            Now extend is diveded into AddRow
            and AddColumn sections.
modified:   src/TabularDataNode.tsx
            Modified addColumns so that its safer.
            Added optional pass of rowValue to
            support generateColumn.
modified:   src/backend/ai.ts
            Added generateColumn and it's
            corresponding system message.
Cleaned up some comments and added missing commas.
@Kraft-Cheese
Copy link
Contributor Author

Kraft-Cheese commented Dec 17, 2024

Add column has been added along with changes to the popover UI

console.log("LLM said: ", result.responses[0].responses[0]);

// Decode the LLM response as a column in a markdown table
const columnValues = decodeTable(result.responses[0].responses[0] as string);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is dangerous, because it relies upon the LLM to exactly reproduce the table. As I mentioned in our Discord conversation, you should instead batch the table into say, 5-row batches, then ask the LLM for a list of items that represents the items in the new column, for each item in the table. Importantly, in this solution, you do not ask the LLM to reproduce the table. This solution is also scalable because you have to imagine the tables in ChainForge can be quite large ---say, 1000 rows. Inputting 1000 rows directly into the context will likely not work; even if it does it will not be able to reproduce the table exactly, and even then, even if it can, it's a waste of $$.

So, batch into a series of 5 or 10-row batches, ask for the items as a list, then loop over this until complete.

chainforge/react-server/src/backend/ai.ts Show resolved Hide resolved
processing of the rows for generating the
new column values.

modified:   src/AiPopover.tsx
            Fixed the key issue for onAddColumn.
modified:   src/TabularDataNode.tsx
            Changed addColumns to filter out
            previously added columns.
modified:   src/backend/ai.ts
            Changed generateColumns to process
            item-by-item to generate new columns.
@ianarawjo ianarawjo changed the base branch from main to synth-tab-data December 19, 2024 18:31
@ianarawjo ianarawjo merged commit 29278d5 into ianarawjo:synth-tab-data Dec 19, 2024
ianarawjo added a commit that referenced this pull request Dec 19, 2024
* TabularDataNode supports Replace and Extend for AiGen (#312)

* Testing Values

* Fixed typing issue with Models in fromModelId

* TabularDataNode now supports table generation.
modified:   src/AiPopover.tsx
            Added support for table replacement
            and future support for extension.
modified:   src/TabularDataNode.tsx
            Added the AiPopover button and
            functionality for table replacement.
modified:   src/backend/ai.ts
            Added specific prompts and decoding
            for markdown table generation.
new file:   src/backend/tableUtils.ts
            Seperated the parsing for tables into
            a seperate utility file for better
            organization and future extensibility.

* Fixed typing issue with Models in fromModelId

* TabularDataNode now supports table generation.
modified:   src/AiPopover.tsx
            Added support for table replacement
            and future support for extension.
modified:   src/TabularDataNode.tsx
            Added the AiPopover button and
            functionality for table replacement.
modified:   src/backend/ai.ts
            Added specific prompts and decoding
            for markdown table generation.
new file:   src/backend/tableUtils.ts
            Seperated the parsing for tables into
            a seperate utility file for better
            organization and future extensibility.

Testing Values

* Added Extend Functionality to Table Popover.
modified:   src/AiPopover.tsx
            Removed unnecessary import.
            Changed handleCommandFill to work with
            autofillTable function in ai.ts.
modified:   src/TabularDataNode.tsx
            Removed Skeleton from Popover.
            Changed addMultipleRows such that it
            now renders the new rows correctly
            and removes the blank row.
modified:   src/backend/ai.ts
            Added autofillTable function and
            changed decodeTable so that they
            are flexible with both proper and
            improper markdown tables.
            Added new system message prompt
            specific to autofillTable.
            Removed unneccessary log statements.
removed:    src/backend/utils.ts
            Removed change.

* Added "add column" prompt & button in TablePopover

modified:   src/AiPopover.tsx
            Added handleGenerateColumn so that
            a column can be generated given
            a prompt.
            Added changes to the TablePopover UI
            Now extend is diveded into AddRow
            and AddColumn sections.
modified:   src/TabularDataNode.tsx
            Modified addColumns so that its safer.
            Added optional pass of rowValue to
            support generateColumn.
modified:   src/backend/ai.ts
            Added generateColumn and it's
            corresponding system message.
Cleaned up some comments and added missing commas.

* Generate Columns now considers item-by-item
processing of the rows for generating the
new column values.

modified:   src/AiPopover.tsx
            Fixed the key issue for onAddColumn.
modified:   src/TabularDataNode.tsx
            Changed addColumns to filter out
            previously added columns.
modified:   src/backend/ai.ts
            Changed generateColumns to process
            item-by-item to generate new columns.

* Fix bugs. Change OpenAI small model for GenAI features to GPT-4o.

* Update package version

* Remove gen diverse outputs switch in genAI for table

---------

Co-authored-by: Kraft-Cheese <114844630+Kraft-Cheese@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants