enfuse / backstage-chatgpt-backend

ChatGPT backend plugin for Backstage. Handles the interaction with OpenAI and exposes an API for the front end plugin
11 stars 4 forks source link

Bug with plugin setup #5

Closed jsidney closed 1 year ago

jsidney commented 1 year ago

I have just installed the latest version of the plugin and created the chatgpt.ts file under plugins. However, my linter is returning the following error:

Argument of type '{ logger: winston.Logger; }' is not assignable to parameter of type 'RouterOptions'. Property 'config' is missing in type '{ logger: winston.Logger; }' but required in type 'RouterOptions'.ts(2345) index.d.ts(7, 5): 'config' is declared here.

this is what the code looks like:


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,
  });
}

any thoughts?

ch-enfuse commented 1 year ago

Hi @jsidney, you need to also reference the configuration from the environment and pass it to the createRouter function like this,

export default async function createPlugin(
  env: PluginEnvironment,
): Promise<Router> {
  return await createRouter({
    logger: env.logger,
    config: env.config
  });
}

We updated the installation instructions for this, thank you for bringing this up!

jsidney commented 1 year ago

thanks @ch-enfuse ! worked like a charm!