Skip to content

CopilotWebSearchFunction

NexusLabs.Needlr.Copilot

CopilotWebSearchFunction Class

Microsoft.Extensions.AI.AIFunction that calls the Copilot MCP server's web_search tool. Register this with Needlr's agent framework tool set to give agents access to Copilot's AI-powered web search.

public sealed class CopilotWebSearchFunction : Microsoft.Extensions.AI.AIFunction

Inheritance System.Object 🡒 Microsoft.Extensions.AI.AITool 🡒 Microsoft.Extensions.AI.AIFunctionDeclaration 🡒 Microsoft.Extensions.AI.AIFunction 🡒 CopilotWebSearchFunction

Example

var tools = CopilotToolSet.Create(new CopilotToolSetOptions { EnableWebSearch = true });
// Pass tools to an agent via IterativeLoopOptions.Tools

Properties

CopilotWebSearchFunction.Description Property

Gets a description of the tool, suitable for use in describing the purpose to a model.

public override string Description { get; }

Property Value

System.String

CopilotWebSearchFunction.JsonSchema Property

Gets a JSON Schema describing the function and its input parameters.

public override System.Text.Json.JsonElement JsonSchema { get; }

Property Value

System.Text.Json.JsonElement

Remarks

When specified, declares a self-contained JSON schema document that describes the function and its input parameters. A simple example of a JSON schema for a function that adds two numbers together is shown below:

{
  "type": "object",
  "properties": {
    "a" : { "type": "number" },
    "b" : { "type": ["number","null"], "default": 1 }
  },
  "required" : ["a"]
}

The metadata present in the schema document plays an important role in guiding AI function invocation.

When no schema is specified, consuming chat clients should assume the "{}" or "true" schema, indicating that any JSON input is admissible.

CopilotWebSearchFunction.Name Property

Gets the name of the tool.

public override string Name { get; }

Property Value

System.String