Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/itchy-geckos-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@voltagent/zhipu-ai": major
---

Implement ZhipuProvider for LLM integration
3 changes: 3 additions & 0 deletions examples/with-zhipu-ai/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
.DS_Store
59 changes: 59 additions & 0 deletions examples/with-zhipu-ai/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<div align="center">
<a href="https://voltagent.dev/">
<img width="1800" alt="435380213-b6253409-8741-462b-a346-834cd18565a9" src="https://github.com/user-attachments/assets/452a03e7-eeda-4394-9ee7-0ffbcf37245c" />
</a>

<br/>
<br/>

<div align="center">
<a href="https://voltagent.dev">Home Page</a> |
<a href="https://voltagent.dev/docs/">Documentation</a> |
<a href="https://github.com/voltagent/voltagent/tree/main/examples">Examples</a> |
<a href="https://s.voltagent.dev/discord">Discord</a> |
<a href="https://voltagent.dev/blog/">Blog</a>
</div>
</div>

<br/>

<div align="center">
<strong>VoltAgent is an open source TypeScript framework for building and orchestrating AI agents.</strong><br>
Escape the limitations of no-code builders and the complexity of starting from scratch.
<br />
<br />
</div>

<div align="center">

[![npm version](https://img.shields.io/npm/v/@voltagent/core.svg)](https://www.npmjs.com/package/@voltagent/core)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](CODE_OF_CONDUCT.md)
[![Discord](https://img.shields.io/discord/1361559153780195478.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://s.voltagent.dev/discord)
[![Twitter Follow](https://img.shields.io/twitter/follow/voltagent_dev?style=social)](https://twitter.com/voltagent_dev)

</div>

<br/>

<div align="center">
<a href="https://voltagent.dev/">
<img width="896" alt="Screenshot 2025-04-20 at 22 44 38" src="https://github.com/user-attachments/assets/f0627868-6153-4f63-ba7f-bdfcc5dd603d" />
</a>

</div>

## VoltAgent: Build AI Agents Fast and Flexibly

VoltAgent is an open-source TypeScript framework for creating and managing AI agents. It provides modular components to build, customize, and scale agents with ease. From connecting to APIs and memory management to supporting multiple LLMs, VoltAgent simplifies the process of creating sophisticated AI systems. It enables fast development, maintains clean code, and offers flexibility to switch between models and tools without vendor lock-in.

## Try Example

```bash
npm create voltagent-app@latest -- --example with-zhipu-ai
```

### Important Notes

1. Ensure you have a valid Zhipu AI API key
2. The weather tool in this example is for demonstration purposes only; replace it with a real weather API for production use
3. You can adjust model parameters and tool configurations as needed
31 changes: 31 additions & 0 deletions examples/with-zhipu-ai/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "voltagent-example-vercel-ai",
"private": true,
"keywords": [
"voltagent",
"ai",
"agent"
],
"license": "MIT",
"author": "",
"type": "module",
"scripts": {
"build": "tsc",
"dev": "tsx watch --env-file=.env ./src ",
"start": "node dist/index.js",
"volt": "volt"
},
"dependencies": {
"@ai-sdk/openai": "^1.3.10",
"@voltagent/cli": "^0.1.5",
"@voltagent/core": "^0.1.15",
"@voltagent/vercel-ai": "^0.1.7",
"@voltagent/zhipu-ai": "workspace:^",
"zod": "^3.24.2"
},
"devDependencies": {
"@types/node": "^22.13.5",
"tsx": "^4.19.3",
"typescript": "^5.8.2"
}
}
47 changes: 47 additions & 0 deletions examples/with-zhipu-ai/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { VoltAgent, Agent, createTool } from "@voltagent/core";
import { ZhipuProvider } from "@voltagent/zhipu-ai";
import { z } from "zod";


const zhipuProvider = new ZhipuProvider({
apiKey: process.env.ZHIPU_API_KEY ?? (() => {
throw new Error("ZHIPU_API_KEY environment variable is not set.");
})(),
});

// Weather tool
const weatherTool = createTool({
name: "get_weather",
description: "Get the current weather for a location",
parameters: z.object({
location: z.string().describe('location'),
time: z.string().optional().describe('time')
}),
execute: async (args) => {
const { location, time } = args;
return {
time,
location,
temperature: 22,
conditions: "sunny",
};
},
});

const agent = new Agent({
name: "Asistant",
description: "A helpful assistant that answers questions without using tools",
llm: zhipuProvider,
model: {
id: "glm-4-air",
provider: "zhipu",
modelId: "glm-4-air",
} as any,
tools: [weatherTool],
});

new VoltAgent({
agents: {
agent,
},
});
14 changes: 14 additions & 0 deletions examples/with-zhipu-ai/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"outDir": "dist",
"skipLibCheck": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
71 changes: 71 additions & 0 deletions packages/zhipu-ai/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# @voltagent/zhipu-ai

VoltAgent Zhipu AI provider integration using the Zhipu AI

This package allows you to use Zhipu AI's fast inferencing models within your VoltAgent agents.

## Installation

```bash
npm install @voltagent/zhipu-ai
# or
yarn add @voltagent/zhipu-ai
# or
pnpm add @voltagent/zhipu-ai
```

## Usage

You need to provide your Zhipu AI API key. You can get one from [Zhipu AI](https://www.zhipuai.cn/) after signing up.

```typescript
import { VoltAgent, Agent } from "@voltagent/core";
import { ZhipuProvider } from "@voltagent/zhipu-ai";

const zhipuProvider = new ZhipuProvider({
apiKey: process.env.ZHIPU_API_KEY ?? (() => {
throw new Error("ZHIPU_API_KEY environment variable is not set.");
})(),
});

// Weather tool
const weatherTool = createTool({
name: "get_weather",
description: "Get the current weather for a location",
parameters: z.object({
location: z.string().describe('location'),
time: z.string().optional().describe('time')
}),
execute: async (args) => {
const { location, time } = args;
return {
location,
time,
temperature: 22,
conditions: "sunny",
};
},
});

const agent = new Agent({
name: "Asistant",
description: "A helpful assistant that answers questions without using tools",
llm: zhipuProvider,
model: {
id: "glm-4-air",
provider: "zhipu",
modelId: "glm-4-air",
} as any,
tools: [weatherTool],
});

new VoltAgent({
agents: {
agent,
},
});
```

## License

Licensed under the MIT License, Copyright © 2025-present VoltAgent.
11 changes: 11 additions & 0 deletions packages/zhipu-ai/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testMatch: ["**/__tests__/**/*.test.ts", "**/*.spec.ts"],
transform: {
"^.+\\.ts$": "ts-jest",
},
coverageDirectory: "coverage",
collectCoverageFrom: ["src/**/*.ts", "!src/**/*.d.ts", "!src/**/index.ts"],
};
34 changes: 34 additions & 0 deletions packages/zhipu-ai/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@voltagent/zhipu-ai",
"version": "0.0.1",
"description": "VoltAgent Zhipu AI - Zhipu AI provider integration for VoltAgent",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": ["dist", "src", "dist/*.map"],
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
"lint": "eslint src --ext .ts,.tsx",
"test": "jest --passWithNoTests"
},
"dependencies": {
"@ai-sdk/openai": "^1.3.10",
"@voltagent/core": "^0.1.14",
"ai": "^4.2.11",
"zod": "^3.24.2"
},
"devDependencies": {
"@types/jest": "^29.5.0",
"@types/node": "^18.15.11",
"eslint": "^8.0.0",
"jest": "^29.5.0",
"ts-jest": "^29.1.0",
"tsup": "^6.7.0",
"typescript": "^5.0.4"
},
"peerDependencies": {
"@voltagent/core": "^0.1.0"
}
}
Loading
Loading