Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/Cellm/AddIn/CellmFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,11 @@ public static object Run(object providerAndModel, object instructions, object[]
// Do work on background thread, releasing Excel's main thread to keep UI responsive
var response = ExcelAsyncUtil.RunTaskWithCancellation(
nameof(Run),
// Add callerCoordinates to make task arguments unique, otherwise all concurrent calls
// with identical arguments will reuse the response from the first call that finishes.
// ExcelDNA calls this function twice. Once when invoked and once when result is ready
// at which point the list of arguments is used as key to pair result with first call
// at which point the list of arguments is used as key to pair result with first call.
// We therefore add callerCoordinates to make task arguments unique, otherwise all calls
// concurrent with identical arguments will reuse the response from the first call that
// finishes.
new object[] { providerAndModel, instructions, ranges, callerCoordinates },
cancellationToken => GetResponseAsync(arguments, wallClock, callerCoordinates, cancellationToken));

Expand Down Expand Up @@ -265,7 +266,7 @@ public static object Run(object providerAndModel, object instructions, object[]
}

/// <summary>
/// Builds a prompt, sends it to the model, and returns the response.
/// Builds a prompt, sends it to a model, and returns the response.
/// </summary>
internal static async Task<object> GetResponseAsync(Arguments arguments, Stopwatch wallClock, string callerCoordinates, CancellationToken cancellationToken)
{
Expand All @@ -277,7 +278,7 @@ internal static async Task<object> GetResponseAsync(Arguments arguments, Stopwat

try
{
logger.LogInformation("Sending {caller} to {provider}/{model} ...", callerCoordinates, arguments.Provider, arguments.Model);
logger.LogInformation("Sending {callerCoordinates} to {provider}/{model} ...", callerCoordinates, arguments.Provider, arguments.Model);

// Check for cancellation before doing any work
cancellationToken.ThrowIfCancellationRequested();
Expand Down
2 changes: 1 addition & 1 deletion src/Cellm/Models/Prompts/PromptBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ internal PromptBuilder AddUserMessage(string content)

internal PromptBuilder AddAssistantMessage(string content)
{
_messages.Add(new ChatMessage(ChatRole.User, content));
_messages.Add(new ChatMessage(ChatRole.Assistant, content));
return this;
}

Expand Down
Loading