kg-chat
LLM-based chatbot that queries and visualizes KGX nodes and edges TSV files loaded into either DuckDB (default) or neo4j database backend.
LLMs Supported
| LLM Provider | Models |
|---|---|
| OpenAI | - gpt-4o-2024-08-06- gpt-4o-mini- gpt-4o-mini-2024-07-18- gpt-4o-2024-05-13- gpt-4o- gpt-4-turbo-2024-04-09- gpt-4-turbo- gpt-4-turbo-preview |
| Anthropic | - claude-3-5-sonnet-20240620- claude-3-opus-20240229- claude-3-sonnet-20240229- claude-3-haiku-20240307 |
| Ollama | - llama3.1 |
| LBNL-hosted models via CBORG | - lbl/llama-3 (actually 3.1 (405b))- openai/gpt-4o-mini- anthropic/claude-haiku- anthropic/claude-sonnet- anthropic/claude-opus |
⚠️
-
OpenAI: Ensure
OPENAI_API_KEYis set as an environment variable. -
Anthropic: Ensure
ANTHROPIC_API_KEYis set as an environment variable. -
Ollama: Better results if the
llama 3.1 405bmodel is used. Needs GPU.- No API key required.
- Download the application from here and install it locally.
- Get any model of your choice but make sure the model has the
Toolsbadge for it to work. Here's an example:ollama run llama3.1:405b
-
Models hosted by Lawrence Berkeley National Laboratory via CBORG: Ensure
CBORG_API_KEYis set as an environment variable.- The list of modes can be found here listed under "LBNL_Hosted Models".
How to set the API key as an environment variable?
One quick way is
export OPENAI_API_KEY=XXXXXX
export ANTHROPIC_API_KEY=XXXXX
export CBORG_API_KEY=XXXX
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)
- Install Neo4j desktop from here.
- Create a new project and database, then start it.
- Install the APOC plugin in Neo4j Desktop.
- Update settings to match
neo4j_db_settings.conf.
General Setup
For Developers
- Clone this repository.
- Create a virtual environment and install dependencies:
cd kg-chat pip install poetry poetry install
- Replace
data/nodes.tsvanddata/edges.tsvwith 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
-
Import KG: Load nodes and edges into a database (default: duckdb).
poetry run kg import --data-dir data
-
Test Query: Run a test query.
⚠️
--data-diris 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
-
QnA: Ask questions about the data.
poetry run kg qna "how many nodes do we have here?" --data-dir data
-
Chat: Start an interactive chat session.
poetry run kg chat --data-dir data
-
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.
Metadata
Release files for kg-chat 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kg_chat-0.1.5.tar.gz | 423.0 kB | Without provenance | Details for kg_chat-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kg_chat-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for kg_chat-0.1.5-py3-none-any.whl |
Total release size: 847.8 kB
Release files / kg_chat-0.1.5.tar.gz
| Download URL | kg_chat-0.1.5.tar.gz |
|---|---|
| Size | 423.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a74b6b698536e676bb5057c6bc517f85cc081095f4cfcd61037c33d65630532c
|
|
BLAKE2b-256 checksum How to use checksums |
493114e6831d15f741351e83c344626927893628d13caa28a7618a8a9d6ca723
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.5
|
Release files / kg_chat-0.1.5-py3-none-any.whl
| Download URL | kg_chat-0.1.5-py3-none-any.whl |
|---|---|
| Size | 424.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
91a81909bdc5966954c08aad94e6d861764d08e5b8385d51d09b43dabd4f94c4
|
|
BLAKE2b-256 checksum How to use checksums |
084ba85226def6bf1801e29683f05cbb097efc3c82903dba04cca7d06b64609a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.5
|
Security for kg-chat 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.