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..1c21337 100644 --- a/testFramework/completionEntityStub.mjs +++ b/testFramework/completionEntityStub.mjs @@ -15,7 +15,7 @@ export function makeCompletionEntity({ basicType: 'String', basicValue: 'openai-excel-functions:chat-completion', }, - _lines: undefined, // Not for programmatic use + lines: (content ?? '').split('\n'), requestBody: { type: 'Entity', basicType: 'Error',