diff --git a/OpenAI-DotNet/Common/Function.cs b/OpenAI-DotNet/Common/Function.cs
index 1cb0352f..2142987c 100644
--- a/OpenAI-DotNet/Common/Function.cs
+++ b/OpenAI-DotNet/Common/Function.cs
@@ -73,6 +73,12 @@ public Function(string name, string description, string parameters)
Parameters = JsonNode.Parse(parameters);
}
+ internal Function(string name, JsonNode arguments)
+ {
+ Name = name;
+ Arguments = arguments;
+ }
+
private Function(string name, string description, MethodInfo method, object instance = null)
{
if (!Regex.IsMatch(name, NameRegex))
diff --git a/OpenAI-DotNet/Common/Tool.cs b/OpenAI-DotNet/Common/Tool.cs
index 427cdc61..8bfa3094 100644
--- a/OpenAI-DotNet/Common/Tool.cs
+++ b/OpenAI-DotNet/Common/Tool.cs
@@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
+using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
@@ -23,6 +24,13 @@ public Tool(Function function)
Type = nameof(function);
}
+ public Tool(string toolCallId, string functionName, JsonNode functionArguments)
+ {
+ Function = new Function(functionName, arguments: functionArguments);
+ Type = "function";
+ Id = toolCallId;
+ }
+
public Tool(FileSearchOptions fileSearchOptions)
{
Type = "file_search";
diff --git a/OpenAI-DotNet/OpenAI-DotNet.csproj b/OpenAI-DotNet/OpenAI-DotNet.csproj
index cab9dfda..b6ebd04c 100644
--- a/OpenAI-DotNet/OpenAI-DotNet.csproj
+++ b/OpenAI-DotNet/OpenAI-DotNet.csproj
@@ -29,8 +29,10 @@ More context [on Roger Pincombe's blog](https://rogerpincombe.com/openai-dotnet-
OpenAI-DotNet.pfx
true
true
- 8.1.1
+ 8.1.2
+Version 8.1.2
+- Added constructor overloads to Tool and Function classes to support manually adding tool calls in the conversation history
Version 8.1.1
- Added overloads to Assistant streaming event callbacks to include event name: Func<String, IServerSentEvent, Task>
Version 8.1.0