Skip to content

Commit efabd97

Browse files
authored
Add derived types for ResponseTool (#646)
Added derived types for `ResponseTool` to make it easier to work with when used as an output.
1 parent c8c3ef7 commit efabd97

File tree

51 files changed

+10294
-10900
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+10294
-10900
lines changed

api/OpenAI.net8.0.cs

Lines changed: 75 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4685,6 +4685,17 @@ public enum ComputerCallStatus {
46854685
Completed = 1,
46864686
Incomplete = 2
46874687
}
4688+
[Experimental("OPENAI001")]
4689+
public class ComputerTool : ResponseTool, IJsonModel<ComputerTool>, IPersistableModel<ComputerTool> {
4690+
public ComputerTool(ComputerToolEnvironment environment, int displayWidth, int displayHeight);
4691+
public int DisplayHeight { get; set; }
4692+
public int DisplayWidth { get; set; }
4693+
public ComputerToolEnvironment Environment { get; set; }
4694+
protected override ResponseTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
4695+
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
4696+
protected override ResponseTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
4697+
protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
4698+
}
46884699
[Experimental("OPENAICUA001")]
46894700
public readonly partial struct ComputerToolEnvironment : IEquatable<ComputerToolEnvironment> {
46904701
public ComputerToolEnvironment(string value);
@@ -4736,6 +4747,18 @@ public enum FileSearchCallStatus {
47364747
Failed = 4
47374748
}
47384749
[Experimental("OPENAI001")]
4750+
public class FileSearchTool : ResponseTool, IJsonModel<FileSearchTool>, IPersistableModel<FileSearchTool> {
4751+
public FileSearchTool(IEnumerable<string> vectorStoreIds);
4752+
public BinaryData Filters { get; set; }
4753+
public int? MaxResultCount { get; set; }
4754+
public FileSearchToolRankingOptions RankingOptions { get; set; }
4755+
public IList<string> VectorStoreIds { get; }
4756+
protected override ResponseTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
4757+
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
4758+
protected override ResponseTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
4759+
protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
4760+
}
4761+
[Experimental("OPENAI001")]
47394762
public readonly partial struct FileSearchToolRanker : IEquatable<FileSearchToolRanker> {
47404763
public FileSearchToolRanker(string value);
47414764
public static FileSearchToolRanker Auto { get; }
@@ -4796,6 +4819,18 @@ public enum FunctionCallStatus {
47964819
Incomplete = 2
47974820
}
47984821
[Experimental("OPENAI001")]
4822+
public class FunctionTool : ResponseTool, IJsonModel<FunctionTool>, IPersistableModel<FunctionTool> {
4823+
public FunctionTool(string functionName, BinaryData functionParameters, bool? strictModeEnabled);
4824+
public string FunctionDescription { get; set; }
4825+
public string FunctionName { get; set; }
4826+
public BinaryData FunctionParameters { get; set; }
4827+
public bool? StrictModeEnabled { get; set; }
4828+
protected override ResponseTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
4829+
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
4830+
protected override ResponseTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
4831+
protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
4832+
}
4833+
[Experimental("OPENAI001")]
47994834
public class MessageResponseItem : ResponseItem, IJsonModel<MessageResponseItem>, IPersistableModel<MessageResponseItem> {
48004835
public IList<ResponseContentPart> Content { get; }
48014836
public MessageRole Role { get; }
@@ -5301,10 +5336,10 @@ public class ResponseTokenUsage : IJsonModel<ResponseTokenUsage>, IPersistableMo
53015336
[Experimental("OPENAI001")]
53025337
public class ResponseTool : IJsonModel<ResponseTool>, IPersistableModel<ResponseTool> {
53035338
[Experimental("OPENAICUA001")]
5304-
public static ResponseTool CreateComputerTool(ComputerToolEnvironment environment, int displayWidth, int displayHeight);
5305-
public static ResponseTool CreateFileSearchTool(IEnumerable<string> vectorStoreIds, int? maxResultCount = null, FileSearchToolRankingOptions rankingOptions = null, BinaryData filters = null);
5306-
public static ResponseTool CreateFunctionTool(string functionName, string functionDescription, BinaryData functionParameters, bool functionSchemaIsStrict = false);
5307-
public static ResponseTool CreateWebSearchTool(WebSearchUserLocation userLocation = null, WebSearchContextSize? searchContextSize = null);
5339+
public static ComputerTool CreateComputerTool(ComputerToolEnvironment environment, int displayWidth, int displayHeight);
5340+
public static FileSearchTool CreateFileSearchTool(IEnumerable<string> vectorStoreIds, int? maxResultCount = null, FileSearchToolRankingOptions rankingOptions = null, BinaryData filters = null);
5341+
public static FunctionTool CreateFunctionTool(string functionName, BinaryData functionParameters, bool? strictModeEnabled, string functionDescription = null);
5342+
public static WebSearchTool CreateWebSearchTool(WebSearchToolLocation userLocation = null, WebSearchToolContextSize? searchContextSize = null);
53085343
protected virtual ResponseTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
53095344
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
53105345
protected virtual ResponseTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
@@ -5603,28 +5638,50 @@ public enum WebSearchCallStatus {
56035638
Failed = 3
56045639
}
56055640
[Experimental("OPENAI001")]
5606-
public readonly partial struct WebSearchContextSize : IEquatable<WebSearchContextSize> {
5607-
public WebSearchContextSize(string value);
5608-
public static WebSearchContextSize High { get; }
5609-
public static WebSearchContextSize Low { get; }
5610-
public static WebSearchContextSize Medium { get; }
5611-
public readonly bool Equals(WebSearchContextSize other);
5641+
public class WebSearchTool : ResponseTool, IJsonModel<WebSearchTool>, IPersistableModel<WebSearchTool> {
5642+
public WebSearchTool();
5643+
public WebSearchToolContextSize? SearchContextSize { get; set; }
5644+
public WebSearchToolLocation UserLocation { get; set; }
5645+
protected override ResponseTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
5646+
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
5647+
protected override ResponseTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
5648+
protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
5649+
}
5650+
[Experimental("OPENAI001")]
5651+
public class WebSearchToolApproximateLocation : WebSearchToolLocation, IJsonModel<WebSearchToolApproximateLocation>, IPersistableModel<WebSearchToolApproximateLocation> {
5652+
public WebSearchToolApproximateLocation();
5653+
public string City { get; set; }
5654+
public string Country { get; set; }
5655+
public string Region { get; set; }
5656+
public string Timezone { get; set; }
5657+
protected override WebSearchToolLocation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
5658+
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
5659+
protected override WebSearchToolLocation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
5660+
protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
5661+
}
5662+
[Experimental("OPENAI001")]
5663+
public readonly partial struct WebSearchToolContextSize : IEquatable<WebSearchToolContextSize> {
5664+
public WebSearchToolContextSize(string value);
5665+
public static WebSearchToolContextSize High { get; }
5666+
public static WebSearchToolContextSize Low { get; }
5667+
public static WebSearchToolContextSize Medium { get; }
5668+
public readonly bool Equals(WebSearchToolContextSize other);
56125669
[EditorBrowsable(EditorBrowsableState.Never)]
56135670
public override readonly bool Equals(object obj);
56145671
[EditorBrowsable(EditorBrowsableState.Never)]
56155672
public override readonly int GetHashCode();
5616-
public static bool operator ==(WebSearchContextSize left, WebSearchContextSize right);
5617-
public static implicit operator WebSearchContextSize(string value);
5618-
public static implicit operator WebSearchContextSize?(string value);
5619-
public static bool operator !=(WebSearchContextSize left, WebSearchContextSize right);
5673+
public static bool operator ==(WebSearchToolContextSize left, WebSearchToolContextSize right);
5674+
public static implicit operator WebSearchToolContextSize(string value);
5675+
public static implicit operator WebSearchToolContextSize?(string value);
5676+
public static bool operator !=(WebSearchToolContextSize left, WebSearchToolContextSize right);
56205677
public override readonly string ToString();
56215678
}
56225679
[Experimental("OPENAI001")]
5623-
public class WebSearchUserLocation : IJsonModel<WebSearchUserLocation>, IPersistableModel<WebSearchUserLocation> {
5624-
public static WebSearchUserLocation CreateApproximateLocation(string country = null, string region = null, string city = null, string timezone = null);
5625-
protected virtual WebSearchUserLocation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
5680+
public class WebSearchToolLocation : IJsonModel<WebSearchToolLocation>, IPersistableModel<WebSearchToolLocation> {
5681+
public static WebSearchToolApproximateLocation CreateApproximateLocation(string country = null, string region = null, string city = null, string timezone = null);
5682+
protected virtual WebSearchToolLocation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
56265683
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
5627-
protected virtual WebSearchUserLocation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
5684+
protected virtual WebSearchToolLocation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
56285685
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
56295686
}
56305687
}

0 commit comments

Comments
 (0)