1.0.20 • Published 8 months ago

@edvisory/okmd-ai-widget v1.0.20

Weekly downloads
-
License
-
Repository
-
Last release
8 months ago

OKMD AI Widget

A React widget component that provides AI chat functionality with OKMD's AI service.

Features

  • AI Chat interface with floating button and expandable chat box
  • Real-time message streaming
  • Message history and conversation starters
  • File attachments support
  • Citations and references
  • Character limit warnings
  • Usage quota management
  • Like/Dislike feedback system
  • Responsive design

Installation

Requirements

This package has the following peer dependencies:

  • React ^18.3.1
  • React DOM ^18.3.1
  • @tanstack/react-query ^5.59.16
  • @hookform/resolvers ^3.10.0
  • antd ^5.21.6
  • axios ^1.7.7

Environment Configuration

Configure the environment variables in src/constants/env.ts:

VariableDescriptionRequired
NEXT_PUBLIC_APP_URLBase URL of your applicationYes
NEXT_PUBLIC_API_ENDPOINTAPI endpoint for OKMD AI serviceYes

Example configuration:

These environment variables are used for:

  • Authentication endpoints
  • API communication
  • Login redirects

Usage

  1. Import the widget:
  2. Add the widget to your React application:

Props

PropTypeRequiredDescription
apiKeystringYesAPI key for authentication with OKMD AI service
onLogin() => voidNoCallback function when login is required
onChatChange(chats: ChatSessionChatMessageType[]) => voidNoCallback function when chat messages change
onClose() => voidNoCallback function when chat box is closed
onOpen() => voidNoCallback function when chat box is opened

Example usage in react project

import React from "react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; // required for react-query
import { OkmdAiWidget } from "okmd-ai-widget"; // import widget
import "@edvisory/okmd-ai-widget/dist/esm/index.css"; // import styles

const queryClient = new QueryClient({
  defaultOptions: {
    // your default options
  },
});

const App = () => {
  return (
    <QueryClientProvider client={queryClient}>
      <OkmdAiWidget apiKey="your-api-key" />
    </QueryClientProvider>
  );
};

Example usage in nextjs project

import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; // required for react-query
import "@edvisory/okmd-ai-widget/dist/esm/index.css"; // import styles

const OkmdAiWidget = dynamic(
  () => import("@edvisory/okmd-ai-widget").then((mod) => mod.OkmdAiWidget),
  { ssr: false }
);

const queryClient = new QueryClient({
  defaultOptions: {
    // your default options
  },
});

const App = () => {
  return (
    <QueryClientProvider client={queryClient}>
      <OkmdAiWidget apiKey="your-api-key" />
    </QueryClientProvider>
  );
};

Features

Chat Interface

  • Floating button with "Ask OKMD AI" text
  • Expandable chat box
  • Real-time message streaming
  • Support for markdown formatting in responses

Conversation Management

  • Pre-defined conversation starters
  • Support for regenerating responses
  • Feedback system (like/dislike)

User Experience

  • Character limit warnings
  • Usage quota management
  • Loading states
  • Error handling
  • Responsive design for mobile and desktop

Publish to NPM

  1. Patch version
npm version patch
  1. Publish to NPM
npm publish

or

npm publish --access public

License

This project is proprietary software owned by Edvisory.

Support

For support, please contact the development team at Edvisory.

1.0.20

8 months ago

1.0.19

8 months ago

1.0.18-1

8 months ago

1.0.18

8 months ago

1.0.17-21

8 months ago

1.0.17-20

8 months ago

1.0.17-19

8 months ago

1.0.17-18

8 months ago

1.0.17-17

8 months ago

1.0.17-16

8 months ago

1.0.17-15

8 months ago

1.0.17-14

8 months ago

1.0.17-13

8 months ago

1.0.17-12

8 months ago

1.0.17-11

8 months ago

1.0.17-10

8 months ago

1.0.17-9

8 months ago

1.0.17-8

8 months ago

1.0.17-7

8 months ago

1.0.17-6

8 months ago

1.0.17-5

8 months ago

1.0.17-4

8 months ago

1.0.17-3

8 months ago

1.0.17-2

8 months ago

1.0.17-1

8 months ago

1.0.16-12

8 months ago

1.0.17

8 months ago

1.0.16-11

8 months ago

1.0.16-10

8 months ago

1.0.16-9

8 months ago

1.0.16-8

8 months ago

1.0.16-6

8 months ago

1.0.16-5

8 months ago

1.0.16-4

8 months ago

1.0.16-3

8 months ago

1.0.16-2

8 months ago

1.0.16-1

8 months ago

1.0.13

8 months ago

1.0.16

8 months ago

1.0.15

8 months ago

1.0.14

8 months ago

1.0.12

9 months ago

1.0.11

9 months ago

1.0.10

9 months ago

1.0.9

9 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago