Skip to content

Commit 331cf1c

Browse files
jagnani73gane5h
andauthored
chore: docs (#81)
* refactor: tests * wip: chore docs * wip: chore docs * docs: readmes * chore(cza): update templates * fix: build * fix: anthropic * fix(anthropic): zee * nit * feat(zee): image handling * fic --------- Co-authored-by: Ganesh Swami <[email protected]>
1 parent d727661 commit 331cf1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+663
-505
lines changed

README.md

+14-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# AI Agent SDK for TypeScript
44

5-
[📖 Documentation](https://cxt.build/) |
5+
[📖 Documentation](https://cxt.build/) |
66
[✍🏻 ZEE Use-cases](https://cxt.build/docs/use-cases/overview)
77

88
<br />
@@ -15,7 +15,6 @@
1515
[![GitHub issues](https://img.shields.io/github/issues/covalenthq/ai-agent-sdk)](https://github.com/covalenthq/ai-agent-sdk/issues)
1616
[![GitHub pull requests](https://img.shields.io/github/issues-pr/covalenthq/ai-agent-sdk)](https://github.com/covalenthq/ai-agent-sdk/pulls)
1717

18-
1918
[![GitHub stars](https://img.shields.io/github/stars/covalenthq/ai-agent-sdk)](https://github.com/covalenthq/ai-agent-sdk/stargazers)
2019
[![GitHub forks](https://img.shields.io/github/forks/covalenthq/ai-agent-sdk)](https://github.com/covalenthq/ai-agent-sdk/network/members)
2120

@@ -25,10 +24,10 @@
2524

2625
## Features
2726

28-
- LLMs - a unified interface for all LLMs
29-
- Agents - a single model with a system prompt and a set of tools
30-
- Tools - extend the capabilities of agents with external tools
31-
- ZEE Workflows - compose agents to solve complex problems
27+
- LLMs - a unified interface for all LLMs
28+
- Agents - a single model with a system prompt and a set of tools
29+
- Tools - extend the capabilities of agents with external tools
30+
- ZEE Workflows - compose agents to solve complex problems
3231

3332
## Using the SDK (Quick Start)
3433

@@ -45,27 +44,31 @@ const agent1 = new Agent({
4544
name: "Agent1",
4645
model: {
4746
provider: "OPEN_AI",
48-
name: "gpt-4o-mini",
47+
id: "gpt-4o-mini",
4948
},
5049
description: "A helpful AI assistant that can engage in conversation.",
50+
instructions: ["Interact with the user in a friendly and helpful manner"],
5151
});
5252
```
5353

5454
### 3. Modify the ZEE Workflow
5555

5656
```js
5757
const zee = new ZeeWorkflow({
58-
description: "A workflow of agents that do stuff together",
59-
output: "Just bunch of stuff",
60-
agents: { agent1, agent2 },
58+
goal: "A workflow of agents that do stuff together",
59+
agents: [agent1, agent2],
60+
model: {
61+
provider: "OPEN_AI",
62+
id: "gpt-4o-mini",
63+
},
6164
});
6265
```
6366

6467
### 4. Run the Zee Workflow
6568

6669
```js
6770
(async function main() {
68-
const result = await ZeeWorkflow.run(zee);
71+
const result = await zee.run();
6972
console.log(result);
7073
})();
7174
```

docs/concepts/agents.mdx

+18-9
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,45 @@ The simplest way to create an Agent is to use initialize an Agent with a model,
1616
const agent = new Agent({
1717
name: "Reporting Agent",
1818
model: {
19-
provider: "OPEN_AI",
20-
name: "gpt-4o-mini",
19+
provider: "openai",
20+
id: "gpt-4o-mini",
2121
},
2222
description: "This agent is responsible for generating reports",
23-
instructions: ["Generate a report on the current state of the company"],
23+
instructions: [
24+
"Generate a report on the current state of the company",
25+
"Use the following tools to help you generate the report",
26+
],
2427
});
2528
```
2629

2730
## Adding tools
2831

29-
[Tools](/concepts/tools) are optional and can be added to an Agent to extend its capabilities. Tools are included in the calls to the language model through features like OpenAI's [function calling](https://platform.openai.com/docs/guides/function-calling) or Claude's [tool use](https://docs.anthropic.com/en/docs/build-with-claude/tool-use).
32+
[Tools](/concepts/tools) are optional and can be added to an Agent to extend its capabilities. Tools are included in the calls to the language model through the [tools](https://sdk.vercel.ai/docs/ai-sdk-core/tools-and-tool-calling) property.
3033

31-
Tools are created using the `createTool` function and can be sent to the agent using the `tools` property during initialization.
34+
Tools are created using the `Tool` class and can be sent to the agent using the `tools` property during initialization.
3235

3336
```typescript
3437
const agent = new Agent({
3538
name: "Reporting Agent",
3639
...
37-
tools: [tool1, tool2, tool3],
40+
tools: {
41+
tool1,
42+
tool2,
43+
tool3,
44+
},
3845
});
3946
```
4047

4148
Read more about [Tools](/concepts/tools) to learn how to create them.
4249

4350
## Running an Agent
4451

45-
Agents can be run standalone or as part of a ZEE workflow. Running an agent standalone is useful for testing and debugging. The `run` method will return the final state of the agent.
52+
Agents can be run standalone or as part of a ZEE workflow. Running an agent standalone is useful for testing and debugging. The `generate` method will run the agent standalone.
4653

4754
```typescript
48-
const result = await agent.run();
55+
const result = await agent.generate({
56+
messages: [userMessage("What is the current state of the company?")],
57+
});
4958
```
5059

51-
Running an agent as part of a ZEE workflow is useful for solving complex problems. Read more about [ZEE](/concepts/zeeworkflows) to learn how to run agents in a ZEE workflow.
60+
Running an agent as part of a ZEE workflow is useful for solving complex problems. Read more about [ZEE](/concepts/zee-workflows) to learn how to run agents in a ZEE workflow.

docs/concepts/llms.mdx

+83-76
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,72 @@ description: Overview of supported language models, including OpenAI, Anthropic,
44
icon: "computer-classic"
55
---
66

7-
Each LLM is an adapter around a language model provider and the specific model version, eg: `gpt-4o-mini`. Each [Agent](./agents) can pick their own model and a [ZeeWorkflow](./zeeworkflows) can be configured to use a specific LLM as default.
7+
Each LLM is an adapter around a language model provider and the specific model version, eg: `gpt-4o-mini`. Each [Agent](/agents) can pick their own model and a [ZeeWorkflow](/zee-workflows) can be configured to use a specific LLM as default.
88

99
```tsx
1010
const llm = new LLM({
11-
provider: "OPEN_AI",
12-
name: "gpt-4o-mini",
13-
apiKey: process.env.OPENAI_API_KEY,
14-
temperature: 0.7
11+
provider: "openai",
12+
id: "gpt-4o-mini",
1513
});
1614
```
1715

18-
## List of supported LLMs
19-
20-
### Open AI
16+
## List of supported LLM Model IDs
2117

2218
<CodeGroup>
2319

24-
```plaintext OpenAI
25-
"gpt-4"
26-
"gpt-4-turbo"
27-
"gpt-3.5-turbo"
20+
```plaintext openai
2821
"gpt-4o"
2922
"gpt-4o-mini"
30-
"o3-mini"
31-
```
32-
33-
```plaintext DeepSeek
34-
"deepseek-chat"
35-
"deepseek-coder"
23+
"gpt-4o-2024-05-13"
24+
"gpt-4o-2024-08-06"
25+
"gpt-4o-2024-11-20"
26+
"gpt-4o-audio-preview"
27+
"gpt-4o-audio-preview-2024-10-01"
28+
"gpt-4o-audio-preview-2024-12-17"
29+
"gpt-4o-mini-2024-07-18"
30+
"gpt-4-turbo"
31+
"gpt-4-turbo-2024-04-09"
32+
"gpt-4-turbo-preview"
33+
"gpt-4-0125-preview"
34+
"gpt-4-1106-preview"
35+
"gpt-4"
36+
"gpt-4-0613"
37+
"gpt-3.5-turbo-0125"
38+
"gpt-3.5-turbo"
39+
"gpt-3.5-turbo-1106"
3640
```
3741

38-
```plaintext Grok
39-
"grok-2-latest"
40-
"grok-beta"
42+
```plaintext anthropic
43+
"claude-3-5-sonnet-latest"
44+
"claude-3-5-sonnet-20241022"
45+
"claude-3-5-sonnet-20240620"
46+
"claude-3-5-haiku-latest"
47+
"claude-3-5-haiku-20241022"
48+
"claude-3-opus-latest"
49+
"claude-3-opus-20240229"
50+
"claude-3-sonnet-20240229"
51+
"claude-3-haiku-20240307"
4152
```
4253

43-
```plaintext Gemini
54+
```plaintext google
55+
"gemini-2.0-flash-001"
4456
"gemini-1.5-flash"
57+
"gemini-1.5-flash-latest"
58+
"gemini-1.5-flash-001"
59+
"gemini-1.5-flash-002"
60+
"gemini-1.5-flash-8b"
61+
"gemini-1.5-flash-8b-latest"
62+
"gemini-1.5-flash-8b-001"
4563
"gemini-1.5-pro"
64+
"gemini-1.5-pro-latest"
65+
"gemini-1.5-pro-001"
66+
"gemini-1.5-pro-002"
67+
"gemini-2.0-flash-lite-preview-02-05"
68+
"gemini-2.0-pro-exp-02-05"
69+
"gemini-2.0-flash-thinking-exp-01-21"
70+
"gemini-2.0-flash-exp"
71+
"gemini-exp-1206"
72+
"learnlm-1.5-pro-experimental"
4673
```
4774

4875
</CodeGroup>
@@ -51,20 +78,16 @@ const llm = new LLM({
5178

5279
<CodeGroup>
5380

54-
```plaintext OpenAI
81+
```plaintext openai
5582
OPENAI_API_KEY
5683
```
5784

58-
```plaintext DeepSeek
59-
DEEPSEEK_API_KEY
60-
```
61-
62-
```plaintext Grok
63-
GROK_API_KEY
85+
```plaintext anthropic
86+
ANTHROPIC_API_KEY
6487
```
6588

66-
```plaintext Gemini
67-
GEMINI_API_KEY
89+
```plaintext google
90+
GOOGLE_GENERATIVE_AI_API_KEY
6891
```
6992

7093
</CodeGroup>
@@ -77,57 +100,41 @@ LLMs can also process images along with text using image URL messages. Here's an
77100

78101
```typescript
79102
const messages = [
80-
{
81-
role: "user",
82-
content: [
83-
{
84-
type: "text",
85-
text: "What's in this image? Analyze the logo and suggest improvements.",
86-
},
87-
{
88-
type: "image_url",
89-
image_url: {
90-
url: "https://example.com/logo.png",
91-
detail: "auto",
92-
},
93-
},
94-
],
95-
},
96-
];
97-
98-
const schema = {
99-
analysis: z.object({
100-
description: z.string(),
101-
colors: z.array(z.string()),
102-
text_content: z.string().optional(),
103-
improvements: z.string().optional(),
104-
}),
105-
};
103+
userMessage(
104+
"What's in this image?"
105+
),
106+
userMessage([
107+
{
108+
type: "image",
109+
image: "https://example.com/logo.png",
110+
},
111+
]),
112+
],
113+
114+
const schema = z.object({
115+
description: z.string(),
116+
colors: z.array(z.string()),
117+
text_content: z.string().optional(),
118+
improvements: z.string().optional(),
119+
});
106120

107-
const result = await llm.generate(messages, schema, {});
121+
const result = await llm.generate({
122+
messages,
123+
schema,
124+
temperature: 0.8,
125+
});
108126
```
109127

110128
The LLM will analyze the image and return a structured response containing the description, colors used, and potential improvements. You can also use base64-encoded images by providing the data URL:
111129

112130
```typescript
113131
const messages = [
114-
{
115-
role: "user",
116-
content: [
117-
{
118-
type: "text",
119-
text: "What's in this image and what color is it?",
120-
},
121-
{
122-
type: "image_url",
123-
image_url: {
124-
url: "data:image/png;base64,..." // Your base64 image data
125-
detail: "auto",
126-
},
127-
},
128-
],
129-
},
132+
userMessage("What's in this image?"),
133+
userMessage([
134+
{
135+
type: "image",
136+
image: "data:image/png;base64,...",
137+
},
138+
]),
130139
];
131140
```
132-
133-
Note: Image analysis is currently supported by OpenAI models. Some providers like Gemini may have limited or no support for image analysis.

docs/concepts/tools.mdx

+12-9
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,26 @@ Tools are functions that can be used to extend the capabilities of your agents.
1010

1111
2. **Structured Output**: Tools are functions that can be used to generate structured output. This is useful for generating JSON, CSV, or other structured data.
1212

13-
Tools are optional and can be added to an Agent to extend its capabilities. Tools are included in the calls to the language model through features like OpenAI's [function calling](https://platform.openai.com/docs/guides/function-calling) or Claude's [tool use](https://docs.anthropic.com/en/docs/build-with-claude/tool-use).
13+
Tools are optional and can be added to an Agent to extend its capabilities. Tools are included in the calls to the language model through the [tools](https://sdk.vercel.ai/docs/ai-sdk-core/tools-and-tool-calling) property.
1414

1515
## Creating a Tool
1616

17-
Tools are created using the `createTool` function and can be sent to the agent using the `tools` property during initialization.
17+
Tools are created using the `Tool` class and can be sent to the agent using the `tools` property during initialization.
1818

1919
```typescript
20-
const tool = createTool({
21-
id: "get-company-report",
22-
description: "This tool is used to get the current state of the company",
23-
schema: z.object({}),
24-
execute: async (params) => {
25-
return "The current state of the company is good";
20+
const tool = new Tool({
21+
provider: "openai",
22+
name: "get weather",
23+
description: "This tool is used to get the current weather in a location",
24+
parameters: z.object({
25+
location: z.string(),
26+
}),
27+
execute: async ({ location }) => {
28+
return "The current weather in " + location + " is sunny";
2629
},
2730
});
2831
```
2932

30-
## Available Tools
33+
## Default Tools
3134

3235
- [GoldRush Onchain Data](/tools/goldrush-onchain-data) - Tools for interacting with blockchain data

0 commit comments

Comments
 (0)