Skip to content

Commit

Permalink
release zotero-chatpdf v0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ljeagle committed Oct 21, 2024
1 parent 0d1e00e commit 5679f07
Show file tree
Hide file tree
Showing 25 changed files with 2,259 additions and 706 deletions.
154 changes: 41 additions & 113 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,131 +1,59 @@
<div align="center">
<img src="imgs/background.png" width="50%" />
<h1 align="center">
Zotero-ChatPDF
</h1>
Zotero-ChatPDF is an advanced tool that integrates seamlessly with Zotero, enabling effortless interaction with PDF documents through state-of-the-art (SOTA) large language models (LLMs). It offers users the ability to ask questions, extract insights, and converse with PDFs directly, providing a powerful research assistant for scholars, researchers, and anyone who deals with large amounts of text in PDF format.

# Key Features
Effortless PDF Interaction: Chat with your PDFs directly in Zotero, asking questions and receiving detailed answers in natural language.

SOTA Language Models: Powered by cutting-edge LLMs, such as gpt-4o, claude-3.5-sonnet and gemini-1.5-pro, offering highly accurate and contextually relevant responses.
For Mac users, there are some excellent free and open-source models built in, such as llama3.1, gemma2, phi-3.5, etc. Now after free registration, they can be automatically downloaded, installed and used with just one click on the plugin page, and the model data is all locally stored, ensuring absolute privacy and security of the data

# Awesome GPT
Annotations and Highlights: Extract annotations and highlights from your PDFs and use them for deeper analysis and conversation.

Full-text Search: Automatically scan and index the full text of PDFs to enable more precise question-answering.

👋
Seamless Zotero Integration: Syncs directly with your Zotero library, making it easy to manage and query your documents without leaving the Zotero interface.


Welcome to share your command tag [here](https://github.com/MuiseDestiny/zotero-gpt/discussions/3) using [Meet API](src/modules/Meet/api.ts).
# How to Use
Installation: Download [here](), Open Zotero. In the top menu bar, click on `Tools > Add-ons`.

Click on the gear icon at the top right of the window. Click on `Install Add-on From File` and open the downloaded plugin file zotero-chatpdf.xpi.

[![Using Zotero Plugin Template](https://img.shields.io/badge/Using-Zotero%20Plugin%20Template-blue?style=flat-round&logo=github)](https://github.com/windingwind/zotero-plugin-template)
[![Latest release](https://img.shields.io/github/v/release/MuiseDestiny/zotero-gpt)](https://github.com/MuiseDestiny/zotero-gpt/releases)
![Release Date](https://img.shields.io/github/release-date/MuiseDestiny/zotero-gpt?color=9cf)
[![License](https://img.shields.io/github/license/MuiseDestiny/zotero-gpt)](https://github.com/MuiseDestiny/zotero-gpt/blob/master/LICENSE)
![Downloads latest release](https://img.shields.io/github/downloads/MuiseDestiny/zotero-gpt/latest/total?color=yellow)
Startup: In Zotero, press the keys to start the plugin, MacOS(command + enter), Windows(ctrl + enter).

Select LLM models: For Windows users, after registering the OpenAI, Claude, and Gemini models can all be accessed and switched by one click.

<img src="https://user-images.githubusercontent.com/51939531/228763331-90baa9aa-8bef-4b32-9d6f-35538b58b158.png" width="80%" />
For Mac users, after registering llama3.1, gemma2, phi-3.5 and mistral can all be used by just one click in plugin without extra need to install many additional tools or softwares.
Now the registration is open and free!

Chat with PDFs: Open any PDF and start asking questions. Zotero-ChatPDF will process the document and provide insightful responses.

</div>
Manage Insights: Save, export, or share the extracted insights, answers, and annotations from your conversations.

Quit: Press esc key to exit.



---

## 🚀 Main Features
Features about GPT:
- [x] 🔗 **Integrate with Zotero**: You can use the plugin to search and ask items in the library based on the selected text or the PDF file.
- [x] 🧠 Use GPT to generate reply text: support `gpt-3.5-turbo` and `gpt-4`
- [x] 🏷️ [Command tags](https://github.com/MuiseDestiny/zotero-gpt#command-tags): **Click once** to accelerate your research.
- [x] 💬 Ask questions about current **PDF file** (full-text or selected text).
- [x] 💬 Ask questions about **selected paper** (Abstract).
- [x] 📝 **Summarize the selected paper** into several highly condensed sentences.
- [x] 🔍 **Search items** in the library based on the selected text.
- [x] ... ...
- [x] ⚙️ **Advanced settings for GPT**: You can set the [api key](https://platform.openai.com/account/api-keys), [model name](https://platform.openai.com/docs/api-reference/chat/create#chat/create-model), [api url](https://platform.openai.com/docs/api-reference/chat/create), [temperature](https://platform.openai.com/docs/api-reference/chat/create#chat/create-temperature).
- [x] 📚 **Integrate with Better Notes**: You can directly open this plugin when using [Better Notes](https://github.com/windingwind/zotero-better-notes).

Features about UI:
- [x] 🎨 **Real-time markdown rendering** for reply text: Latex and mathjax are supported.
- [x] 🔍 **Zoom in and out** of the reply text or the size of the plugin window.
- [x] 🖱️ **Move the plugin window to any position** on the screen.
- [x] 📋 **Copy the reply text** to the clipboard.
- [x] ⚠️ Detailed **error message** will be displayed when the request fails.
- [x] 🔧 Compatible with **Zotero 6** and **Zotero 7**.
- [x] 🎉 Discover more exciting features that are not listed here.


## How to use
- [x] Get `.xpi` file
- [ ] [download latest](https://github.com/MuiseDestiny/zotero-gpt/releases/latest/download/zotero-gpt.xpi) release `.xpi` file
- [ ] or build this project [1] to generate a `.xpi` file
- [x] Install `.xpi` file in Zotero [2]
- [x] Open Zotero GPT [3]
- [x] Set your `OpenAI` secret key [4]

### [1] Build the project
Here is an example on how to build this project. For more information on how to build, please visit this project: [https://github.com/windingwind/zotero-plugin-template](https://github.com/windingwind/zotero-plugin-template)
# Build the plugin
If you like to build the plugin by yourself, do as the below commands:

```bash
git clone https://github.com/MuiseDestiny/zotero-gpt.git
cd zotero-gpt
git clone https://github.com/ljeagle/zotero-chatpdf.git
cd zotero-chatpdf
npm install
npm run build
```
The generated `.xpi` file in the build directory is the extension that you can install in Zotero.

### [2] Install the extension in Zotero
Open Zotero. In the top menu bar, click on `Tools > Add-ons`.
Click on the gear icon at the top right of the window. Click on `Install Add-on From File` and open the generated `.xpi` file in the build directory from the previous step.

### [3] Open/Exit Zotero GPT

|Action|Shortcut|
|--|--|
|Open|<img src="https://github.com/MuiseDestiny/zotero-gpt/assets/51939531/f76b23ee-8c54-47da-823c-8c14faa88a87" width="20%">|
|Exit|`ESC`|
|Multi-line editing| `Shift` + `Enter`|

### [4] Set up the API key

![image](https://github.com/MuiseDestiny/zotero-gpt/assets/51939531/225c468a-acfc-43be-b5ac-cf6aaaa33e96)

## Hi, Command Tag.
> 👻 Follow the steps below, and you will gain a new understanding of command tags.
|Step| Description | Supplementary Information |
|----|-------------|---------------------------|
|1 | Open Zotero GPT | Refer to [3] Open/Exit Zotero GPT |
|2 | Type `#Tag Name` and press `Enter` | ![image](https://github.com/MuiseDestiny/zotero-gpt/assets/51939531/52f776fc-5592-4c17-8c36-7769c537ef79) |
|3 | Input your prompt or code | ![image](https://github.com/MuiseDestiny/zotero-gpt/assets/51939531/6f6d9985-69e5-4d29-ba78-df31e30e9cd1) |
|4 | **R**un your tag | Press `Ctrl + R` |
|5 | **S**ave your tag | Press `Ctrl + S` |
|6 | Long press a command tag to access the editing interface | ![image](https://github.com/MuiseDestiny/zotero-gpt/assets/51939531/28235117-79ab-43c6-b175-079e609683f4) |
|7 | Modify the tag's color, position, or trigger; remember to save with `Ctrl + S` | ![image](https://github.com/MuiseDestiny/zotero-gpt/assets/51939531/5261878a-30ce-4ea5-b3be-9c6b9ef29f70) |
|8 | Press `ESC` to exit the editing interface | Remember to save your changes with `Ctrl + S` before exiting |
|9 | Long press the right mouse button to delete a tag | Note: Build-in tags do not support deletion |

### How to run a command tag
> Trigger is an attribute of a command tag, as are color and position. Long press any label to view/modify its trigger word. It supports both plain text and JS regular expressions.
![How to run a command tag](https://github.com/MuiseDestiny/zotero-gpt/assets/51939531/fdfc369a-1e96-478c-a7c2-4a93d2d7a580)

![image](https://github.com/MuiseDestiny/zotero-gpt/assets/51939531/d7f857a4-9ed9-42af-8662-6336ce70a881)


### How to write a code block

You can find some build-in APIs [here](https://github.com/MuiseDestiny/zotero-gpt/blob/bootstrap/src/modules/Meet/api.ts).

A simple example:
```
Summarize the following paragraph for me:
${Meet.Zotero.getPDFSelection()}
```

Here, the `Summarize the following paragraph for me:` represents plain text, while `${your code}` denotes a code snippet. Undoubtedly, if you are familiar with Zotero APIs, you can develop your own code. The code snippet will be executed, and the text returned by the code snippet will replace the code snippet. Finally, the replaced text will be input to GPT. So, theoretically, you can **accomplish all interactions** between Zotero and GPT using command tags.

### How to navigate historical chats

> Press the up (↑) and down (↓) keys on the keyboard to navigate.
![image](https://github.com/MuiseDestiny/zotero-gpt/assets/51939531/ca2dcfbf-efb4-4ba3-8339-5277a879e3ea)

## Support the project

[Here](https://github.com/MuiseDestiny/zotero-reference#%E8%B5%9E%E5%8A%A9)
The plugin file(zotero-chatpdf.xpi) will be built and generated into the build directory


# Use Cases
Research Assistance: Summarize research papers, identify key concepts, and quickly get answers to your questions.

Academic Writing: Generate insights for literature reviews or dive deep into specific sections of papers.

Collaborative Projects: Share annotated PDFs and responses with colleagues and teams for smoother collaboration.

# Contributions
Contributions to Zotero-ChatPDF are welcome! Please follow the standard GitHub process for submitting pull requests or reporting issues.

Binary file removed addon/chrome/content/icons/favicon.png
Binary file not shown.
2 changes: 1 addition & 1 deletion addon/chrome/content/md.css
Original file line number Diff line number Diff line change
Expand Up @@ -1078,4 +1078,4 @@

.markdown-body ::-webkit-calendar-picker-indicator {
filter: invert(50%)
}
}
2 changes: 1 addition & 1 deletion addon/install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
em:creator="__author__"
em:description="__description__"
em:homepageURL="__homepage__"
em:iconURL="chrome://__addonRef__/content/icons/favicon.png"
em:iconURL="chrome://__addonRef__/content/icons/favicon.ico"
em:optionsURL="chrome://__addonRef__/content/preferences.xul"
em:updateURL="__updaterdf__"
em:multiprocessCompatible="true"
Expand Down
8 changes: 6 additions & 2 deletions addon/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
"description": "__description__",
"author": "__author__",
"icons": {
"48": "chrome/content/icons/[email protected].png",
"96": "chrome/content/icons/favicon.png"
"48": "chrome/content/icons/[email protected].ico",
"96": "chrome/content/icons/favicon.ico"
},
"permissions": [
"downloads",
"downloads.open"
],
"applications": {
"zotero": {
"id": "__addonID__",
Expand Down
23 changes: 15 additions & 8 deletions addon/prefs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
pref("extensions.zotero.__addonRef__.enable", true);
pref("extensions.zotero.__addonRef__.tags", "[]");
pref("extensions.zotero.__addonRef__.languages", "[\"Arabic\", \"Bengali\", \"Bulgarian\", \"Chinese\", \"Croatian\", \"Czech\", \"Danish\", \"Dutch\", \"English\", \"Estonian\", \"Finnish\", \"French\", \"German\", \"Greek\", \"Hebrew\", \"Hindi\", \"Hungarian\", \"Italian\", \"Indonesian\", \"Japanese\", \"Korean\", \"Latvian\", \"Norwegian\", \"Polish\", \"Portuguese\", \"Romanian\", \"Russian\", \"Serbian\", \"Slovak\", \"Slovenian\", \"Spanish\", \"Swahili\", \"Swedish\", \"Thai\", \"Turkish\", \"Ukrainian\", \"Vietnamese\"]");
pref("extensions.zotero.__addonRef__.startLocalServer", false);
pref("extensions.zotero.__addonRef__.email", "");
pref("extensions.zotero.__addonRef__.token", "");
pref("extensions.zotero.__addonRef__.isLicenseActivated", false);
pref("extensions.zotero.__addonRef__.grade", "");
pref("extensions.zotero.__addonRef__.supportedLLMs", "");
pref("extensions.zotero.__addonRef__.usingLanguage", "");
pref("extensions.zotero.__addonRef__.usingPublisher", "OpenAI");
pref("extensions.zotero.__addonRef__.usingModel", "gpt-3.5-turbo");
pref("extensions.zotero.__addonRef__.usingAPIKEY", "");
pref("extensions.zotero.__addonRef__.usingAPIURL", "https://api.openai.com/v1/chat/completions");
pref("extensions.zotero.__addonRef__.openaiApiKey", "");
pref("extensions.zotero.__addonRef__.geminiApiKey", "");
pref("extensions.zotero.__addonRef__.claudeApiKey", "");
pref("extensions.zotero.__addonRef__.secretKey", "");
pref("extensions.zotero.__addonRef__.model", "gpt-3.5-turbo");
pref("extensions.zotero.__addonRef__.api", "https://api.openai.com");
Expand All @@ -10,11 +25,3 @@ pref("extensions.zotero.__addonRef__.tagsMore", "expand");
pref("extensions.zotero.__addonRef__.chatNumber", 3);
pref("extensions.zotero.__addonRef__.relatedNumber", 5);
pref("extensions.zotero.__addonRef__.embeddingBatchNum", 10);








Binary file removed imgs/apikey.png
Binary file not shown.
Binary file removed imgs/background.png
Binary file not shown.
Loading

0 comments on commit 5679f07

Please sign in to comment.