From 356b5e5624265d0d3646c0ab8bc8311e961b3086 Mon Sep 17 00:00:00 2001 From: Robat Williams Date: Thu, 21 Dec 2023 14:22:25 +0000 Subject: [PATCH] Don't try and keep _lines and text value private --- README.md | 2 +- src/functions/functions.mjs | 2 +- testFramework/completionEntityStub.mjs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b6f3708..e5f2791 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Completions populate the cell with a custom data type which includes the complet To obtain the text value for use in formulas, use the `VALUETOTEXT()` function. To obtain other request/response data, use dot notation to the property path (e.g. `A123.response.model`). -To view the completion data, open the entity card. The `_lines` property provides a line-by-line view of the completion content. +To view the completion data, open the entity card. The `lines` property provides a line-by-line view of the completion content. To extract a final answer that follows a chain of thought, you could use a formula such as: diff --git a/src/functions/functions.mjs b/src/functions/functions.mjs index 4766a38..946a068 100644 --- a/src/functions/functions.mjs +++ b/src/functions/functions.mjs @@ -73,7 +73,7 @@ export async function chatComplete(messages, params, invocation) { _entityKind: COMPLETION_ENTITY_KIND, // For visibility of newlines without needing to use cell text wrap. - _lines: + lines: json.choices.length === 1 ? json.choices[0].message.content.split('\n') : json.choices.map((choice) => choice.message.content.split('\n')), diff --git a/testFramework/completionEntityStub.mjs b/testFramework/completionEntityStub.mjs index a582588..901c562 100644 --- a/testFramework/completionEntityStub.mjs +++ b/testFramework/completionEntityStub.mjs @@ -8,14 +8,14 @@ export function makeCompletionEntity({ type: 'Entity', basicType: 'Error', basicValue: '#VALUE!', - text: undefined, // Not for programmatic use + text: content ?? '', properties: { _entityKind: { type: 'String', basicType: 'String', basicValue: 'openai-excel-functions:chat-completion', }, - _lines: undefined, // Not for programmatic use + lines: (content ?? '').split('\n'), requestBody: { type: 'Entity', basicType: 'Error',