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
277 changes: 0 additions & 277 deletions src/Cellm/AddIn/ArgumentParser.cs

This file was deleted.

12 changes: 6 additions & 6 deletions src/Cellm/AddIn/Functions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static class Functions
/// </returns>
[ExcelFunction(Name = "PROMPT", Description = "Send a prompt to the default model")]
public static object Prompt(
[ExcelArgument(AllowReference = true, Name = "Context", Description = "A cell or range of cells")] object context,
[ExcelArgument(AllowReference = true, Name = "InstructionsOrContext", Description = "A string with instructions or a cell or range of cells with context")] object context,
[ExcelArgument(Name = "InstructionsOrTemperature", Description = "A cell or range of cells with instructions or a temperature")] object instructionsOrTemperature,
[ExcelArgument(Name = "Temperature", Description = "Temperature")] object temperature)
{
Expand All @@ -52,7 +52,7 @@ public static object Prompt(
/// Sends a prompt to the specified model.
/// </summary>
/// <param name="providerAndModel">The provider and model in the format "provider/model".</param>
/// <param name="context">A cell or range of cells containing the context for the prompt.</param>
/// <param name="instructionsOrContext">A string with instructions or a cell or range of cells with context.</param>
/// <param name="instructionsOrTemperature">
/// A cell or range of cells with instructions, or a temperature value.
/// If omitted, any instructions found in the context will be used.
Expand All @@ -67,16 +67,16 @@ public static object Prompt(
[ExcelFunction(Name = "PROMPTWITH", Description = "Send a prompt to a specific model")]
public static object PromptWith(
[ExcelArgument(AllowReference = true, Name = "Provider/Model")] object providerAndModel,
[ExcelArgument(AllowReference = true, Name = "Context", Description = "A cell or range of cells")] object context,
[ExcelArgument(AllowReference = true, Name = "InstructionsOrContext", Description = "A string with instructions or a cell or range of cells with context")] object instructionsOrContext,
[ExcelArgument(Name = "InstructionsOrTemperature", Description = "A cell or range of cells with instructions or a temperature")] object instructionsOrTemperature,
[ExcelArgument(Name = "Temperature", Description = "Temperature")] object temperature)
{
try
{
var arguments = ServiceLocator.Get<ArgumentParser>()
var arguments = ServiceLocator.Get<PromptWithArgumentParser>()
.AddProvider(providerAndModel)
.AddModel(providerAndModel)
.AddContext(context)
.AddInstructionsOrContext(instructionsOrContext)
.AddInstructionsOrTemperature(instructionsOrTemperature)
.AddTemperature(temperature)
.Parse();
Expand All @@ -94,7 +94,7 @@ public static object PromptWith(
.Build();

// ExcelAsyncUtil yields Excel's main thread, Task.Run enables async/await in inner code
return ExcelAsyncUtil.Run(nameof(PromptWith), new object[] { providerAndModel, context, instructionsOrTemperature, temperature }, () =>
return ExcelAsyncUtil.Run(nameof(PromptWith), new object[] { providerAndModel, instructionsOrContext, instructionsOrTemperature, temperature }, () =>
{
return Task.Run(async () => await CallModelAsync(prompt, arguments.Provider)).GetAwaiter().GetResult();
});
Expand Down
Loading