@vrabbi/plugin-chatgpt-backend
v2.1.0
Published
Plugin that exposes an API to interact with OpenAI and serve the [frontend](https://github.com/enfuse/backstage-chatgpt-plugin) chatgpt plugin
Downloads
3
Readme
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
- 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.
- Create a
chatgpt.ts
file inside yourpackages/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
});
}
- 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));
- Test your backend plugin installation by having backstage running and curling the endpoint
curl localhost:7007/api/chatgpt/health