wyona / katie-backend

Katie Backend
https://katie.qa
Apache License 2.0
26 stars 1 forks source link

(Backend)

About

Katie is an Open Source AI-based question-answering platform that helps companies and organizations make their private domain knowledge accessible and useful to their employees and customers.

Katie is integrated with Discord, Slack, MS Teams, Matrix, E-Mail, Wordpress and TOPdesk, and also provides a web interface for expert users.

Katie can be connected with all your applications and data repositories, like for example Websites, Confluence, SharePoint, OneNote, Outlook, Supabase, Directus, Discourse, etc.

Katie is based on state of the art AI and supports embedding and large language models of your choice.

By default, Katie uses Apache Lucene for full text and vector search, but it also integrates with Weaviate, Elasticsearch, Azure AI Search, etc.

Quickstart

To pull the most recent Katie image from Docker Hub (with prefix /katie or for Mac M1 or higher) and run Katie locally, please follow the steps below

Requirements

The Katie backend webapp is based on Spring Boot and to build and run locally you need

Build and Run from Command Line

Optionally you can run Katie with an outgoing proxy configuration enabled (https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html)

IntelliJ (Ultimate)

Make sure you have Lombok configured

https://www.baeldung.com/lombok-ide

In case startup fails, then delete the .idea directory and the file askkatie-webapp.iml, and reopen the project.

Eclipse (Version: 2022-06 (4.24.0))

Run Katie within Tomcat

Generate Katie Docker image and run Katie Docker container

Or as another alternative run:

sh pull-down-up.sh

whereas make sure to configure VOLUME_KATIE inside the script accordingly.

Docker using Tomcat

API and Testing API

Database / Flyway

Create / migrate Database on startup of Katie web app

When running Katie as Docker

Documentation

Backup and restore h2 database:

Access database from command line (WARN: Might not work properly when database is already in use by server, either stop server or make a copy and connect with copy)

When you encounter an error like "Migration checksum mismatch for migration version 28.3", then the reason is that the migration script src/main/resources/db/migration/V28_3__alter_question_table.sql has been modified, for example because the script comment at the top got updated. If this modification is not relevant, then you can fix the database by replacing the previous checksum (Applied to database) by the new checksum (Resolved locally)

and the startup should work again.

Update Angular Frontend

Enable Google Analytics

Create Release

Update the version in the following files:

Elasticsearch 6.6.1

Basic configuration: src/main/resources/application.properties

Implementation: src/main/java/com/wyona/katie/handlers/ElasticsearchQuestionAnswerImpl.java

List all indices https://elasticsearch-vt.wyona.com/_cat/indices Get all hits of a particular index: E.g. https://elasticsearch-vt.wyona.com/askkatie_1b3805a8-84db-452d-ae00-b13755686d30/_search

Slack App

You can add the official Katie Slack App to your Slack workspace by clicking on the button "Add to Slack" on the page https://app.katie.qa/slack.html

The official Katie Slack App is configured at https://api.slack.com/apps/A0184KMLJJE (Workspace https://wyonaworkspace.slack.com)

If you want to create and use your own custom Slack App in order to connect with the Katie backend, then follow the instructions below:

Update configuration parameters inside volume/config/slack-apps.json

Config values of your App

Update Slack App configuration

Slack Katie App Manifest (https://app.slack.com/app-settings/T01848J69AP/A0184KMLJJE/app-manifest):

_metadata:
  major_version: 1
  minor_version: 1
display_information:
  name: Katie
  description: Katie is a question answering bot, continuously improving, self-learning and trained by humans.
  background_color: "#000000"
  long_description: Katie answers questions using artificial and natural intelligence, whereas Katie is currently not intended for conversations beyond asking one question at a time. Natural conversations are much more complex than just detecting duplicated/similar questions. Simple dialogs with clear intents, such as for example a restaurant reservation or initiate a phone call, work quite well already, but more complex conversations are much more difficult and users become frustrated and will eventually stop trying to have more complex conversations.
features:
  app_home:
    home_tab_enabled: true
    messages_tab_enabled: false
    messages_tab_read_only_enabled: false
  bot_user:
    display_name: katie
    always_online: false
  slash_commands:
    - command: /katie
      url: https://app.katie.qa/api/v1/slack/command/katie
      description: Get help on how to use Katie
      should_escape: false
oauth_config:
  redirect_urls:
    - https://app.katie.qa/api/v1/slack/oauth2-callback/SLACK_CLIENT_ID
  scopes:
    user:
      - im:history
    bot:
      - channels:history
      - chat:write
      - commands
      - im:history
      - incoming-webhook
      - team:read
settings:
  event_subscriptions:
    request_url: https://app.katie.qa/api/v1/slack/events
    user_events:
      - message.im
    bot_events:
      - message.channels
      - message.im
  interactivity:
    is_enabled: true
    request_url: https://app.katie.qa/api/v1/slack/interactivity
    message_menu_options_url: https://app.katie.qa/api/v1/slack/options-load
  org_deploy_enabled: false
  socket_mode_enabled: false
  token_rotation_enabled: false

MS Teams App

Also see https://app.katie.qa/ms-teams.html

Open Developer Portal https://dev.teams.microsoft.com/apps