Skip to main content

kg-chat

Project description

kg-chat

LLM-based chatbot that queries and visualizes KGX nodes and edges TSV files loaded into either DuckDB (default) or neo4j database backend.

Certainly! Here's a more concise version:

LLMs Supported

  • OpenAI

    NOTE: Ensure OPENAI_API_KEY is set as an environment variable.

  • Anthropic

    NOTE: Ensure ANTHROPIC_API_KEY is set as an environment variable.

  • Ollama

    NOTE: Currently throws error: Invalid Format: Missing 'Action:' after 'Thought' as of now. Work in progress...

    • No API key required.
    • Download the application from here.
    • Get the model by running:
          ollama pull llama3.1 
      
  • Models hosted by Lawrence Berkeley National Laboratory vi CBORG

    NOTE: Ensure CBORG_API_KEY is set as an environment variable.

    • The list of modes can be found (here)[https://cborg.lbl.gov/models/] listed under "LBNL_Hosted Models".
    • The only LLMs that work for now:
      • lbl/llama-3 (actually llama3.1(405B))
      • openai/gpt-4o-mini
      • anthropic/claude-haiku
      • anthropic/claude-sonnet
      • anthropic/claude-opus

How to set the API key as an environment variable?

One quick way is

    export OPENAI_API_KEY=XXXXXX
    export ANTHROPIC_API_KEY=XXXXX

But if you want these to persist permanently

    vi ~/.bash_profile

OR

    vi ~/.bashrc

Add the 2 lines exporting the variables above and then

    source ~/.bash_profile

OR

    source ~/.bashrc

Setup

For Neo4j Backend (Optional)

  1. Install Neo4j desktop from here.
  2. Create a new project and database, then start it.
  3. Install the APOC plugin in Neo4j Desktop.
  4. Update settings to match neo4j_db_settings.conf.

General Setup

For Developers

  1. Clone this repository.
  2. Create a virtual environment and install dependencies:
    cd kg-chat
    pip install poetry
    poetry install
    
  3. Replace data/nodes.tsv and data/edges.tsv with desired KGX files if needed.

For using kg-chat as a dependency

pip install kg-chat

OR

poetry add kg-chat@latest

Supported Backends

  • DuckDB [default]
  • Neo4j

Commands

  1. Import KG: Load nodes and edges into a database (default: duckdb).

    poetry run kg import --data-dir data
    
  2. Test Query: Run a test query.

    NOTE: --data-dir is a required parameter for all commands. This is the path for the directory which contains the nodes.tsv and edges.tsv file. The filenames are expected to be exactly that.

    poetry run kg test-query --data-dir data
    
  3. QnA: Ask questions about the data.

    poetry run kg qna "how many nodes do we have here?" --data-dir data
    
  4. Chat: Start an interactive chat session.

    poetry run kg chat --data-dir data
    
  5. App: Deploy a local web application.

    poetry run kg app --data-dir data
    

Visualization

Use show me in prompts for KG visualization.


Acknowledgements

This cookiecutter project was developed from the monarch-project-template template and will be kept up-to-date using cruft.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kg_chat-0.0.0.tar.gz (422.6 kB view details)

Uploaded Source

Built Distribution

kg_chat-0.0.0-py3-none-any.whl (424.6 kB view details)

Uploaded Python 3

File details

Details for the file kg_chat-0.0.0.tar.gz.

File metadata

  • Download URL: kg_chat-0.0.0.tar.gz
  • Upload date:
  • Size: 422.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for kg_chat-0.0.0.tar.gz
Algorithm Hash digest
SHA256 3e4343cef805dc8263fb1d0555a406030ee0ed87e87ce103547b0826c9b4d570
MD5 4826df7d3d0bc67d7e8889feb8ccca78
BLAKE2b-256 1030556fc9956eb8f21bfd92ac87de0ecc9823761685cc0b67f97c518f507237

See more details on using hashes here.

File details

Details for the file kg_chat-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: kg_chat-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 424.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for kg_chat-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9c2821c3d6c4bd2268557cdea9c6838bc305348d74c910bc66a097e0a39d028
MD5 38c16226e5b1a38f0f6e51ff2cb56733
BLAKE2b-256 a592f1957bb5a2590b66b7e2873db7421778179b1bdc30b098b05c015bfec11d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page