kg_chat package

Subpackages

Submodules

kg_chat.app module

Dash based app for the KG Chatbot.

kg_chat.app.create_app(kg_chatbot)

Create a Dash app for the KG Chatbot.

kg_chat.cli module

Command line interface for kg-chat.

kg_chat.constants module

Constants for the Knowledge Graph Chatbot.

kg_chat.main module

Main module for the KG Chat application.

class kg_chat.main.KnowledgeGraphChat(db)

Bases: object

Main class for the KG Chatbot application.

chat()

Start an interactive chat session with the KG Chatbot.

execute_query(query)

Execute a Cypher query against the Neo4j database.

get_human_response(query)

Ask a question to the KG Chatbot and get a response.

get_structured_response(query)

Ask a question to the KG Chatbot and get a structured response.

load_database()

Load the Knowledge Graph into the database.

kg_chat.utils module

Utility functions for the KG chatbot.

kg_chat.utils.assign_color_to_prefix(curie)

Assign a color to a prefix.

kg_chat.utils.create_vectorstore(doc_dir_or_file)

Create a vectorstore from the documents in the doc_dir.

Return type:

Chroma

kg_chat.utils.extract_nodes_edges(structured_result)

Extract nodes and edges from the structured result.

kg_chat.utils.generate_random_color()

Generate a random color.

kg_chat.utils.get_anthropic_models()

Get the list of Anthropic models.

kg_chat.utils.get_cypher_agent_prompt_template()

Get the agent prompt for querying a Neo4J database.

kg_chat.utils.get_database_impl(database, data_dir, llm_config, doc_dir_or_file=None)

Get the database implementation based on the selected database.

kg_chat.utils.get_exisiting_vectorstore()

Get the existing vectorstore.

kg_chat.utils.get_lbl_cborg_models()

Get the list of LBNL-hosted models via CBORG.

kg_chat.utils.get_llm_config(llm_provider, llm_model=None)

Get the LLM configuration based on the selected LLM.

kg_chat.utils.get_ollama_models()

Get the list of Ollama models.

kg_chat.utils.get_openai_models()

Get the list of OpenAI models.

kg_chat.utils.get_sql_agent_prompt_template()

Get the agent prompt.

kg_chat.utils.llm_factory(config)

Create an LLM instance based on the configuration.

kg_chat.utils.split_documents(path)

Get the local documents.

kg_chat.utils.structure_query(query)

Structure the query to request structured results.

Return type:

str

kg_chat.utils.visualize_kg(nodes, edges, app=False, output_dir=None)

Visualize the knowledge graph using pyvis.

Module contents

kg-chat package.