mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Show tweaked formula in AI responses
Summary: The formula that's used when the Apply button is clicked, and the formula that's shown in responses from the Formula Assistant should now be the same. Previously, they would differ slightly. Test Plan: Server tests. Reviewers: alexmojaki Reviewed By: alexmojaki Subscribers: alexmojaki Differential Revision: https://phab.getgrist.com/D3977
This commit is contained in:
@@ -635,25 +635,24 @@ export class FormulaAssistant extends Disposable {
|
||||
// Get the state of the chat from the column.
|
||||
const conversationId = this._chat.conversationId.get();
|
||||
const prevState = column.chatHistory.peek().get().state;
|
||||
const {reply, suggestedActions, state} = await askAI(gristDoc, {
|
||||
const {reply, suggestedActions, suggestedFormula, state} = await askAI(gristDoc, {
|
||||
conversationId,
|
||||
column,
|
||||
description,
|
||||
state: prevState,
|
||||
});
|
||||
console.debug('suggestedActions', {suggestedActions, reply, state});
|
||||
console.debug('received formula assistant response: ', {suggestedActions, suggestedFormula, reply, state});
|
||||
// If back-end is capable of conversation, keep its state.
|
||||
const chatHistoryNew = column.chatHistory.peek();
|
||||
const value = chatHistoryNew.get();
|
||||
value.state = state;
|
||||
const formula = (suggestedActions[0]?.[3] as any)?.formula as string;
|
||||
// If model has a conversational skills (and maintains a history), we might get actually
|
||||
// some markdown text back, so we need to parse it.
|
||||
const prettyMessage = state ? (reply || formula || '') : (formula || reply || '');
|
||||
const prettyMessage = state ? (reply || suggestedFormula || '') : (suggestedFormula || reply || '');
|
||||
// Add it to the chat.
|
||||
return {
|
||||
message: prettyMessage,
|
||||
formula,
|
||||
formula: suggestedFormula,
|
||||
action: suggestedActions[0],
|
||||
sender: 'ai',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user