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

1.1.1 • 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/chatgpt

Readme

Keywords

none

Package Sidebar

Install

npm i @enfuse/plugin-chatgpt-backend

Weekly Downloads

50

Version

1.1.1

License

Apache-2.0

Unpacked Size

9.91 kB

Total Files

6

Last publish

Collaborators

  • yo-enfuse
  • chr-enfuse
  • ajw-enfuse