mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
add support for conversational state to assistance endpoint (#506)
* add support for conversational state to assistance endpoint This refactors the assistance code somewhat, to allow carrying along some conversational state. It extends the OpenAI-flavored assistant to make use of that state to have a conversation. The front-end is tweaked a little bit to allow for replies that don't have any code in them (though I didn't get into formatting such replies nicely). Currently tested primarily through the runCompletion script, which has been extended a bit to allow testing simulated conversations (where an error is pasted in follow-up, or an expected-vs-actual comparison). Co-authored-by: George Gevoian <85144792+georgegevoian@users.noreply.github.com>
This commit is contained in:
@@ -376,7 +376,8 @@ export class GranularAccess implements GranularAccessForBundle {
|
||||
function fail(): never {
|
||||
throw new ErrorWithCode('ACL_DENY', 'Cannot access cell');
|
||||
}
|
||||
if (!await this.hasTableAccess(docSession, cell.tableId)) { fail(); }
|
||||
const hasExceptionalAccess = this._hasExceptionalFullAccess(docSession);
|
||||
if (!hasExceptionalAccess && !await this.hasTableAccess(docSession, cell.tableId)) { fail(); }
|
||||
let rows: TableDataAction|null = null;
|
||||
if (docData) {
|
||||
const record = docData.getTable(cell.tableId)?.getRecord(cell.rowId);
|
||||
@@ -393,16 +394,18 @@ export class GranularAccess implements GranularAccessForBundle {
|
||||
return fail();
|
||||
}
|
||||
const rec = new RecordView(rows, 0);
|
||||
const input: AclMatchInput = {...await this.inputs(docSession), rec, newRec: rec};
|
||||
const rowPermInfo = new PermissionInfo(this._ruler.ruleCollection, input);
|
||||
const rowAccess = rowPermInfo.getTableAccess(cell.tableId).perms.read;
|
||||
if (rowAccess === 'deny') { fail(); }
|
||||
if (rowAccess !== 'allow') {
|
||||
const colAccess = rowPermInfo.getColumnAccess(cell.tableId, cell.colId).perms.read;
|
||||
if (colAccess === 'deny') { fail(); }
|
||||
if (!hasExceptionalAccess) {
|
||||
const input: AclMatchInput = {...await this.inputs(docSession), rec, newRec: rec};
|
||||
const rowPermInfo = new PermissionInfo(this._ruler.ruleCollection, input);
|
||||
const rowAccess = rowPermInfo.getTableAccess(cell.tableId).perms.read;
|
||||
if (rowAccess === 'deny') { fail(); }
|
||||
if (rowAccess !== 'allow') {
|
||||
const colAccess = rowPermInfo.getColumnAccess(cell.tableId, cell.colId).perms.read;
|
||||
if (colAccess === 'deny') { fail(); }
|
||||
}
|
||||
const colValues = rows[3];
|
||||
if (!(cell.colId in colValues)) { fail(); }
|
||||
}
|
||||
const colValues = rows[3];
|
||||
if (!(cell.colId in colValues)) { fail(); }
|
||||
return rec.get(cell.colId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user