@vrabbi/plugin-chatgpt-backend
TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

ChatGPT Plugin Backend

Plugin that exposes an API to interact with OpenAI and serve the frontend chatgpt plugin

Installation

Navigate to root of Backstage installation and run

# From root directory of your Backstage installation
yarn add --cwd packages/backend @enfuse/plugin-chatgpt-backend

Configuration

  1. This plugin requires an OpenAI API Key. This should be provided in the backstage configuration as shown below:
//app-config.yml or app-config-local.yml

openai:
  apiKey: <openai-api-key>
  

This can be generated here: ChatGPT API keys.

  1. Create a chatgpt.ts file inside your packages/backend/src/plugins directory and include the following:
import { createRouter } from '@enfuse/plugin-chatgpt-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';

export default async function createPlugin(
  env: PluginEnvironment,
): Promise<Router> {
  return await createRouter({
    logger: env.logger,
    config: env.config
  });
}
  1. Inside your packages/backend/src/index.ts file, find the section where backend environments and routes are set up and include the following:
import chatGPTBackend from './plugins/chatgpt';

...
  const chatgptEnv = useHotMemoize(module, () => createEnv('chatgpt-backend'));

  apiRouter.use('/chatgpt', await chatGPTBackend(chatgptEnv));
  1. Test your backend plugin installation by having backstage running and curling the endpoint
curl localhost:7007/api/chatgpt/health

Readme

Keywords

none

Package Sidebar

Install

npm i @vrabbi/plugin-chatgpt-backend

Weekly Downloads

0

Version

2.1.0

License

Apache-2.0

Unpacked Size

10.3 kB

Total Files

8

Last publish

Collaborators

  • vrabbi