mirror of
https://github.com/ianarawjo/ChainForge.git
synced 2025-03-14 08:16:37 +00:00
Fix numeric table imports and make LLM response order consistent w vars order (#178)
* Convert table values to strings upon export * Make ordering of LLM responses consistent w vars dict ordering * Rebuild react and package version * Make sure ordering considers vars as objects
This commit is contained in:
parent
1eae5edf89
commit
a9e1ad691c
@ -1,15 +1,15 @@
|
||||
{
|
||||
"files": {
|
||||
"main.css": "/static/css/main.8665fcca.css",
|
||||
"main.js": "/static/js/main.50d66017.js",
|
||||
"main.js": "/static/js/main.6e3da685.js",
|
||||
"static/js/787.4c72bb55.chunk.js": "/static/js/787.4c72bb55.chunk.js",
|
||||
"index.html": "/index.html",
|
||||
"main.8665fcca.css.map": "/static/css/main.8665fcca.css.map",
|
||||
"main.50d66017.js.map": "/static/js/main.50d66017.js.map",
|
||||
"main.6e3da685.js.map": "/static/js/main.6e3da685.js.map",
|
||||
"787.4c72bb55.chunk.js.map": "/static/js/787.4c72bb55.chunk.js.map"
|
||||
},
|
||||
"entrypoints": [
|
||||
"static/css/main.8665fcca.css",
|
||||
"static/js/main.50d66017.js"
|
||||
"static/js/main.6e3da685.js"
|
||||
]
|
||||
}
|
@ -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.50d66017.js"></script><link href="/static/css/main.8665fcca.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.6e3da685.js"></script><link href="/static/css/main.8665fcca.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
@ -575,6 +575,8 @@ export async function queryLLM(id: string,
|
||||
llm = llm as (Array<string> | Array<Dict>);
|
||||
|
||||
await setAPIKeys(api_keys);
|
||||
|
||||
console.log(vars);
|
||||
|
||||
// Get the storage keys of any cache files for specific models + settings
|
||||
const llms = llm;
|
||||
@ -718,7 +720,23 @@ export async function queryLLM(id: string,
|
||||
}
|
||||
|
||||
// Convert the responses into a more standardized format with less information
|
||||
const res = Object.values(responses).flatMap(rs => rs.map(to_standard_format));
|
||||
let res = Object.values(responses).flatMap(rs => rs.map(to_standard_format));
|
||||
|
||||
// Reorder the responses to match the original vars dict ordering of keys and values
|
||||
res.sort((a, b) => {
|
||||
if (!a.vars || !b.vars) return 0;
|
||||
for (const [varname, vals] of Object.entries(vars)) {
|
||||
if (varname in a.vars && varname in b.vars) {
|
||||
const a_val = a.vars[varname];
|
||||
const b_val = b.vars[varname];
|
||||
const a_idx = vals.findIndex(v => v === a_val || v?.text === a_val);
|
||||
const b_idx = vals.findIndex(v => v === b_val || v?.text === b_val);
|
||||
if (a_idx > -1 && b_idx > -1 && a_idx !== b_idx)
|
||||
return a_idx - b_idx;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
// Save the responses *of this run* to the storage cache, for further recall:
|
||||
let cache_filenames = past_cache_files;
|
||||
|
6
chainforge/react-server/src/store.js
vendored
6
chainforge/react-server/src/store.js
vendored
@ -160,18 +160,18 @@ const useStore = create((set, get) => ({
|
||||
const row_keys = Object.keys(row);
|
||||
|
||||
// Check if this is an 'empty' row (with all empty strings); if so, skip it:
|
||||
if (row_keys.every(key => key === '__uid' || !row[key] || row[key].trim() === ""))
|
||||
if (row_keys.every(key => key === '__uid' || !row[key] || (typeof row[key] === "string" && row[key].trim() === "")))
|
||||
return undefined;
|
||||
|
||||
const row_excluding_col = {};
|
||||
row_keys.forEach(key => {
|
||||
if (key !== src_col.key && key !== '__uid')
|
||||
row_excluding_col[col_header_lookup[key]] = row[key];
|
||||
row_excluding_col[col_header_lookup[key]] = row[key].toString();
|
||||
});
|
||||
return {
|
||||
// We escape any braces in the source text before they're passed downstream.
|
||||
// This is a special property of tabular data nodes: we don't want their text to be treated as prompt templates.
|
||||
text: escapeBraces((src_col.key in row) ? row[src_col.key] : ""),
|
||||
text: escapeBraces((src_col.key in row) ? row[src_col.key].toString() : ""),
|
||||
metavars: row_excluding_col,
|
||||
associate_id: row.__uid, // this is used by the backend to 'carry' certain values together
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user