npx @nestjs/cli new ai-api-agent 然后,切换到ai-api-agent目录: cd ai-api-agent 最后,安装所需的 npm 包: npm install 2. 安装必要的依赖 我们需要 OpenAI 的 SDK 和 Axios 来发起 API 请求 npm install openai axios dotenv 3 设置 OpenAI API 密钥 将
import OpenAI from 'openai'; const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY }); // 下面是一个异步函数,用于生成文本的嵌入 async function generateEmbedding(text: string) { const response = await openai.embeddings.create({ input: text, model: 'text-embedding-ada-002', });...
import{OpenAIModule,Models}from"@webeleon/nestjs-openai";@Module({imports:[OpenAIModule.forRoot({apiKey:'YOUR_OPEN_AI_API_KEY',model:Models.GPT4})],})classAppModule{} Useful links API DOCjulien@webeleon Releases15 v0.5.2Latest Aug 27, 2023 ...
Node.js fs API _dirname & _filename & path All In One2020-11-1656.Node.js Backend Developer2020-10-2557.Node.js require 模块加载原理 All In One2020-10-0558.node.js module.exports & exports & module.export all in one2020-10-0559.Nest.js tutorials All In One2020-09-1360.PM2 & nod...
OpenAI API key Open or create your NestJS application where you would like to integrate the AI Assistant. To create a new NestJS application, use the following command: nest new project-name Now you have to install the packages. Go to the next step. Step 1: Installation Make sure you ar...
OpenAI的api proxy,支持ChatGPT的API调用,支持openai的API接口,支持:gpt-4,gpt-3.5。不需要openai Key, 不需要买openai的账号,不需要美元的银行卡,通通不用的,直接调用就行,稳定好用!!智增增 EasyInstruct - [ACL 2024] An Easy-to-use Instruction Processing Framework for LLMs. FinRobot - FinRobot: An...
ChatGPTAPI- (Used to use)text-davinci-003to mimic ChatGPT via the official OpenAI completions API (most robust approach, but it's not free and doesn't use a model fine-tuned for chat) ChatGPTUnofficialProxyAPI- Uses an unofficial proxy server to access ChatGPT's backend API in a way...
OPENAI_PROXY_URL No If you manually configure the OpenAI interface proxy, you can use this configuration item to override the default OpenAI API request base URL https://api.chatanywhere.cn or https://aihubmix.com/v1 The default value ishttps://api.openai.com/v1 ACCESS_CODE No Add a ...
OPENAI_PROXY_URL No If you manually configure the OpenAI interface proxy, you can use this configuration item to override the default OpenAI API request base URL https://api.chatanywhere.cn or https://aihubmix.com/v1 The default value ishttps://api.openai.com/v1 ACCESS_CODE No Add a ...