forked from mhujer/ankiai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
4,147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
OPENAI_API_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
build | ||
**/*.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"root": true, | ||
"ignorePatterns": ["vite.config.ts"], | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:@typescript-eslint/recommended-requiring-type-checking", | ||
"plugin:@typescript-eslint/strict" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": ["./tsconfig.json"] | ||
}, | ||
"settings": { | ||
"react": { | ||
"version": "detect" | ||
} | ||
}, | ||
"plugins": ["@typescript-eslint"], | ||
"rules": { | ||
"prefer-const": "error", | ||
"no-var": "error", | ||
"@typescript-eslint/no-unsafe-return": "error", | ||
"@typescript-eslint/no-unused-vars": "error", | ||
"@typescript-eslint/no-unsafe-call": "error", | ||
"@typescript-eslint/await-thenable": "error", | ||
"@typescript-eslint/no-misused-promises": "error", | ||
"@typescript-eslint/strict-boolean-expressions": [ | ||
2, | ||
{ | ||
"allowString": false, | ||
"allowNumber": false | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x | ||
cache: 'npm' | ||
- run: npm ci | ||
- run: npm run ci-build | ||
- run: npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
coverage | ||
|
||
node_modules | ||
dist | ||
build | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
package-lock.json | ||
.idea | ||
build | ||
/coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"trailingComma": "all", | ||
"useTabs": false, | ||
"semi": true, | ||
"singleQuote": true, | ||
"printWidth": 120, | ||
"tabWidth": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Anki AI - Add example sentences to your Anki notes with ChatGPT | ||
|
||
> _Note: This README has been improved by ChatGPT 😀_ | ||
Anki AI is a powerful tool that leverages the chat completion API from ChatGPT to generate example sentences for your Anki notes. With Anki AI, you can quickly and easily enhance your Anki notes with relevant and useful example sentences, regardless of the language you are studying. | ||
|
||
## Depends on: | ||
|
||
1. [AnkiConnect](https://github.com/FooSoft/anki-connect) plugin to provide HTTP API for Anki. | ||
2. [Chat completion API](https://platform.openai.com/docs/guides/chat) from ChatGPT to generate sentences. | ||
|
||
## How to use | ||
|
||
Anki AI was originally created to add example sentences to my German Anki notes, but it can be easily adapted to work with other languages as well. To use Anki AI, follow these steps: | ||
|
||
1. [Obtain an OpenAI API key](https://platform.openai.com/account/api-keys) and add it to your `.env.local` under `OPENAI_API_KEY` entry. See the included `.env` file for an example. | ||
2. Install [AnkiConnect](https://ankiweb.net/shared/info/2055492159) to your Anki | ||
3. Update the `DECK_TO_PROCESS` constant in `src/main.ts` to match the name of the deck you want to process. | ||
4. Modify `NoteFields` interface to match fields names in your Anki notes | ||
5. Replace all occurences of `FrontTextExample` with the name of the field where you want the example sentences to be placed. | ||
6. For other languages than German, I guess that it would be enough to replace `German` with something else in the prompt in `src/openai/get-sentences-from-chatgpt.ts` | ||
7. Ensure that Anki is running. | ||
8. Run `npm run dev` to start the Anki AI application. | ||
|
||
By following these simple steps, you can quickly and easily enhance your Anki notes with relevant and useful example sentences using Anki AI. | ||
|
||
## Examples | ||
|
||
I got pretty good results (at least for my language learning needs). | ||
|
||
```js | ||
[ | ||
{ noteId: 1675192165656, text: 'der Ton' }, | ||
{ noteId: 1675192165657, text: 'der Führerschein' }, | ||
{ noteId: 1675192165661, text: 'die Schuld' }, | ||
{ noteId: 1675192165667, text: 'die Biene' }, | ||
{ noteId: 1675192165670, text: 'sich entzünden' }, | ||
{ noteId: 1675192165675, text: 'der Kaufmann' }, | ||
{ noteId: 1675192165675, text: 'die Kauffrau' }, | ||
{ noteId: 1675192165676, text: 'das Tischtennis' }, | ||
{ noteId: 1675192165681, text: 'die Stellenanzeige' }, | ||
{ noteId: 1675192165688, text: 'der Auftritt' }, | ||
{ noteId: 1675192165668, text: 'der Stich' }, | ||
{ noteId: 1675192165672, text: 'die Umschulung' }, | ||
{ noteId: 1675192165659, text: 'mit einem blauen Auge davonkommen' }, | ||
{ noteId: 1675192165685, text: 'ziemlich gut' }, | ||
{ noteId: 1675192165654, text: 'der Abnehmer' }, | ||
{ noteId: 1675192165669, text: 'anschwellen' }, | ||
{ noteId: 1675192165662, text: 'Schulden machen' }, | ||
{ noteId: 1675192165683, text: 'das Publikum' }, | ||
{ noteId: 1675192165652, text: 'der Lieferant' }, | ||
{ noteId: 1675192165655, text: 'vollkommen' }, | ||
]; | ||
``` | ||
|
||
```js | ||
{ | ||
'1675192165656': [ | ||
'Der Ton der Musik war zu laut.', | ||
'Kannst du bitte den Ton des Fernsehers erhöhen?' | ||
], | ||
'1675192165657': [ | ||
'Ich habe gestern meinen Führerschein bestanden.', | ||
'Ich kann meinen Führerschein nicht finden. ' | ||
], | ||
'1675192165661': [ | ||
'Ich habe keine Schuld an dem Unfall.', | ||
'Er hat die Schuld auf sich genommen.' | ||
], | ||
'1675192165667': [ | ||
'Die Biene ist auf einer Blume gelandet.', | ||
'Die Biene hat mich gestochen.' | ||
], | ||
'1675192165670': [ | ||
'Das Feuer hat sich schnell entzündet.', | ||
'Die Zigarette hat sich auf dem Teppich entzündet.' | ||
], | ||
'1675192165675': [ | ||
'Der Kaufmann hat einen neuen Laden eröffnet.', | ||
'Die Kauffrau arbeitet im Einzelhandel.' | ||
], | ||
'1675192165676': [ | ||
'Ich liebe Tischtennis spielen.', | ||
'Können wir Tischtennis im Garten spielen?' | ||
], | ||
'1675192165681': [ | ||
'Ich habe eine interessante Stellenanzeige gefunden.', | ||
'Die Stellenanzeige hat keine Angaben zum Gehalt.' | ||
], | ||
'1675192165688': [ | ||
'Sein Auftritt auf der Bühne war fantastisch.', | ||
'Der Musiker hatte einen schlechten Auftritt.' | ||
], | ||
'1675192165668': [ | ||
'Die Stechmücke hat mich gestochen.', | ||
'Er hat einen Stich ins Herz bekommen.' | ||
], | ||
'1675192165672': [ | ||
'Ich muss eine Umschulung machen, um eine neue Arbeit zu finden.', | ||
'Die Umschulung hat mir sehr geholfen, einen neuen Job zu finden.' | ||
], | ||
'1675192165659': [ | ||
'Ich bin froh, dass ich mit einem blauen Auge davon gekommen bin. ', | ||
'Er kam gestern mit einem blauen Auge davon.' | ||
], | ||
'1675192165685': [ | ||
'Sein Deutsch ist ziemlich gut.', | ||
'Sie spielt ziemlich gut Gitarre.' | ||
], | ||
``` |
Oops, something went wrong.