|
| 1 | +# LexiSage - AI Definition Generator for Anki |
| 2 | + |
| 3 | +English | [中文](README.md) |
| 4 | + |
| 5 | +> LexiSage – Let your cards speak with clarity and wisdom. |
| 6 | +
|
| 7 | +## Project Overview |
| 8 | +[LexiSage](https://ankiweb.net/shared/info/750479332?cb=1744698675805) is an intelligent definition plugin designed for Anki that supports multiple AI interfaces (OpenAI, XAI, DeepSeek) to generate explanations for selected fields. It's especially useful for language learners. |
| 9 | + |
| 10 | +### Key Features |
| 11 | +- Automatic parsing of word meanings and usage |
| 12 | +- Context-based word explanations |
| 13 | +- Batch processing to improve study efficiency |
| 14 | +- Customizable system prompts |
| 15 | +- Support for multiple note types |
| 16 | +- Support for various AI services (requires your own API Keys) |
| 17 | + |
| 18 | +## Installation |
| 19 | + |
| 20 | +1. In Anki, click "Tools" > "Add-ons" |
| 21 | +2. Click "Get Add-ons" |
| 22 | +3. Enter the add-on code: **750479332** |
| 23 | +4. Restart Anki |
| 24 | + |
| 25 | +## Usage Instructions |
| 26 | + |
| 27 | +### Basic Configuration |
| 28 | + |
| 29 | +1. Open Anki, select "LexiSage Settings..." from the "Tools" menu |
| 30 | +2. Set up AI services. The plugin doesn't provide AI services itself, so you need to purchase API Keys from AI service providers and enter them into the plugin. After obtaining an API Key, select the corresponding service provider and fill in the correct API Key and the model you want to use. |
| 31 | + Recommended AI service providers: |
| 32 | + - [xAI](https://console.x.ai) (Great value: $5 monthly charge gives you $150 credit) |
| 33 | + - [DeepSeek](https://platform.deepseek.com) (Leading Chinese AI platform) |
| 34 | + |
| 35 | +  |
| 36 | +3. Add configuration for your note types, specify which template fields the AI should explain, designate output result fields, and optionally add context for more accurate definitions. |
| 37 | + |
| 38 | +  |
| 39 | + |
| 40 | + - Click the + button to add note type configuration |
| 41 | + - Select the field to explain |
| 42 | + - Select context field (optional) |
| 43 | + - Select destination field for definitions |
| 44 | + - Save configuration |
| 45 | + (This plugin supports configuring multiple note types, allowing batch processing of different note types simultaneously) |
| 46 | + |
| 47 | +### Generating Definitions |
| 48 | + |
| 49 | +1. Browse your card collection |
| 50 | +2. Select the cards for which you want to generate definitions |
| 51 | +3. Click "LexiSage" > "Generate Batch Definitions" in the menu bar, then wait for completion |
| 52 | + |
| 53 | +  |
| 54 | + |
| 55 | +### Custom Prompts |
| 56 | + |
| 57 | +The plugin includes built-in prompts, but if you're not satisfied with the definition results, you can customize the prompts in "LexiSage Settings" |
| 58 | + |
| 59 | +## Development Guide |
| 60 | + |
| 61 | +### Environment Setup |
| 62 | +1. Clone this repository |
| 63 | +2. Ensure you have Python 3.8+ installed |
| 64 | +3. Install dependencies: `pip install -r requirements.txt` (if available) |
| 65 | + |
| 66 | +### Project Structure |
| 67 | +- `__init__.py`: Plugin entry point and main functionality |
| 68 | +- `config_ui.py`: Configuration UI interface |
| 69 | +- `ai_service.py`: AI service API interface |
| 70 | +- `prompts.py`: Default prompt templates |
| 71 | + |
| 72 | +### Packaging the Plugin |
| 73 | +1. Ensure the project includes the following necessary files: |
| 74 | + - `__init__.py`: Plugin entry point |
| 75 | + - `ai_service.py`: AI service interface |
| 76 | + - `config_ui.py`: Configuration interface |
| 77 | + - `prompts.py`: Default prompts |
| 78 | + - `manifest.json`: Plugin metadata, including name, version, etc. |
| 79 | + - `meta.json`: Anki version compatibility information (important, determines supported Anki versions) |
| 80 | + - `config.json`: Default configuration (optional) |
| 81 | + - `LICENSE`: License file |
| 82 | + |
| 83 | +2. Update version numbers: |
| 84 | + - Update the `version` field in the `manifest.json` file |
| 85 | + - Synchronize the version number in the `ankiweb.json` file (used for AnkiWeb submissions) |
| 86 | + |
| 87 | +3. Package with the following command: |
| 88 | + ```bash |
| 89 | + zip -r anki_lexisage.ankiaddon __init__.py ai_service.py config_ui.py prompts.py manifest.json meta.json LICENSE config.json -x ".*" "__pycache__/*" "*.pyc" |
| 90 | + ``` |
| 91 | + |
| 92 | +4. Verify package contents: |
| 93 | + ```bash |
| 94 | + unzip -l anki_lexisage.ankiaddon |
| 95 | + ``` |
| 96 | + Ensure it contains only necessary files, without extraneous `.git`, `__pycache__`, etc. |
| 97 | + |
| 98 | +5. Test installation: |
| 99 | + - Install the `.ankiaddon` file in a test environment using Anki's "Install from file" function |
| 100 | + - Verify that the plugin functions correctly |
| 101 | + |
| 102 | +### Submitting to AnkiWeb |
| 103 | +1. Register an [AnkiWeb account](https://ankiweb.net/account/register) |
| 104 | +2. After logging in, visit the [sharing page](https://ankiweb.net/shared/info/) |
| 105 | +3. Click "Upload Add-on" to submit your plugin |
| 106 | +4. Fill in plugin information and upload the packaged file |
| 107 | +5. Wait for approval |
| 108 | + |
| 109 | +## Contribution Guidelines |
| 110 | +Contributions of code, issue reports, or feature suggestions are welcome! |
| 111 | + |
| 112 | +1. Fork this repository |
| 113 | +2. Create your feature branch: `git checkout -b feature/amazing-feature` |
| 114 | +3. Commit your changes: `git commit -m 'Add some amazing feature'` |
| 115 | +4. Push to the branch: `git push origin feature/amazing-feature` |
| 116 | +5. Open a Pull Request |
| 117 | + |
| 118 | +## License |
| 119 | +This project uses the [MIT License](LICENSE) - see the LICENSE file for details. |
| 120 | + |
| 121 | +## Acknowledgements |
| 122 | +- Thanks to all contributors and users |
| 123 | +- Special thanks to the Anki development team for providing an excellent platform |
| 124 | + |
| 125 | +## Supported AI Services |
| 126 | +- **OpenAI**: Supports GPT-3.5/GPT-4 and other models |
| 127 | +- **XAI**: Supports custom API interfaces |
| 128 | +- **DeepSeek**: Supports DeepSeek Chat models |
| 129 | + |
| 130 | +## Custom Prompts |
| 131 | +In prompt templates, you can use the following variables: |
| 132 | +- `{word}`: Represents the content of the field to explain |
| 133 | +- `{context}`: Represents the content of the context field (if any) |
| 134 | + |
| 135 | +## Troubleshooting |
| 136 | +- If the plugin doesn't work properly, check: |
| 137 | + - Whether your API key is correct |
| 138 | + - Whether your network connection is stable |
| 139 | + - Whether you've selected the correct fields |
| 140 | +- If you encounter problems, try restarting Anki |
| 141 | + |
| 142 | +## Privacy Statement |
| 143 | +This plugin sends your card content to the AI service you configure, so please ensure you understand the relevant privacy policies. API keys are stored only in local configuration files and are not uploaded. |
0 commit comments