open-index/open-npm huggingface dataset:
npm package: @kozmoai/rag-ai
Description: This plugin is the frontend for RAG AI Backstage plugin. You can see the corresponding backend plugin in [here](/plugins/backend/rag-ai-backend/README.md).
Latest version: 0.2.1

# Glint RAG AI Frontend plugin for Backstage

This plugin is the frontend for RAG AI Backstage plugin. You can see the corresponding backend plugin in [here](/plugins/backend/rag-ai-backend/README.md).

![docs/petstore-rag-openapi-example.gif](docs/petstore-rag-openapi-example.gif)

## Getting started

The plugin exposes a single Modal React component which can be triggered on the application UI by pressing `ctrl+,` (control + comma).
![docs/empty-modal.png](docs/empty-modal.png)

You can ask the plugin information about your catalog and request assistance on how to better interact with the catalog entities that have been configured to your system. The plugin provides functionality to call the RAG AI backend, which enhances your queries with additional context and requests responses from configured LLMs to provide answers based on that context.

![docs/simple-q-a.png](docs/simple-q-a.png)

Depending on how you implement your Embeddings providers and retrieval functionality, you can use the LLM, for example, to construct specific code samples from your Catalog Entity API endpoints, while using the wider knowledge of specific best practices from various programming languages and frameworks.

![docs/api-spec-query.png](docs/api-spec-query.png)

## Configuration

To configure the frontend plugin, you need to do two things:

- Create an API client for the frontend plugin
- Add the exposed UI element into the application

### Creating an API client

The RAG AI plugin exposes an API client which needs to be configured for your Backstage application frontend to be able to use the RAG AI functionality. You can do that by adding a new API factory into your `apis.ts` file. See configuration example below:

```ts
// packages/app/src/apis.ts

import {
  AnyApiFactory,
  configApiRef,
  createApiFactory,
  discoveryApiRef,
  fetchApiRef,
  identityApiRef,
} from '@backstage/core-plugin-api';
import fetch from 'cross-fetch';
import { ragAiApiRef, GlintRagAiClient } from '@kozmoai/rag-ai';

export const apis: AnyApiFactory[] = [
  // ... Other APIs
  createApiFactory({
    api: ragAiApiRef,
    deps: {
      configApi: configApiRef,
      discoveryApi: discoveryApiRef,
      fetchApi: fetchApiRef,
      identityApi: identityApiRef,
    },
    factory: ({ discoveryApi, fetchApi, configApi, identityApi }) => {
      return new GlintRagAiClient({
        discoveryApi,
        fetchApi,
        configApi,
        identityApi,
      });
    },
  }),
];
```

### Adding the UI components into the application

The plugin exposes a single UI component which is used to communicate with the application Backend. You can register this

App.tsx

```tsx

// packages/app/src/App.tsx
import { RagModal } from '@kozmoai/rag-ai';

...
const App = () => (
  <AppProvider>
    <AlertDisplay />
    <OAuthRequestDialog />
    <AppRouter>
      <RagModal />
      <Root>{routes}</Root>
    </AppRouter>
  </AppProvider>
);
```
npm package: @kozmoai/rag-ai-backend-embeddings-aws
Description: The AWS (Bedrock) backend module for the @kozmoai/rag-ai plugin.
Latest version: 0.2.1

# RAG AI Backend-embeddings AWS Bedrock submodule

This is a submodule for the `@kozmoai/rag-ai-backend` module, which provides functionality to use AWS Bedrock embeddings to generate a RAG AI Backend plugin for Backstage. It integrates `@backstage/integration-aws-node` package for fetching AWS account credentials.

## Initialization

```typescript
const vectorStore = await createGlintPgVectorStore({ logger, database });
const awsCredentialsManager = DefaultAwsCredentialsManager.fromConfig(config);
const credProvider = await awsCredentialsManager.getCredentialProvider();

const augmentationIndexer = await initializeBedrockEmbeddings({
  logger,
  catalogApi,
  vectorStore,
  discovery,
  config,
  options: {
    credentials: credProvider.sdkCredentialProvider,
    region: 'eu-central-1',
  },
});
```

## Configuration Options

The module expects 2 pieces of configuration:

1. The configuration of the module to configure AWS Bedrock
2. AWS integration configuration for credentials provisioning

### AWS Bedrock configuration

The module expects the name of the embeddings generative AI model to be configured via app-config.

```yaml
ai:
  embeddings:
    awsBedrock:
      # Name of the Bedrock model to use to create Embeddings
      modelName: 'amazon.titan-embed-text-v1'
```

### AWS Credentials Configuration

The module depends on the `@backstage/integration-aws-node` package which helps fetch AWS account credentials for AWS SDK clients in backend packages and plugins. Users configure AWS account information and the credentials in their Backstage app configurations. This could include IAM user credentials, IAM roles, and profile names for their AWS accounts.

A full description of how to use and configure `@backstage/integration-aws-node` package can be found from the [package README](https://github.com/backstage/backstage/blob/master/packages/integration-aws-node/README.md).

Configuration examples:

```yaml
aws:
  mainAccount:
    accessKeyId: ${MY_ACCESS_KEY_ID}
    secretAccessKey: ${MY_SECRET_ACCESS_KEY}
  accounts:
    - accountId: '111111111111'
      roleName: 'my-iam-role-name'
      externalId: 'my-external-id'
    - accountId: '222222222222'
      partition: 'aws-other'
      roleName: 'my-iam-role-name'
      region: 'not-us-east-1'
      accessKeyId: ${MY_ACCESS_KEY_ID_FOR_ANOTHER_PARTITION}
      secretAccessKey: ${MY_SECRET_ACCESS_KEY_FOR_ANOTHER_PARTITION}
    - accountId: '333333333333'
      accessKeyId: ${MY_OTHER_ACCESS_KEY_ID}
      secretAccessKey: ${MY_OTHER_SECRET_ACCESS_KEY}
    - accountId: '444444444444'
      profile: my-profile-name
    - accountId: '555555555555'
  accountDefaults:
    roleName: 'my-backstage-role'
    externalId: 'my-id'
```
npm package: @kozmoai/rag-ai-backend-embeddings-openai
Description: The OpenAI backend module for the @kozmoai/rag-ai plugin.
Latest version: 0.2.1

# RAG AI Backend-embeddings OpenAI submodule

This is a submodule for the `@kozmoai/rag-ai-backend` module, which provides functionality to use OpenAI embeddings to generate a RAG AI Backend plugin for Backstage. It exposes configuration options to configure OpenAI API token and wanted embeddings model, as well as the parameters for the model.

## Initialization

```typescript
const vectorStore = await createGlintPgVectorStore({ logger, database });

const augmentationIndexer = await initializeOpenAiEmbeddings({
  logger,
  catalogApi,
  vectorStore,
  discovery,
  config,
});
```

>

## Configuration Options

The module expects an API Token, the name of the embeddings generative AI model and its configuration options to be configured via app-config.

You can generate an API Token in here: https://platform.openai.com/api-keys

```yaml
ai:
  embeddings:
    # OpenAI Embeddings configuration
    openai:
      # (Optional) The API key for accessing OpenAI services. Defaults to process.env.OPENAI_API_KEY
      openAIApiKey: 'sk-123...'

      # (Optional) Name of the OpenAI model to use to create Embeddings. Defaults to text-embedding-3-large
      modelName: 'text-embedding-3-large'

      # The size of the batch to use when creating embeddings. Defaults to 512, max is 2048
      batchSize: 512

      # The number of dimensions to generate. Defaults to use the default value from the chosen model
      embeddingsDimensions: 3072
```

<details><summary>Example minimal configuration</summary>

```yaml
ai:
  embeddings:
    openAI: {} # uses env variable OPENAI_API_KEY for API key, model 'text-embedding-3-large' for embeddings creation model
```

</details>
npm package: @kozmoai/rag-ai-backend-retrieval-augmenter
Description: This is a base module providing default functionality related to RAG AI indexing embeddings and retrieval of augmentation context. It enables a pluggable AI model initialization in a submodule and provides default, extendable functionality to create, mana
Latest version: 0.2.1

# rag-ai-backend-retrieval-augmenter

This is a base module providing default functionality related to RAG AI indexing embeddings and retrieval of augmentation context. It enables a pluggable AI model initialization in a submodule and provides default, extendable functionality to create, manage, and search embeddings.

It also contains logic to use the default Backstage search to search for additional context that can be added to the query prompts sent to configured LLMs.

This module should be configured to be used by injecting use-case specific embeddings, retrieval, post processing and routing implementations.

The Glint RAG AI backend expects a retrieval pipeline that is used to retrieve augmentation context when querying information from the LLM. This retrieval pipeline retrieves, processes and sorts information based on queries and other information, providing data that can be used to augment the query sent to the LLM.

This repository provides default retrieval pipeline implementations that can be configured to retrieve as much (or as little ) data as is needed. The pipeline can also be run in a pass-through mode where additional context is not added to the queries and users can interact with the configured LLMs directly.

A bare-bones implementation of the pipeline can be initialized by calling the `DefaultRetrievalPipeline` constructor with an empty configuration object (`{}`).

To start appending important functionality to the RAG pipeline, it is recommended to start implementing and using routers to define correct augmentation information retrievers and to use post processor with enough logic to rerank, sort, and manipulate the retrieved information. The initial starting point, to use a vector store with optional search functionality, is provided by Glint within this repository. You can get a naive RAG pipeline running this way and start tweaking and configuring the optimal embeddings configuration to provide relevant context for your queries.

```typescript
const retrievalPipeline = createDefaultRetrievalPipeline({
  discovery,
  logger,
  vectorStore: augmentationIndexer.vectorStore,
});
```

> You are able to get the vector store implementation from your constructed augmentation indexer. See embeddings submodules or `@kozmoai/rag-ai-backend` README for more information
npm package: @kozmoai/rag-ai-storage-pgvector
Description: A module enabling usage of PostgreSQL as a storage solution for RAG AI Backstage backend plugin.
Latest version: 0.1.1

# GlintPgVectorStore - PostgreSQL RAG AI Vector Storage

A module enabling usage of PostgreSQL as a storage solution for RAG AI Backstage backend plugin.

> Note, you need to have `uuid-ossp` and `vector` PostgreSQL extensions available on your database to be able to use this module.

This module construct a database and needed database tables to support storing embeddings vectors into your PostgreSQL DB. You can control the name of the database with the configured environment name within your Backstage backend application.

## How to initialize

You can use the exported `createGlintPgVectorStore` function to initialize the GlintPGVectorStore. This initialization function expects an instance of logger and a Knex DB connection.

Here is a TypeScript example:

```typescript
const config = {
  logger: Logger, // logger instance
  db: Knex, // database connection provided by Knex
  options: {
    chunkSize: number, // (optional) amount of documents to chunk when adding vectors, default is 500
    tableName: string, // (optional) Table naming to use to store embeddings. Default is 'embeddings'
  },
};

const vectorStore = await createGlintPgVectorStore({
  logger,
  database,
  options: { chunkSize, tableName },
});
```
npm package: @kozmoai/scaffolder-backend-argocd
Description: Welcome to the `argocd` actions for the `scaffolder-backend`.
Latest version: 1.1.25

# scaffolder-backend-argocd

Welcome to the `argocd` actions for the `scaffolder-backend`.

This contains one action: `argocd:create-resources`.

The `argocd:create-resources` action allows the task to call any of the Argo CD instance APIs available to the user that triggers it.

## Getting started

Create your Backstage application using the Backstage CLI as described here:
https://backstage.io/docs/getting-started/create-an-app

> Note: If you are using this plugin in a Backstage monorepo that contains the code for `@backstage/plugin-scaffolder-backend`, you need to modify your internal build processes to transpile files from the `node_modules` folder as well.

> Note: To use this scaffolder action you need to ensure the Argo CD user you are utilizing has the `create` permission for both `projects` and `applications`

You need to configure the action in your backend as well as your software template:

### From your Backstage root directory

```
cd packages/backend
yarn add @kozmoai/scaffolder-backend-argocd
```

Configure the action:
(you can check the [docs](https://backstage.io/docs/features/software-templates/writing-custom-actions#registering-custom-actions) to see all options):

```typescript
// packages/backend/src/plugins/scaffolder.ts

const actions = [
  createArgoCdResources({ config, logger }),
  ...createBuiltinActions({
    containerRunner,
    integrations,
    config,
    catalogClient,
    reader,
  }),
];

return await createRouter({
  containerRunner,
  logger,
  config,
  database,
  catalogClient,
  reader,
  actions,
});
```

### From your software template yaml file

Under `spec.steps[]` insert the below. In the below we reference items in the `spec.paramters[]` section.

```
    - id: create-argocd-resources
      name: Create ArgoCD Resources
      action: argocd:create-resources
      input:
        appName: ${{ parameters.name }}-nonprod
        argoInstance: ${{ parameters.argoinstance }}
        namespace: ${{ parameters.namespace }}
        repoUrl: ${{ steps.publish.output.remoteUrl }}
        labelValue: ${{ parameters.name }}
        path: "kubernetes/nonprod"
```

> If needed there is an optional parameter of `projectName` as well.

## Contributed By American Airlines