Skip to content

Reference

A chat block and other AI/LLM functionality for datalab.

Attributes:

Name Type Description
__version__

__version__

__version__ = version('whinchat')

ChatBlock

Bases: DataBlock

This block uses API calls to external LLMs via Langchain to provide a conversational interface to a user's data.

Implemented models include:

  • the GPT series of models from OpenAI
  • Claude from Anthropic

Each needs the server to be configured with the corresponding API keys:

  • OPENAI_API_KEY,
  • ANTHROPIC_API_KEY.

A discussion of this block can be found in:

Jablonka et al, Digital Discovery, 2023,2, 1233-1250, DOI: 10.1039/d3dd00113j

Attributes:

Name Type Description
accepted_file_extensions
block_db_model
blocktype
defaults dict
description
name
plot_functions

accepted_file_extensions

accepted_file_extensions = None

block_db_model

block_db_model = ChatBlockResponse

blocktype

blocktype = 'chat'

defaults

defaults: dict = {'system_prompt': 'You are whinchat (lowercase w), a virtual data managment assistant that helps materials chemists manage their experimental data and plan experiments. You are deployed in the group of Professor Clare Grey in the Department of Chemistry at the University of Cambridge.\nYou are embedded within the program datalab, where you have access to JSON describing an ‘item’, or a collection of items, with connections to other items. These items may include experimental samples, starting materials, and devices (e.g. battery cells made out of experimental samples and starting materials).\nAnswer questions in markdown. Specify the language for all markdown code blocks. You can make diagrams by writing a mermaid code block or an svg code block. When writing mermaid code, you must use quotations around each of the labels (e.g. A["label1"] --> B["label2"])\nBe as concise as possible. When saying your name, type a bird emoji right after whinchat 🐦.\n        ', 'temperature': 0.2, 'model': 'gpt-6-luna', 'available_models': AVAILABLE_MODELS}

description

description = 'Virtual LLM assistant block allows you to converse with your data.'

name

name = 'Whinchat assistant'

plot_functions

plot_functions

continue_conversation

continue_conversation(prompt: str | None) -> None

Continues the conversation based on the passed user prompt.

Parameters:

Name Type Description Default
prompt str | None

The textual response from the user.

required

render

render()

start_conversation

start_conversation(item_data: dict | None = None, collection_data: dict | None = None)

Starts a new conversation with the system prompt, embedding the current item or collection data.