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
25 changes: 24 additions & 1 deletion api/OpenAI.net8.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6058,7 +6058,8 @@ public class ResponseTool : IJsonModel<ResponseTool>, IPersistableModel<Response
public static ImageGenerationTool CreateImageGenerationTool(string model, ImageGenerationToolQuality? quality = null, ImageGenerationToolSize? size = null, ImageGenerationToolOutputFileFormat? outputFileFormat = null, int? outputCompressionFactor = null, ImageGenerationToolModerationLevel? moderationLevel = null, ImageGenerationToolBackground? background = null, ImageGenerationToolInputFidelity? inputFidelity = null, ImageGenerationToolInputImageMask inputImageMask = null, int? partialImageCount = null);
public static McpTool CreateMcpTool(string serverLabel, McpToolConnectorId connectorId, string authorizationToken = null, string serverDescription = null, IDictionary<string, string> headers = null, McpToolFilter allowedTools = null, McpToolCallApprovalPolicy toolCallApprovalPolicy = null);
public static McpTool CreateMcpTool(string serverLabel, Uri serverUri, string authorizationToken = null, string serverDescription = null, IDictionary<string, string> headers = null, McpToolFilter allowedTools = null, McpToolCallApprovalPolicy toolCallApprovalPolicy = null);
public static WebSearchTool CreateWebSearchTool(WebSearchToolLocation userLocation = null, WebSearchToolContextSize? searchContextSize = null);
public static WebSearchPreviewTool CreateWebSearchPreviewTool(WebSearchToolLocation userLocation = null, WebSearchToolContextSize? searchContextSize = null);
public static WebSearchTool CreateWebSearchTool(WebSearchToolLocation userLocation = null, WebSearchToolContextSize? searchContextSize = null, WebSearchToolFilters filters = null);
protected virtual ResponseTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
protected virtual ResponseTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
Expand Down Expand Up @@ -6597,8 +6598,19 @@ public enum WebSearchCallStatus {
Failed = 3
}
[Experimental("OPENAI001")]
public class WebSearchPreviewTool : ResponseTool, IJsonModel<WebSearchPreviewTool>, IPersistableModel<WebSearchPreviewTool> {
public WebSearchPreviewTool();
public WebSearchToolContextSize? SearchContextSize { get; set; }
public WebSearchToolLocation UserLocation { get; set; }
protected override ResponseTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
protected override ResponseTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
[Experimental("OPENAI001")]
public class WebSearchTool : ResponseTool, IJsonModel<WebSearchTool>, IPersistableModel<WebSearchTool> {
public WebSearchTool();
public WebSearchToolFilters Filters { get; set; }
public WebSearchToolContextSize? SearchContextSize { get; set; }
public WebSearchToolLocation UserLocation { get; set; }
protected override ResponseTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
Expand Down Expand Up @@ -6636,6 +6648,17 @@ public class WebSearchToolApproximateLocation : WebSearchToolLocation, IJsonMode
public override readonly string ToString();
}
[Experimental("OPENAI001")]
public class WebSearchToolFilters : IJsonModel<WebSearchToolFilters>, IPersistableModel<WebSearchToolFilters> {
public IList<string> AllowedDomains { get; set; }
[EditorBrowsable(EditorBrowsableState.Never)]
[Experimental("SCME0001")]
public ref JsonPatch Patch { get; }
protected virtual WebSearchToolFilters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
protected virtual WebSearchToolFilters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
[Experimental("OPENAI001")]
public class WebSearchToolLocation : IJsonModel<WebSearchToolLocation>, IPersistableModel<WebSearchToolLocation> {
[EditorBrowsable(EditorBrowsableState.Never)]
[Experimental("SCME0001")]
Expand Down
22 changes: 21 additions & 1 deletion api/OpenAI.netstandard2.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5320,7 +5320,8 @@ public class ResponseTool : IJsonModel<ResponseTool>, IPersistableModel<Response
public static ImageGenerationTool CreateImageGenerationTool(string model, ImageGenerationToolQuality? quality = null, ImageGenerationToolSize? size = null, ImageGenerationToolOutputFileFormat? outputFileFormat = null, int? outputCompressionFactor = null, ImageGenerationToolModerationLevel? moderationLevel = null, ImageGenerationToolBackground? background = null, ImageGenerationToolInputFidelity? inputFidelity = null, ImageGenerationToolInputImageMask inputImageMask = null, int? partialImageCount = null);
public static McpTool CreateMcpTool(string serverLabel, McpToolConnectorId connectorId, string authorizationToken = null, string serverDescription = null, IDictionary<string, string> headers = null, McpToolFilter allowedTools = null, McpToolCallApprovalPolicy toolCallApprovalPolicy = null);
public static McpTool CreateMcpTool(string serverLabel, Uri serverUri, string authorizationToken = null, string serverDescription = null, IDictionary<string, string> headers = null, McpToolFilter allowedTools = null, McpToolCallApprovalPolicy toolCallApprovalPolicy = null);
public static WebSearchTool CreateWebSearchTool(WebSearchToolLocation userLocation = null, WebSearchToolContextSize? searchContextSize = null);
public static WebSearchPreviewTool CreateWebSearchPreviewTool(WebSearchToolLocation userLocation = null, WebSearchToolContextSize? searchContextSize = null);
public static WebSearchTool CreateWebSearchTool(WebSearchToolLocation userLocation = null, WebSearchToolContextSize? searchContextSize = null, WebSearchToolFilters filters = null);
protected virtual ResponseTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
protected virtual ResponseTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
Expand Down Expand Up @@ -5802,8 +5803,18 @@ public enum WebSearchCallStatus {
Completed = 2,
Failed = 3
}
public class WebSearchPreviewTool : ResponseTool, IJsonModel<WebSearchPreviewTool>, IPersistableModel<WebSearchPreviewTool> {
public WebSearchPreviewTool();
public WebSearchToolContextSize? SearchContextSize { get; set; }
public WebSearchToolLocation UserLocation { get; set; }
protected override ResponseTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
protected override ResponseTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
public class WebSearchTool : ResponseTool, IJsonModel<WebSearchTool>, IPersistableModel<WebSearchTool> {
public WebSearchTool();
public WebSearchToolFilters Filters { get; set; }
public WebSearchToolContextSize? SearchContextSize { get; set; }
public WebSearchToolLocation UserLocation { get; set; }
protected override ResponseTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
Expand Down Expand Up @@ -5838,6 +5849,15 @@ public class WebSearchToolApproximateLocation : WebSearchToolLocation, IJsonMode
public static bool operator !=(WebSearchToolContextSize left, WebSearchToolContextSize right);
public override readonly string ToString();
}
public class WebSearchToolFilters : IJsonModel<WebSearchToolFilters>, IPersistableModel<WebSearchToolFilters> {
public IList<string> AllowedDomains { get; set; }
[EditorBrowsable(EditorBrowsableState.Never)]
public ref JsonPatch Patch { get; }
protected virtual WebSearchToolFilters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
protected virtual WebSearchToolFilters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
public class WebSearchToolLocation : IJsonModel<WebSearchToolLocation>, IPersistableModel<WebSearchToolLocation> {
[EditorBrowsable(EditorBrowsableState.Never)]
public ref JsonPatch Patch { get; }
Expand Down
27 changes: 26 additions & 1 deletion specification/base/typespec/responses/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ union ToolType {
file_search: "file_search",
function: "function",
computer_use_preview: "computer_use_preview",
web_search: "web_search",
web_search_preview: "web_search_preview",
mcp: "mcp",
code_interpreter: "code_interpreter",
Expand Down Expand Up @@ -613,7 +614,31 @@ model WebSearchPreviewTool extends Tool {
@doc("""
High level guidance for the amount of context window space to use for the search. One of `low`, `medium`, or `high`. `medium` is the default.
""")
search_context_size?: "low" | "medium" | "high";
search_context_size?: SearchContextSize;
}

// Tool customization (apply_discriminator): Apply discriminated type base for tools
/** This tool searches the web for relevant results to use in a response. Learn more about the [web search tool](https://platform.openai.com/docs/guides/tools-web-search). */
model WebSearchTool extends Tool {
/** The type of the web search tool. One of `web_search` or `web_search_2025_08_26`. */
type: ToolType.web_search;

filters?: WebSearchToolFilters | null;

user_location?: Location | null;

/** High level guidance for the amount of context window space to use for the search. One of `low`, `medium`, or `high`. `medium` is the default. */
search_context_size?: SearchContextSize;
}

enum SearchContextSize {
low,
medium,
high,
}

model WebSearchToolFilters {
allowed_domains?: string[] | null;
}

// Tool customization: Establish a discriminated base for location approximation
Expand Down
1 change: 1 addition & 0 deletions specification/client/responses.client.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ using TypeSpec.HttpClient.CSharp;
@@dynamicModel(ResponseCodeInterpreterCallInterpretingEvent);
@@dynamicModel(TopLogProb);
@@dynamicModel(LogProb);
@@dynamicModel(WebSearchToolFilters);
// custom.tsp models
@@dynamicModel(ResponseErrorResponse);
@@dynamicModel(DeleteResponseResponse);
Expand Down
13 changes: 12 additions & 1 deletion src/Custom/Responses/Tools/ResponseTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,20 @@ public static FileSearchTool CreateFileSearchTool(IEnumerable<string> vectorStor
}

// CUSTOM: Added factory method as a convenience.
public static WebSearchTool CreateWebSearchTool(WebSearchToolLocation userLocation = null, WebSearchToolContextSize? searchContextSize = null)
public static WebSearchTool CreateWebSearchTool(WebSearchToolLocation userLocation = null, WebSearchToolContextSize? searchContextSize = null, WebSearchToolFilters filters = null)
{
return new WebSearchTool(
kind: InternalToolType.WebSearch,
patch: default,
userLocation: userLocation,
searchContextSize: searchContextSize,
filters: filters);
}

// CUSTOM: Added factory method as a convenience.
public static WebSearchPreviewTool CreateWebSearchPreviewTool(WebSearchToolLocation userLocation = null, WebSearchToolContextSize? searchContextSize = null)
{
return new WebSearchPreviewTool(
kind: InternalToolType.WebSearchPreview,
patch: default,
userLocation: userLocation,
Expand Down
7 changes: 7 additions & 0 deletions src/Custom/Responses/Tools/WebSearchPreviewTool.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace OpenAI.Responses;

// CUSTOM: Renamed.
[CodeGenType("WebSearchPreviewTool")]
public partial class WebSearchPreviewTool
{
}
4 changes: 2 additions & 2 deletions src/Custom/Responses/Tools/WebSearchTool.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace OpenAI.Responses;

// CUSTOM: Renamed.
[CodeGenType("WebSearchPreviewTool")]
[CodeGenType("WebSearchTool")]
public partial class WebSearchTool
{
}
}
2 changes: 1 addition & 1 deletion src/Custom/Responses/Tools/WebSearchToolContextSize.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace OpenAI.Responses;

// CUSTOM: Renamed.
[CodeGenType("WebSearchPreviewToolSearchContextSize")]
[CodeGenType("SearchContextSize")]
public readonly partial struct WebSearchToolContextSize
{
}
7 changes: 7 additions & 0 deletions src/Custom/Responses/Tools/WebSearchToolFilters.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace OpenAI.Responses;

// CUSTOM: Renamed.
[CodeGenType("WebSearchToolFilters")]
public partial class WebSearchToolFilters
{
}
2 changes: 2 additions & 0 deletions src/Generated/Models/OpenAIContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,10 @@ namespace OpenAI
[ModelReaderWriterBuildable(typeof(VectorStoreFileError))]
[ModelReaderWriterBuildable(typeof(VectorStoreModificationOptions))]
[ModelReaderWriterBuildable(typeof(WebSearchCallResponseItem))]
[ModelReaderWriterBuildable(typeof(WebSearchPreviewTool))]
[ModelReaderWriterBuildable(typeof(WebSearchTool))]
[ModelReaderWriterBuildable(typeof(WebSearchToolApproximateLocation))]
[ModelReaderWriterBuildable(typeof(WebSearchToolFilters))]
[ModelReaderWriterBuildable(typeof(WebSearchToolLocation))]
[ModelReaderWriterBuildable(typeof(WeightsAndBiasesIntegration))]
public partial class OpenAIContext : ModelReaderWriterContext
Expand Down
3 changes: 3 additions & 0 deletions src/Generated/Models/Responses/InternalToolType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace OpenAI.Responses
private const string FileSearchValue = "file_search";
private const string FunctionValue = "function";
private const string ComputerUsePreviewValue = "computer_use_preview";
private const string WebSearchValue = "web_search";
private const string WebSearchPreviewValue = "web_search_preview";
private const string McpValue = "mcp";
private const string CodeInterpreterValue = "code_interpreter";
Expand All @@ -33,6 +34,8 @@ public InternalToolType(string value)

internal static InternalToolType ComputerUsePreview { get; } = new InternalToolType(ComputerUsePreviewValue);

internal static InternalToolType WebSearch { get; } = new InternalToolType(WebSearchValue);

internal static InternalToolType WebSearchPreview { get; } = new InternalToolType(WebSearchPreviewValue);

internal static InternalToolType Mcp { get; } = new InternalToolType(McpValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ internal static ResponseTool DeserializeResponseTool(JsonElement element, Binary
case "computer_use_preview":
return ComputerTool.DeserializeComputerTool(element, data, options);
case "web_search_preview":
return WebSearchPreviewTool.DeserializeWebSearchPreviewTool(element, data, options);
case "web_search":
return WebSearchTool.DeserializeWebSearchTool(element, data, options);
case "code_interpreter":
return CodeInterpreterTool.DeserializeCodeInterpreterTool(element, data, options);
Expand Down
Loading
Loading