mirror of
https://github.com/ianarawjo/ChainForge.git
synced 2025-03-14 16:26:45 +00:00
Make ordering of LLM responses consistent w vars dict ordering
This commit is contained in:
parent
687c277a22
commit
d00788369c
@ -718,7 +718,21 @@ 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_idx = vals.indexOf(a.vars[varname]);
|
||||
const b_idx = vals.indexOf(b.vars[varname]);
|
||||
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;
|
||||
|
1
chainforge/react-server/src/store.js
vendored
1
chainforge/react-server/src/store.js
vendored
@ -160,7 +160,6 @@ 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:
|
||||
console.log(row);
|
||||
if (row_keys.every(key => key === '__uid' || !row[key] || (typeof row[key] === "string" && row[key].trim() === "")))
|
||||
return undefined;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user