tangshuang / chatglm Goto Github PK
View Code? Open in Web Editor NEWChatGLM 官方接口的 NodeJS SDK 非官方实现
ChatGLM 官方接口的 NodeJS SDK 非官方实现
你好,最近在对接智谱的AI接口,尝试调用官方API,想学习借鉴你的写法,在本地跑起来出现这个问题,请问是否可以帮忙定位下。
npm i chatglm
import { ChatGLM } from 'chatglm';
// 加载apikey
api_key = process.env.ZHIPUAI_API_KEY;
const chat = new ChatGLM(this.api_key);
// 发起请求
const { data } = await chat.completions.careate({
model: 'chatglm-4',
stream: true,
messages: [
{ role: 'system', content: '你是一个聪明且富有创造力的小说作家' },
{
role: 'user',
content:
'请你作为童话故事大王,写一篇短篇童话故事,故事的主题是要永远保持一颗善良的心,要能够激发儿童的学习兴趣和想象力,同时也能够帮助儿童更好地理解和接受故事中所蕴含的道理和价值观。',
},
],
});
const stream = ChatGLM.adapt(data); // 通过adapt方法让数据抛出的更好用
stream.on('data', (chunk) => {
console.log(chunk);
});
const { data } = await chat.completions.careate({
^
TypeError: chat.completions.careate is not a function
at ZhipuService.callChatGLM (...\zhipu.service.ts:16:45)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.