Unverified Commit e376064b authored by jinyuan sun's avatar jinyuan sun Committed by GitHub
Browse files

Merge pull request #45 from ChatMol/v2_release

final update for release of ChatMol v0.2
parents 9268d232 9082e835
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -142,4 +142,7 @@ cf08d4763cf8b0309f2aa182c253388d712a1b736d4eb34f226c74588995faa0*
e9bbca7f41ac6c03b3a6c3193115e8ac8a4c4fd572a4230577a81c432b2cacfe*
e9bbca7f41ac6c03b3a6c3193115e8ac8a4c4fd572a4230577a81c432b2cacfe*
06377e8a560dca176f9a7d7ac9e3184c6c67e13aa1e9a6a3972e2fde8952375b*
06377e8a560dca176f9a7d7ac9e3184c6c67e13aa1e9a6a3972e2fde8952375b*
copilot_public/Project-*
copilot_public/Project-*

chatmol_claude_test.py
chatmol_claude_test.py
model_info.json
ollama.sh
 No newline at end of file
+52 −103
Original line number Original line Diff line number Diff line
# ChatMol
# ChatMol
Started from a PyMol plugin.
Started from a PyMol plugin, towards a comprehensive molecular design assistant.

![GitHub license](https://img.shields.io/github/license/ChatMol/ChatMol)  ![GitHub issues](https://img.shields.io/github/issues/ChatMol/ChatMol) ![GitHub forks](https://img.shields.io/github/forks/ChatMol/ChatMol)  ![GitHub stars](https://img.shields.io/github/stars/ChatMol/ChatMol)  
Our paper "ChatMol Copilot: An Agent for Molecular Modeling and Computation Powered by LLMs" has been accepted for oral presentation at the First Workshop on Language and Molecules (L+M 2024), co-located with ACL 2024. [![Paper](https://img.shields.io/badge/Paper-L%2BM%20Workshop%20ACL%202024-blue)](https://aclanthology.org/2024.langmol-1.7/)

## Overview
<details>
<summary>Table of contents</summary>


## Table of contents
- [ChatMol](#chatmol)
- [ChatMol](#chatmol)
  - [Table of contents](#table-of-contents)
  - [Overview](#overview)
  - [Overview](#overview)
  - [PyMOL Plugin](#pymol-plugin)
  - [ChatMol + Streamlit](#chatmol--streamlit)
  - [ChatMol + Streamlit](#chatmol--streamlit)
  - [ChatMol python package](#chatmol-python-package)
  - [ChatMol python package](#chatmol-python-package)
  - [Copilot](#copilot)
  - [Copilot](#copilot)
  - [ChatMol Website](#chatmol-website)
  - [ChatMol Website](#chatmol-website)
  - [Requirements \& Installation](#requirements--installation)
  - [ChatMol API Key Setup](#chatmol-api-key-setup)
  - [Usage](#usage)
    - [ChatMol as a Task Execution Agent](#chatmol-as-a-task-execution-agent)
    - [ChatMol as a Q\&A Chatbot](#chatmol-as-a-qa-chatbot)
    - [Want to start over again?](#want-to-start-over-again)
    - [ChatMol-Lite](#chatmol-lite)
    - [miniGUI](#minigui)
  - [License](#license)
  - [License](#license)
</details>


## Overview
We aim to leverage the capabilities of large language models to better assist scientists in designing new biomolecules. Our journey began with developing a [PyMOL plugin](#pymol-plugin) that automatically translates natural language into commands. From there, we expanded into several domains, including:
The PyMOL ChatGPT Plugin seamlessly integrates LLMs into PyMOL, enabling users to interact with PyMOL using natural language instructions. This tool simplifies PyMOL tasks and offers suggestions, explanations, and guidance on a wide range of PyMOL-related topics. ChatMol provides various interaction modes with PyMOL, including the PyMOL command line, miniGUI chatbot, python and web browsers.


## ChatMol + Streamlit
- An interactive [Streamlit interface](#chatmol--streamlit)
- A dedicated [Python package](#chatmol-python-package)
- [ChatMol Copilot](#copilot): an automated system capable of executing various tasks including: 
  - Structure prediction
  - Molecular docking
  - Sequence design
  - Small molecule analysis & generation


We also provide a Streamlit app for ChatMol, which can be used as a task execution agent or Q&A chatbot. It retains your entire conversation history with ChatMol, and you have the flexibility to modify the execution plan suggested by ChatMol. See more details in [here](./chatmol-streamlit/README.md).
Through these tools, we strive to empower scientists to better utilize large language models in solving scientific problems. Our goal is to bridge the gap between advanced AI capabilities and practical scientific research needs in molecular biology and related fields.


## ChatMol python package
## PyMOL Plugin


See this [README](./chatmol_pkg/README.md) for more details.
**Installation**  
Simply run the following command in PyMOL command line to install the plugin:


```bash
```python
pip install chatmol
load https://raw.githubusercontent.com/ChatMol/ChatMol/main/chatmol.py
```
```


## Copilot
For permanent installation, go to `Plugin` -> `Plugin Manager` -> `Install New Plugin` and enter the URL `https://raw.githubusercontent.com/ChatMol/ChatMol/main/chatmol.py`.
This is ChatMol copilot, just like other copilot, it is designed to help your work.  
[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/9uMFZMQqTf8/0.jpg)](https://www.youtube.com/watch?v=9uMFZMQqTf8)
See more details in [here](./copilot_public/README.md)

## ChatMol Website

- Visit the [official website](https://chatmol.org) for comprehensive information about its development and use cases.

- The [Online Chatbot](https://chatmol.org/qa/) is a Q&A system designed to answer questions related to PyMOL usage.

- The [ChatMol web-browser interface](http://xp.chatmol.org/chatmol.html) allows you to submit PyMOL requests and execute them in PyMOL via ChatMol. (Please note that this feature is browser setting-dependent)

## Requirements & Installation
<img src="./assets/install.png" alt="alt text" width="400px" align="right"/>

- PyMOL can be installed using `conda install -c conda-forge pymol-open-source`, python 3.7 and 3.10 were test to be fine.
- OpenAI Python package: To install, enter `pip install openai` in the PyMOL command line.
- Download the plugin script `chatmol.py` and save it to a convenient location on your computer.
- Launch PyMOL.
- In the PyMOL command line, enter `run /path/to/chatmol.py` (replace `/path/to` with the actual path to the script).
- Create a .PyMOL folder in your home director for saving PyMOL-related files, like ChatGPT API keys, PyMOL license file, etc.
- The plugin is now installed and ready to use.

Alternatively, you can use the following command to load the plugin directly:


**Usage**  
The simplest way to get started is to use the `chatlite` command in PyMOL. 
```pymol
chatlite download 1ake and color it by secondary structures
```
```
load https://raw.githubusercontent.com/JinyuanSun/ChatMol/main/chatmol.py
```

For permanent installation, click on `Plugin`, navigate to the `Plugin Manager`, go to `Install New Plugin`, and either choose the local file or fetch from the URL: `https://raw.githubusercontent.com/JinyuanSun/ChatMol/main/chatmol.py`

## ChatMol API Key Setup

Set your OpenAI API key by entering the following command in the PyMOL command line: `set_api_key your_api_key_here` (replace `your_api_key_here` with your actual API key). The API key will be stored in the same directory as the plugin script for future use.

## Usage

ChatMol offers two interaction modes in the PyMOL command line: ChatMol and ChatMol-Lite. ChatMol directly utilizes OpenAI's GPT-3.5 model and requires an API key setup, whereas ChatMol-Lite is built on text-davinci-003 and supplemented with additional PyMol-related resources. Currently, ChatMol-Lite is undergoing rapid development, providing faster performance and eliminating the need for an API key setup for end users.

### ChatMol as a Task Execution Agent

The ChatGPT Plugin automates PyMOL tasks with ease. In the PyMOL command line, just enter `chat` as the trigger word for the ChatMol plugin, followed by your PyMOL task description or questions about specific PyMOL commands. After entering your requests, a set of instructions will appear, and the commands for completing your tasks will be automatically executed by default. For example, use `chat Show me how to color a protein by its secondary structures` to view a protein molecule in the PyMOL 3D window, with colors representing its secondary structures.


![img](./assets/img_ss.png)
![img](./assets/img_ss.png)


### ChatMol as a Q&A Chatbot
Refer to the [doc](./pymol_plugin/README.md) for more details.


ChatMol also serves as a Q&A chatbot, answering your queries about executing PyMOL tasks without actually performing the PyMOL. 
**miniGUI**  
You can disable the automatic execution by adding a question mark `?` at the end of ChatMol prompt, e.g., `chat How do I align two proteins?`. You will receive a helpful response such as:
We also provide a miniGUI for ChatMol-Lite, which can be used as a task execution agent or Q&A chatbot. It retains your entire conversation history with ChatMol, and you have the flexibility to modify the execution plan suggested by ChatMol. For example, you can delete certain commands or add additional commands before sending them to PyMOL. You can launch the miniGUI from a terminal.
   
````
ChatGPT: To align two proteins in PyMOL, you can use the `align` command. Here's an example:

```
# Load two proteins
fetch 1ake
fetch 1ttt

# Align the two proteins
align 1ake, 1ttt


# Show the aligned proteins
```bash
show cartoon
cd miniGUI
python miniGUI.py
```
```
Here is a screenshot of the miniGUI:
![img](./assets/chatmol_lite.png)


In this example, we first load two proteins using the `fetch` command. If you already have the proteins loaded, you can skip this step.
## ChatMol + Streamlit

Next, we use the `align` command to align the two proteins. The first argument is the reference protein (the one that will not move), and the second argument is the mobile protein (the one that will be aligned to the reference). In this case, we're aligning 1ake to 1ttt.

Finally, we use the `show` command to display the aligned proteins in cartoon representation.


Note that the `align` command will superimpose the mobile protein onto the reference protein, so that the two proteins have the same orientation and position.
We also provide a Streamlit app for ChatMol, which can be used as a task execution agent or Q&A chatbot. It retains your entire conversation history with ChatMol, and you have the flexibility to modify the execution plan suggested by ChatMol. See more details in [here](./chatmol-streamlit/README.md).


````
## ChatMol python package
  commands from each query will be saved internally. if you want to execute all saved commands, run `chat e` or `chat execute`. After execution, the stashed commands are cleared.


### Want to start over again?
See this [README](./chatmol_pkg/README.md) for more details.
To start a new chat session, just enter the following in the PyMOL command line: `chat new`. This will let ChatMol clear the conversation history.


### ChatMol-Lite
We found the response of gpt-3.5 is slow and people might don't have access to OpenAI's API, we developed chatmol-lite as an alternative. This is installed with the chatmol automatically. You can use it by typing `chatlite` in the PyMOL command line:
```bash
```bash
chatlite "Something you want chatmol to do for you"
pip install chatmol
```
```
**`chatlite` is different from the `chat`:**
1. Although it is a chatbot and have memory, it is designed to directly execute commnads based on your instructions. 
2. You can chat with ChatMol-Lite at [here](https://chatmol.org/qa/), the model is the same as the `chatlite`
3. It is much faster than the `chat` and you don't need to set up the OpenAI API key. And the response is more short than the `chat` .


### miniGUI
## Copilot
We also provide a miniGUI for ChatMol-Lite, which can be used as a task execution agent or Q&A chatbot. It retains your entire conversation history with ChatMol, and you have the flexibility to modify the execution plan suggested by ChatMol. For example, you can delete certain commands or add additional commands before sending them to PyMOL. You can launch the miniGUI from a terminal.
This is ChatMol copilot, just like other copilot, it is designed to help your work.  
[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/9uMFZMQqTf8/0.jpg)](https://www.youtube.com/watch?v=9uMFZMQqTf8)  
See more details in [here](./copilot_public/README.md)


```bash
## ChatMol Website
git clone https://github.com/JinyuanSun/ChatMol.git

cd ChatMol/miniGUI
- Visit the [official website](https://chatmol.org) for comprehensive information about its development and use cases.
python miniGUI.py

```
- The [ChatMol web-browser interface](http://xp.chatmol.org/chatmol.html) allows you to submit PyMOL requests and execute them in PyMOL via ChatMol. (Please note that this feature is browser setting-dependent)
Here is a screenshot of the miniGUI:
![img](./assets/chatmol_lite.png)


## Acknowledgements
## Acknowledgements


As an open source project, we thank the support from [ChemXAI](https://www.chemxai.com/), [WeComput](https://www.wecomput.com/) and [levinthal](https://www.levinthal.bio/).
As an open source project, we thank the support from [ChemXAI](https://www.chemxai.com/), [WeComput](https://www.wecomput.com/) and [Levinthal](https://www.levinthal.bio/).


## License
## License
This project is released under the MIT License.
This project is released under the MIT License.
+411 −181

File changed.

Preview size limit exceeded, changes collapsed.

chatmol_v2.py

deleted100644 → 0
+0 −475

File deleted.

Preview size limit exceeded, changes collapsed.

pymol_plugin/README.md

0 → 100644
+106 −0
Original line number Original line Diff line number Diff line
# ChatMol PyMOL Plugin
This is a PyMOL plugin built by ChatMol, for automating the process of creating a biomoelcular figure in PyMOL. 

### Installation

We provide a up-to-date version of the plugin on our website. You can download the plugin from [here](https://chatmol.com/pymol_plugins/chatmol-latest.py). Or, in PyMOL command line, you can run the following command to install the plugin:

```python
load https://chatmol.com/pymol_plugins/chatmol-latest.py
```

### Supported LLM providers
| Provider  | Models               | GPU Required | API Key Required | Notes               |
| --------- | -------------------- | ------------ | ---------------- | ------------------- |
| OpenAI    | GPT Models           | No           | Yes              | Commercial API      |
| Anthropic | Claude Models        | No           | Yes              | Commercial API      |
| DeepSeek  | DeepSeek Models      | No           | Yes              | Commercial API      |
| Ollama    | LLaMA, Mixtral, etc. | Yes          | No               | Self-hosted models  |
| ChatMol   | ChatMol Model        | No           | No               | Free hosted service |

### Usage
1. The most easy way to get started is to use the `chatlite` command in PyMOL. 
```pymol
chatlite "show me a protein"
```

2. Comercial API providers
- OpenAI, Anthropic, and DeepSeek require an API key. You can get an API key from the respective provider's website.
- We suggest adding the API key to the environment variable:
```bash
export OPENAI_API_KEY=sk-proj-xxxx
export ANTHROPIC_API_KEY=sk-ant-xxxx
export DEEPSEEK_API_KEY=sk-xxxx
```
or you can use the `set_api_key` command in PyMOL:
```python
set_api_key openai, sk-proj-xxxx
set_api_key anthropic, sk-ant-xxxx
set_api_key deepseek, sk-xxxx
```
- Currently supported models are:

| **Provider** | **Models**                                                                                                |
| ------------ | --------------------------------------------------------------------------------------------------------- |
| OpenAI       | gpt-4o, gpt-4o-mini                                                                                       |
| Anthropic    | claude-3-5-sonnet-20241022, claude-3-5-haiku-20241022, claude-3-opus-20240229, claude-3-5-sonnet-20240620 |
| DeepSeek     | deepseek-chat                                                                                             |

Use `update_model` command to get the latest models from the provider.

```pymol
update_model deepseek-chat
```

Once the model and API key are set, you can use the `chat` command to generate text from the model.
```pymol
chat "show me a protein"
```

3. Self-hosted models
- Ollama provides self-hosted models. You can use any model you like, tell the plugin to use ollama models by adding `@ollama` to the model name. Refer to the [Ollama documentation](https://ollama.com/docs) for more information.
```pymol
update_model phi-4@ollama
```

### Examples

**1. ChatMol as a Task Execution Agent**

The ChatGPT Plugin automates PyMOL tasks with ease. In the PyMOL command line, just enter `chat` as the trigger word for the ChatMol plugin, followed by your PyMOL task description or questions about specific PyMOL commands. After entering your requests, a set of instructions will appear, and the commands for completing your tasks will be automatically executed by default. For example, use `chat Show me how to color a protein by its secondary structures` to view a protein molecule in the PyMOL 3D window, with colors representing its secondary structures.

![img](../assets/img_ss.png)

**2. ChatMol as a Q&A Chatbot**

ChatMol also serves as a Q&A chatbot, answering your queries about executing PyMOL tasks without actually performing the PyMOL. 
You can disable the automatic execution by adding a question mark `?` at the end of ChatMol prompt, e.g., `chat How do I align two proteins?`. You will receive a helpful response such as:
   
````
ChatGPT: To align two proteins in PyMOL, you can use the `align` command. Here's an example:

```
# Load two proteins
fetch 1ake
fetch 1ttt

# Align the two proteins
align 1ake, 1ttt

# Show the aligned proteins
show cartoon
```

In this example, we first load two proteins using the `fetch` command. If you already have the proteins loaded, you can skip this step.

Next, we use the `align` command to align the two proteins. The first argument is the reference protein (the one that will not move), and the second argument is the mobile protein (the one that will be aligned to the reference). In this case, we're aligning 1ake to 1ttt.

Finally, we use the `show` command to display the aligned proteins in cartoon representation.

Note that the `align` command will superimpose the mobile protein onto the reference protein, so that the two proteins have the same orientation and position.

````
  commands from each query will be saved internally. if you want to execute all saved commands, run `chat e` or `chat execute`. After execution, the stashed commands are cleared.

**3. Want to start over again?**
To start a new chat session, just enter the following in the PyMOL command line: `chat new`. This will let ChatMol clear the conversation history.
 No newline at end of file
Loading