Bug fix to visibility on TF nodes (#201)

* removed 'source-code-pro' from code css to fix cursor accuracy in code editor (#199)

Co-authored-by: Kayla Zethelyn <kaylazethelyn@college.harvard.edu>

* Refactor duplicate code (#198)

* Refactor common const from JoinNode.js, LLMResponseInspector.js, SplitNode.js and VisNode.js into utils.ts

* unfactor same constant different definition, fixed syntax for multiple imports

---------

Co-authored-by: Kayla Zethelyn <kaylazethelyn@college.harvard.edu>

* Bug fix to update visibility on TF fields

* rebuild react and update version

---------

Co-authored-by: Kayla Z <77540029+kamazet@users.noreply.github.com>
Co-authored-by: Kayla Zethelyn <kaylazethelyn@college.harvard.edu>
This commit is contained in:
ianarawjo 2023-12-29 11:18:21 -05:00 committed by GitHub
parent 69ff3a1452
commit 0af7bdaedd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 76 additions and 134 deletions

View File

@ -1,15 +1,15 @@
{
"files": {
"main.css": "/static/css/main.847ce933.css",
"main.js": "/static/js/main.508b0a68.js",
"main.css": "/static/css/main.15dfff17.css",
"main.js": "/static/js/main.54f8a8b4.js",
"static/js/787.4c72bb55.chunk.js": "/static/js/787.4c72bb55.chunk.js",
"index.html": "/index.html",
"main.847ce933.css.map": "/static/css/main.847ce933.css.map",
"main.508b0a68.js.map": "/static/js/main.508b0a68.js.map",
"main.15dfff17.css.map": "/static/css/main.15dfff17.css.map",
"main.54f8a8b4.js.map": "/static/js/main.54f8a8b4.js.map",
"787.4c72bb55.chunk.js.map": "/static/js/787.4c72bb55.chunk.js.map"
},
"entrypoints": [
"static/css/main.847ce933.css",
"static/js/main.508b0a68.js"
"static/css/main.15dfff17.css",
"static/js/main.54f8a8b4.js"
]
}

View File

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><script async src="https://www.googletagmanager.com/gtag/js?id=G-RN3FDBLMCR"></script><script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","G-RN3FDBLMCR")</script><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="A visual programming environment for prompt engineering"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>ChainForge</title><script defer="defer" src="/static/js/main.508b0a68.js"></script><link href="/static/css/main.847ce933.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><script async src="https://www.googletagmanager.com/gtag/js?id=G-RN3FDBLMCR"></script><script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","G-RN3FDBLMCR")</script><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="A visual programming environment for prompt engineering"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>ChainForge</title><script defer="defer" src="/static/js/main.54f8a8b4.js"></script><link href="/static/css/main.15dfff17.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -8,7 +8,7 @@ import { IconArrowMerge, IconList } from '@tabler/icons-react';
import { Divider, NativeSelect, Text, Popover, Tooltip, Center, Modal, Box } from '@mantine/core';
import { useDisclosure } from '@mantine/hooks';
import { escapeBraces } from './backend/template';
import { countNumLLMs, toStandardResponseFormat } from './backend/utils';
import { countNumLLMs, toStandardResponseFormat, tagMetadataWithLLM, extractLLMLookup, removeLLMTagFromMetadata, truncStr, groupResponsesBy } from './backend/utils';
import StorageCache from './backend/cache';
const formattingOptions = [
@ -55,57 +55,6 @@ const getVarsAndMetavars = (input_data) => {
};
};
const tagMetadataWithLLM = (input_data) => {
let new_data = {};
Object.entries(input_data).forEach(([varname, resp_objs]) => {
new_data[varname] = resp_objs.map(r => {
if (!r || typeof r === 'string' || !r?.llm?.key) return r;
let r_copy = JSON.parse(JSON.stringify(r));
r_copy.metavars["__LLM_key"] = r.llm.key;
return r_copy;
});
});
return new_data;
};
const extractLLMLookup = (input_data) => {
let llm_lookup = {};
Object.values(input_data).forEach((resp_objs) => {
resp_objs.forEach(r => {
if (typeof r === 'string' || !r?.llm?.key || r.llm.key in llm_lookup) return;
llm_lookup[r.llm.key] = r.llm;
});
});
return llm_lookup;
};
const removeLLMTagFromMetadata = (metavars) => {
if (!('__LLM_key' in metavars))
return metavars;
let mcopy = JSON.parse(JSON.stringify(metavars));
delete mcopy['__LLM_key'];
return mcopy;
};
const truncStr = (s, maxLen) => {
if (s.length > maxLen) // Cut the name short if it's long
return s.substring(0, maxLen) + '...';
else
return s;
};
const groupResponsesBy = (responses, keyFunc) => {
let responses_by_key = {};
let unspecified_group = [];
responses.forEach(item => {
const key = keyFunc(item);
const d = key !== null ? responses_by_key : unspecified_group;
if (key in d)
d[key].push(item);
else
d[key] = [item];
});
return [responses_by_key, unspecified_group];
};
const DEFAULT_GROUPBY_VAR_ALL = { label: "all text", value: "A" };
const displayJoinedTexts = (textInfos, getColorForLLM) => {

View File

@ -10,28 +10,9 @@ import { useDisclosure } from '@mantine/hooks';
import { IconTable, IconLayoutList } from '@tabler/icons-react';
import * as XLSX from 'xlsx';
import useStore from './store';
import { filterDict } from './backend/utils';
import { filterDict, truncStr, groupResponsesBy } from './backend/utils';
// Helper funcs
const truncStr = (s, maxLen) => {
if (s.length > maxLen) // Cut the name short if it's long
return s.substring(0, maxLen) + '...'
else
return s;
};
const groupResponsesBy = (responses, keyFunc) => {
let responses_by_key = {};
let unspecified_group = [];
responses.forEach(item => {
const key = keyFunc(item);
const d = key !== null ? responses_by_key : unspecified_group;
if (key in d)
d[key].push(item);
else
d[key] = [item];
});
return [responses_by_key, unspecified_group];
};
const countResponsesBy = (responses, keyFunc) => {
let responses_by_key = {};
let unspecified_group = [];

View File

@ -8,7 +8,7 @@ import { IconArrowMerge, IconArrowsSplit, IconList } from '@tabler/icons-react';
import { Divider, NativeSelect, Text, Popover, Tooltip, Center, Modal, Box } from '@mantine/core';
import { useDisclosure } from '@mantine/hooks';
import { escapeBraces } from './backend/template';
import { processCSV, deepcopy, deepcopy_and_modify, dict_excluding_key, toStandardResponseFormat } from "./backend/utils";
import { processCSV, deepcopy, deepcopy_and_modify, dict_excluding_key, toStandardResponseFormat, tagMetadataWithLLM, extractLLMLookup, removeLLMTagFromMetadata, truncStr } from "./backend/utils";
import { fromMarkdown } from "mdast-util-from-markdown";
import StorageCache from './backend/cache';
@ -22,42 +22,6 @@ const formattingOptions = [
{value: "paragraph", label:"paragraphs (md)"},
];
const truncStr = (s, maxLen) => {
if (s.length > maxLen) // Cut the name short if it's long
return s.substring(0, maxLen) + '...'
else
return s;
};
const tagMetadataWithLLM = (input_data) => {
let new_data = {};
Object.entries(input_data).forEach(([varname, resp_objs]) => {
new_data[varname] = resp_objs.map(r => {
if (!r || typeof r === 'string' || !r?.llm?.key) return r;
let r_copy = JSON.parse(JSON.stringify(r));
r_copy.metavars["__LLM_key"] = r.llm.key;
return r_copy;
});
});
return new_data;
};
const extractLLMLookup = (input_data) => {
let llm_lookup = {};
Object.entries(input_data).forEach(([varname, resp_objs]) => {
resp_objs.forEach(r => {
if (typeof r === 'string' || !r?.llm?.key || r.llm.key in llm_lookup) return;
llm_lookup[r.llm.key] = r.llm;
});
});
return llm_lookup;
};
const removeLLMTagFromMetadata = (metavars) => {
if (!('__LLM_key' in metavars))
return metavars;
let mcopy = JSON.parse(JSON.stringify(metavars));
delete mcopy['__LLM_key'];
return mcopy;
};
/** Flattens markdown AST as dict to text (string) */
function compileTextFromMdAST(md) {
if (md?.value !== undefined)

View File

@ -272,8 +272,8 @@ const TextFieldsNode = ({ data, id }) => {
</div>
) : <></>}
</div>)}),
// Update the text fields only when their values or their placeholders change.
[textfieldsValues, placeholders]);
// Update the text fields only when their values, placeholders, or visibility changes.
[textfieldsValues, placeholders, fieldVisibility]);
return (
<BaseNode classNames="text-fields-node" nodeId={id}>

View File

@ -7,15 +7,9 @@ import BaseNode from './BaseNode';
import NodeLabel from './NodeLabelComponent';
import PlotLegend from './PlotLegend';
import fetch_from_backend from './fetch_from_backend';
import { truncStr } from './backend/utils';
// Helper funcs
const truncStr = (s, maxLen) => {
if (s === undefined) return s;
if (s.length > maxLen) // Cut the name short if it's long
return s.substring(0, maxLen) + '...'
else
return s;
}
const splitAndAddBreaks = (s, chunkSize) => {
// Split the input string into chunks of specified size
let chunks = [];

View File

@ -1108,4 +1108,58 @@ export const browserTabIsActive = () => {
console.error(e);
return true; // indeterminate
}
};
export const tagMetadataWithLLM = (input_data) => {
let new_data = {};
Object.entries(input_data).forEach(([varname, resp_objs]) => {
new_data[varname] = (resp_objs as any[]).map(r => {
if (!r || typeof r === 'string' || !r?.llm?.key) return r;
let r_copy = JSON.parse(JSON.stringify(r));
r_copy.metavars["__LLM_key"] = r.llm.key;
return r_copy;
});
});
return new_data;
};
export const extractLLMLookup = (input_data) => {
let llm_lookup = {};
Object.values(input_data).forEach((resp_objs) => {
(resp_objs as any[]).forEach(r => {
if (typeof r === 'string' || !r?.llm?.key || r.llm.key in llm_lookup) return;
llm_lookup[r.llm.key] = r.llm;
});
});
return llm_lookup;
};
export const removeLLMTagFromMetadata = (metavars) => {
if (!('__LLM_key' in metavars))
return metavars;
let mcopy = JSON.parse(JSON.stringify(metavars));
delete mcopy['__LLM_key'];
return mcopy;
};
export const truncStr = (s, maxLen) => {
if (s === undefined) return s;
if (s.length > maxLen) // Cut the name short if it's long
return s.substring(0, maxLen) + '...';
else
return s;
};
export const groupResponsesBy = (responses, keyFunc) => {
let responses_by_key = {};
let unspecified_group = [];
responses.forEach(item => {
const key = keyFunc(item);
const d = key !== null ? responses_by_key : unspecified_group;
if (key in d)
d[key].push(item);
else
d[key] = [item];
});
return [responses_by_key, unspecified_group];
};

View File

@ -8,7 +8,7 @@ body {
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
font-family: Menlo, Monaco, Consolas, 'Courier New',
monospace;
}

View File

@ -6,7 +6,7 @@ def readme():
setup(
name='chainforge',
version='0.2.8.2',
version='0.2.8.3',
packages=find_packages(),
author="Ian Arawjo",
description="A Visual Programming Environment for Prompt Engineering",