-
-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #405 from MervinPraison/develop
Add TypeScript documentation and examples for AI agent tools
- Loading branch information
Showing
16 changed files
with
522 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
title: "Custom Tools for TypeScript AI Agents" | ||
sidebarTitle: "Custom Tools" | ||
description: "Learn how to create custom tools for TypeScript AI Agents" | ||
icon: "toolbox" | ||
--- | ||
|
||
## Single Agent | ||
|
||
```typescript | ||
import { Agent } from 'praisonai'; | ||
|
||
async function getWeather(location: string) { | ||
console.log(`Getting weather for ${location}...`); | ||
return `${Math.floor(Math.random() * 30)}°C`; | ||
} | ||
|
||
const agent = new Agent({ | ||
instructions: `You provide the current weather for requested locations.`, | ||
name: "DirectFunctionAgent", | ||
tools: [getWeather] | ||
}); | ||
|
||
agent.start("What's the weather in Paris, France?"); | ||
``` | ||
|
||
## Multi Agents | ||
|
||
```typescript | ||
import { Agent } from 'praisonai'; | ||
|
||
async function getWeather(location: string) { | ||
console.log(`Getting weather for ${location}...`); | ||
return `${Math.floor(Math.random() * 30)}°C`; | ||
} | ||
|
||
async function getTime(location: string) { | ||
console.log(`Getting time for ${location}...`); | ||
const now = new Date(); | ||
return `${now.getHours()}:${now.getMinutes()}`; | ||
} | ||
|
||
const agent = new Agent({ | ||
instructions: `You provide the current weather and time for requested locations.`, | ||
name: "DirectFunctionAgent", | ||
tools: [getWeather, getTime] | ||
}); | ||
|
||
agent.start("What's the weather and time in Paris, France and Tokyo, Japan?"); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.