Skip to content

Commit 52461d2

Browse files
committed
Add TypeScript documentation and examples for AI agent tools
- Expanded documentation for TypeScript AI agents with tool registration examples - Added new documentation pages for custom tools in TypeScript - Updated installation and quickstart guides to include TypeScript sections - Created example scripts demonstrating single and multi-agent tool usage - Introduced new documentation for external tools like Google Trends
1 parent f9ba1c8 commit 52461d2

File tree

16 files changed

+522
-103
lines changed

16 files changed

+522
-103
lines changed

docs/index.mdx

Lines changed: 98 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,27 +114,53 @@ agents.start()
114114
</Steps>
115115
</Tab>
116116
<Tab title="No Code">
117-
<Tip>
118-
PraisonAI combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customization, and efficient human-agent collaboration.
119-
</Tip>
120117
<Steps>
121118
<Step title="Install Package">
119+
Install the No Code PraisonAI Package:
122120
```bash
123-
pip install praisonai
121+
pip install praisonaiagents
124122
```
125123
</Step>
124+
126125
<Step title="Set API Key">
127126
```bash
128-
export OPENAI_API_KEY=xxxxxxxxxxxxxxxxxxxxxx
127+
export OPENAI_API_KEY=your_openai_key
129128
```
130129
</Step>
131-
<Step title="Auto Mode">
132-
```bash
133-
praisonai --auto create a movie script about Robots in Mars
134-
```
135130

136-
This will automatically create required agents and complete the task
131+
<Step title="Create Config">
132+
Create `agents.yaml`:
133+
134+
<CodeGroup>
135+
```yaml Single Agent
136+
roles:
137+
summarise_agent:
138+
instructions: Summarise Photosynthesis
139+
```
140+
141+
```yaml Multiple Agents
142+
roles:
143+
diet_agent:
144+
instructions: Give me 5 healthy food recipes
145+
blog_agent:
146+
instructions: Write a blog post about the food recipes
147+
```
148+
</CodeGroup>
137149
150+
<Note>
151+
You can automatically create `agents.yaml` using:
152+
```bash
153+
praisonai --init "your task description"
154+
```
155+
</Note>
156+
157+
</Step>
158+
159+
<Step title="Run Agents">
160+
Execute your config:
161+
```bash
162+
praisonai agents.yaml
163+
```
138164
</Step>
139165
</Steps>
140166
</Tab>
@@ -180,6 +206,68 @@ agents.start();
180206
</Step>
181207
</Steps>
182208
</Tab>
209+
<Tab title="TypeScript">
210+
<Steps>
211+
<Step title="Install Package">
212+
<CodeGroup>
213+
```bash npm
214+
npm install praisonai
215+
```
216+
```bash yarn
217+
yarn add praisonai
218+
```
219+
</CodeGroup>
220+
</Step>
221+
<Step title="Set API Key">
222+
```bash
223+
export OPENAI_API_KEY=xxxxxxxxxxxxxxxxxxxxxx
224+
```
225+
</Step>
226+
<Step title="Create File">
227+
Create `app.ts` file
228+
229+
## Code Example
230+
231+
<CodeGroup>
232+
```javascript Single Agent
233+
import { Agent } from 'praisonai';
234+
235+
const agent = new Agent({
236+
instructions: `You are a creative writer who writes short stories with emojis.`,
237+
name: "StoryWriter"
238+
});
239+
240+
agent.start("Write a story about a time traveler")
241+
```
242+
243+
```javascript Multi Agents
244+
import { Agent, PraisonAIAgents } from 'praisonai';
245+
246+
const storyAgent = new Agent({
247+
instructions: "Generate a very short story (2-3 sentences) about artificial intelligence with emojis.",
248+
name: "StoryAgent"
249+
});
250+
251+
const summaryAgent = new Agent({
252+
instructions: "Summarize the provided AI story in one sentence with emojis.",
253+
name: "SummaryAgent"
254+
});
255+
256+
const agents = new PraisonAIAgents({
257+
agents: [storyAgent, summaryAgent]
258+
});
259+
260+
agents.start()
261+
```
262+
</CodeGroup>
263+
</Step>
264+
<Step title="Run Script">
265+
```bash
266+
npx ts-node app.ts
267+
```
268+
</Step>
269+
</Steps>
270+
</Tab>
183271
</Tabs>
184272

185273
## AI Agents Flow

docs/installation.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ pip install praisonai
1414
```bash JavaScript
1515
npm install praisonai
1616
```
17+
```bash TypeScript
18+
npm install praisonai
19+
```
1720
</RequestExample>
1821

1922
<Note>
@@ -109,6 +112,22 @@ Follow these steps to set up PraisonAI in your development environment.
109112
</Step>
110113
</Steps>
111114
</Tab>
115+
<Tab title="TypeScript">
116+
<Steps>
117+
<Step title="Install PraisonAI">
118+
Install the PraisonAI package:
119+
```bash
120+
npm install praisonai
121+
```
122+
</Step>
123+
<Step title="Set API Key">
124+
Set your OpenAI API key as an environment variable in your terminal:
125+
```bash
126+
export OPENAI_API_KEY=your_openai_key
127+
```
128+
</Step>
129+
</Steps>
130+
</Tab>
112131
</Tabs>
113132

114133
Generate your OpenAI API key from [OpenAI](https://platform.openai.com/api-keys)

docs/introduction.mdx

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,68 @@ agents.start();
248248
</Step>
249249
</Steps>
250250
</Tab>
251+
<Tab title="TypeScript">
252+
<Steps>
253+
<Step title="Install Package">
254+
<CodeGroup>
255+
```bash npm
256+
npm install praisonai
257+
```
258+
```bash yarn
259+
yarn add praisonai
260+
```
261+
</CodeGroup>
262+
</Step>
263+
<Step title="Set API Key">
264+
```bash
265+
export OPENAI_API_KEY=xxxxxxxxxxxxxxxxxxxxxx
266+
```
267+
</Step>
268+
<Step title="Create File">
269+
Create `app.ts` file
270+
271+
## Code Example
272+
273+
<CodeGroup>
274+
```javascript Single Agent
275+
import { Agent } from 'praisonai';
276+
277+
const agent = new Agent({
278+
instructions: `You are a creative writer who writes short stories with emojis.`,
279+
name: "StoryWriter"
280+
});
281+
282+
agent.start("Write a story about a time traveler")
283+
```
284+
285+
```javascript Multi Agents
286+
import { Agent, PraisonAIAgents } from 'praisonai';
287+
288+
const storyAgent = new Agent({
289+
instructions: "Generate a very short story (2-3 sentences) about artificial intelligence with emojis.",
290+
name: "StoryAgent"
291+
});
292+
293+
const summaryAgent = new Agent({
294+
instructions: "Summarize the provided AI story in one sentence with emojis.",
295+
name: "SummaryAgent"
296+
});
297+
298+
const agents = new PraisonAIAgents({
299+
agents: [storyAgent, summaryAgent]
300+
});
301+
302+
agents.start()
303+
```
304+
</CodeGroup>
305+
</Step>
306+
<Step title="Run Script">
307+
```bash
308+
npx ts-node app.ts
309+
```
310+
</Step>
311+
</Steps>
312+
</Tab>
251313
</Tabs>
252314

253315
## Key Features

docs/js/customtools.mdx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
title: "Custom Tools for TypeScript AI Agents"
3+
sidebarTitle: "Custom Tools"
4+
description: "Learn how to create custom tools for TypeScript AI Agents"
5+
icon: "toolbox"
6+
---
7+
8+
## Single Agent
9+
10+
```typescript
11+
import { Agent } from 'praisonai';
12+
13+
async function getWeather(location: string) {
14+
console.log(`Getting weather for ${location}...`);
15+
return `${Math.floor(Math.random() * 30)}°C`;
16+
}
17+
18+
const agent = new Agent({
19+
instructions: `You provide the current weather for requested locations.`,
20+
name: "DirectFunctionAgent",
21+
tools: [getWeather]
22+
});
23+
24+
agent.start("What's the weather in Paris, France?");
25+
```
26+
27+
## Multi Agents
28+
29+
```typescript
30+
import { Agent } from 'praisonai';
31+
32+
async function getWeather(location: string) {
33+
console.log(`Getting weather for ${location}...`);
34+
return `${Math.floor(Math.random() * 30)}°C`;
35+
}
36+
37+
async function getTime(location: string) {
38+
console.log(`Getting time for ${location}...`);
39+
const now = new Date();
40+
return `${now.getHours()}:${now.getMinutes()}`;
41+
}
42+
43+
const agent = new Agent({
44+
instructions: `You provide the current weather and time for requested locations.`,
45+
name: "DirectFunctionAgent",
46+
tools: [getWeather, getTime]
47+
});
48+
49+
agent.start("What's the weather and time in Paris, France and Tokyo, Japan?");
50+
```

docs/js/typescript.mdx

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -268,74 +268,12 @@ agents.start()
268268
## Tool Calls Examples
269269

270270
<AccordionGroup>
271-
<Accordion title="Single Agent Tool Call" icon="wrench" defaultOpen>
272-
Create an agent that can use tools to get information:
273-
274-
```typescript
275-
import { Agent } from 'praisonai';
276-
277-
/**
278-
* Example of a simple agent with tool calling capability
279-
*
280-
* This example demonstrates how to create a simple agent that can use tools
281-
* to get weather information for a location.
282-
*/
283-
284-
// Define a weather tool
285-
const getWeather = {
286-
type: "function",
287-
function: {
288-
name: "get_weather",
289-
description: "Get current temperature for a given location.",
290-
parameters: {
291-
type: "object",
292-
properties: {
293-
location: {
294-
type: "string",
295-
description: "City and country e.g. Bogotá, Colombia"
296-
}
297-
},
298-
required: ["location"],
299-
additionalProperties: false
300-
},
301-
strict: true
302-
}
303-
};
304-
305-
// Make the function globally available
306-
// The agent will automatically find and use this function
307-
(global as any).get_weather = async function(location: string) {
308-
console.log(`Getting weather for ${location}...`);
309-
return `20°C`;
310-
};
311-
312-
// Create an agent with the weather tool
313-
const agent = new Agent({
314-
instructions: `You provide the current weather for requested locations.`,
315-
name: "WeatherAgent",
316-
tools: [getWeather]
317-
});
318-
319-
// Start the agent with a prompt that will trigger tool usage
320-
agent.start("What's the weather in Paris, France?");
321-
```
322-
</Accordion>
323-
324271
<Accordion title="Direct Function Tools" icon="code" defaultOpen>
325272
Create an agent with directly registered function tools:
326273

327274
```typescript
328275
import { Agent } from 'praisonai';
329276

330-
/**
331-
* Example of a simple agent with direct function registration
332-
*
333-
* This example demonstrates how to create a simple agent that uses directly
334-
* registered functions as tools without having to define tool schemas manually
335-
* or make functions globally available.
336-
*/
337-
338-
// Define the functions directly
339277
async function getWeather(location: string) {
340278
console.log(`Getting weather for ${location}...`);
341279
return `${Math.floor(Math.random() * 30)}°C`;
@@ -347,15 +285,12 @@ async function getTime(location: string) {
347285
return `${now.getHours()}:${now.getMinutes()}`;
348286
}
349287

350-
// Create an agent with directly registered functions
351288
const agent = new Agent({
352289
instructions: `You provide the current weather and time for requested locations.`,
353290
name: "DirectFunctionAgent",
354-
// Register functions directly as an array without needing to make them global
355291
tools: [getWeather, getTime]
356292
});
357293

358-
// Start the agent with a prompt that will trigger tool usage
359294
agent.start("What's the weather and time in Paris, France and Tokyo, Japan?");
360295
```
361296
</Accordion>

docs/mint.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,14 @@
244244
"group": "JavaScript",
245245
"pages": [
246246
"js/js",
247-
"js/typescript",
247+
{
248+
"group": "TypeScript Agents",
249+
"icon": "subscript",
250+
"pages": [
251+
"js/typescript",
252+
"js/customtools"
253+
]
254+
},
248255
"js/nodejs",
249256
"js/typescript-async",
250257
"js/development"

0 commit comments

Comments
 (0)