Skip to content

Commit 285b4e0

Browse files
HavenDVclaude
andcommitted
Update MEAI tools guide
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8eff3b5 commit 285b4e0

File tree

2 files changed

+51
-61
lines changed

2 files changed

+51
-61
lines changed

docs/guides/meai.md

Lines changed: 49 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,67 @@
11
# Microsoft.Extensions.AI Integration
22

3-
ScrapeGraphAI provides `AIFunction` tools for seamless integration with any `IChatClient` via [Microsoft.Extensions.AI](https://devblogs.microsoft.com/dotnet/introducing-microsoft-extensions-ai-preview/).
3+
!!! tip "Cross-SDK comparison"
4+
See the [centralized MEAI documentation](https://tryagi.github.io/docs/meai/) for feature matrices and comparisons across all tryAGI SDKs.
5+
6+
The ScrapeGraphAI SDK provides `AIFunction` tool wrappers compatible with [Microsoft.Extensions.AI](https://learn.microsoft.com/en-us/dotnet/ai/microsoft-extensions-ai). These tools can be used with any `IChatClient` to give AI models access to ScrapeGraphAI's smart web scraping, AI-powered search, markdown conversion, sitemap extraction, and credit management.
7+
8+
## Installation
9+
10+
```bash
11+
dotnet add package ScrapeGraphAI
12+
```
413

514
## Available Tools
615

7-
| Tool | Method | Description |
8-
|------|--------|-------------|
9-
| SmartScraper | `AsSmartScraperTool()` | Extract structured data from a URL using a natural language prompt |
10-
| SearchScraper | `AsSearchScraperTool()` | AI-powered web search with structured results |
11-
| Markdownify | `AsMarkdownifyTool()` | Convert a webpage to clean markdown |
12-
| GetCredits | `AsGetCreditsTool()` | Check remaining API credit balance |
13-
| GetSitemap | `AsGetSitemapTool()` | Extract all URLs from a website's sitemap |
16+
| Method | Tool Name | Description |
17+
|--------|-----------|-------------|
18+
| `AsSmartScraperTool()` | `SmartScraper` | Extract structured data from a URL using natural language prompts |
19+
| `AsSearchScraperTool()` | `SearchScraper` | AI-powered web search with structured results |
20+
| `AsMarkdownifyTool()` | `Markdownify` | Convert a webpage to clean, readable markdown |
21+
| `AsGetCreditsTool()` | `GetCredits` | Check remaining API credits and total usage |
22+
| `AsGetSitemapTool()` | `GetSitemap` | Extract all URLs from a website's sitemap |
1423

15-
## Usage Example
24+
## Usage
1625

1726
```csharp
18-
using Microsoft.Extensions.AI;
1927
using ScrapeGraphAI;
28+
using Microsoft.Extensions.AI;
2029

21-
// Create the ScrapeGraphAI client
22-
using var scraper = new ScrapeGraphAIClient(apiKey);
30+
var scrapeClient = new ScrapeGraphAIClient(
31+
apiKey: Environment.GetEnvironmentVariable("SGAI_API_KEY")!);
2332

24-
// Create tools
25-
var tools = new[]
33+
var options = new ChatOptions
2634
{
27-
scraper.AsSmartScraperTool(),
28-
scraper.AsSearchScraperTool(),
29-
scraper.AsMarkdownifyTool(),
35+
Tools =
36+
[
37+
scrapeClient.AsSmartScraperTool(),
38+
scrapeClient.AsSearchScraperTool(),
39+
scrapeClient.AsMarkdownifyTool(),
40+
scrapeClient.AsGetCreditsTool(),
41+
scrapeClient.AsGetSitemapTool(),
42+
],
3043
};
3144

32-
// Use with any IChatClient
3345
IChatClient chatClient = /* your chat client */;
34-
var response = await chatClient.GetResponseAsync(
35-
"Extract the main heading from https://example.com",
36-
new ChatOptions { Tools = tools });
37-
```
38-
39-
## Tool Details
40-
41-
### SmartScraper
4246

43-
Extracts structured data from any website using AI. Requires a URL and a natural language prompt describing what to extract.
44-
45-
```csharp
46-
var tool = client.AsSmartScraperTool();
47-
```
48-
49-
### SearchScraper
50-
51-
Performs an AI-powered web search and returns structured results. Optionally configure the number of results (3-20).
52-
53-
```csharp
54-
var tool = client.AsSearchScraperTool(numResults: 5);
55-
```
56-
57-
### Markdownify
58-
59-
Converts a webpage to clean, readable markdown format.
60-
61-
```csharp
62-
var tool = client.AsMarkdownifyTool();
63-
```
64-
65-
### GetCredits
66-
67-
Retrieves the current credit balance and total credits used.
68-
69-
```csharp
70-
var tool = client.AsGetCreditsTool();
71-
```
72-
73-
### GetSitemap
74-
75-
Extracts all URLs from a website's sitemap.
47+
var messages = new List<ChatMessage>
48+
{
49+
new(ChatRole.User, "Extract the pricing information from https://example.com/pricing"),
50+
};
7651

77-
```csharp
78-
var tool = client.AsGetSitemapTool();
52+
while (true)
53+
{
54+
var response = await chatClient.GetResponseAsync(messages, options);
55+
messages.AddRange(response.ToChatMessages());
56+
57+
if (response.FinishReason == ChatFinishReason.ToolCalls)
58+
{
59+
var results = await response.CallToolsAsync(options);
60+
messages.AddRange(results);
61+
continue;
62+
}
63+
64+
Console.WriteLine(response.Text);
65+
break;
66+
}
7967
```

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
site_name: ScrapeGraphAI .NET Documentation
22
nav:
33
- Overview: index.md
4+
- Guides:
5+
- Microsoft.Extensions.AI: guides/meai.md
46
# EXAMPLES:START
57
# EXAMPLES:END
68

0 commit comments

Comments
 (0)