Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ellama-make-flash-cards #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ Find the definition of the current word using Ellama.
Summarize a selected region or the current buffer using Ellama.
![ellama-summarize](imgs/ellama-summarize.gif)

### ellama-make-flash-cards
Create flashcards in org-mode headline format, which could later be used with packages such as [org-anki](https://github.com/eyeinsky/org-anki).

### ellama-code-review

Review code in a selected region or the current buffer using Ellama.
Expand Down
20 changes: 20 additions & 0 deletions ellama.el
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
;;
;; Ellama is a tool for interacting with large language models from Emacs.
;; It allows you to ask questions and receive responses from the
;; LLMs. Ellama can perform various tasks such as translation, code

Check warning on line 29 in ellama.el

View workflow job for this annotation

GitHub Actions / lint-emacs-29

There should be two spaces after a period

Check warning on line 29 in ellama.el

View workflow job for this annotation

GitHub Actions / lint-emacs-28

There should be two spaces after a period
;; review, summarization, enhancing grammar/spelling or wording and
;; more through the Emacs interface. Ellama natively supports streaming

Check warning on line 31 in ellama.el

View workflow job for this annotation

GitHub Actions / lint-emacs-29

There should be two spaces after a period

Check warning on line 31 in ellama.el

View workflow job for this annotation

GitHub Actions / lint-emacs-28

There should be two spaces after a period
;; output, making it effortless to use with your preferred text editor.
;;

Expand Down Expand Up @@ -89,7 +89,7 @@
ARGS contains keys for fine control.

:buffer BUFFER -- BUFFER is the buffer (or `buffer-name') to insert ellama reply
in. Default value is (current-buffer).

Check warning on line 92 in ellama.el

View workflow job for this annotation

GitHub Actions / lint-emacs-29

There should be two spaces after a period

Check warning on line 92 in ellama.el

View workflow job for this annotation

GitHub Actions / lint-emacs-28

There should be two spaces after a period

:point POINT -- POINT is the point in buffer to insert ellama reaply at."
(let* ((buffer (or (plist-get args :buffer) (current-buffer)))
Expand Down Expand Up @@ -244,6 +244,26 @@
(buffer-substring-no-properties (point-min) (point-max)))))
(ellama-instant (format "Text:\n%s\nSummarize it." text))))

;;;###autoload
(defun ellama-make-flash-cards ()
"Create flash cards from active region or current buffer."
(interactive)
(let ((text (if (region-active-p)
(buffer-substring-no-properties (region-beginning) (region-end))
(buffer-substring-no-properties (point-min) (point-max)))))
(ellama-chat (concat (format "Text:\n%s\n" text)
"Instructions:\n"
"Create anki flash cards for the above text. Break the text down into different flashcards.\n"
"Each flashcard should be clear, precise and consistent. Try extracting info about attributes/tendencies, similarities/differences,causes/effects, significance/implications etc and mention them in the flashcards wherever relevant."
"If there is a link in markdown format, you can skip it.\n\n"
"Format for flashcards (2 lines):\n"
"- First line: Front of the card (question), put an asterisk symbol and a space character infront as a prefix.\n"
"- Second line: Back of the card (answer), keep the answer short and precise\n\n"
"Example:\n"
"* What is an apple?\n"
"A fruit"
))))

Check warning on line 265 in ellama.el

View workflow job for this annotation

GitHub Actions / lint-emacs-29

Closing parens should not be wrapped onto new lines.

Check warning on line 265 in ellama.el

View workflow job for this annotation

GitHub Actions / lint-emacs-28

Closing parens should not be wrapped onto new lines.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, move closing parens to previous line.


;;;###autoload
(defun ellama-code-review ()
"Review code in selected region or current buffer."
Expand Down
Loading