[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ellama 4848d51d6c: Improve markdown to org conversion
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/ellama 4848d51d6c: Improve markdown to org conversion |
|
Date: |
Mon, 22 Jan 2024 12:57:54 -0500 (EST) |
branch: externals/ellama
commit 4848d51d6c072f19c93d65134f0b364044815893
Author: Sergey Kostyaev <sskostyaev@gmail.com>
Commit: Sergey Kostyaev <sskostyaev@gmail.com>
Improve markdown to org conversion
Improve markdown to org conversion. Move readme from markdown to org.
---
NEWS.org | 3 +
README.md | 261 -------------------------------------------------------------
README.org | 254 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ellama.el | 27 ++++++-
4 files changed, 282 insertions(+), 263 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index 165cd2a93b..3ee350865e 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -1,3 +1,6 @@
+* Version 0.7.1
+- Improve markdown to org conversion.
+- Move readme from markdown to org.
* Version 0.7.0
- Switch from markdown to org-mode.
- Fix bug in session management on buffer kill.
diff --git a/README.md b/README.md
deleted file mode 100644
index a6e3554daa..0000000000
--- a/README.md
+++ /dev/null
@@ -1,261 +0,0 @@
-# Ellama
-
-[](http://www.gnu.org/licenses/gpl-3.0.txt)
-[](https://melpa.org/#/ellama)
-[](https://stable.melpa.org/#/ellama)
-[](https://elpa.gnu.org/packages/ellama.html)
-
-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
-review, summarization, enhancing grammar/spelling or wording and
-more through the Emacs interface. Ellama natively supports streaming
-output, making it effortless to use with your preferred text editor.
-
-## Installation
-
-Just `M-x` `package-install`<kbd>Enter</kbd> `ellama` <kbd>Enter</kbd>.
-By default it uses [ollama](https://github.com/jmorganca/ollama)
-provider and [zephyr](https://ollama.ai/library/zephyr) model. If you
-ok with it, you need to install
-[ollama](https://github.com/jmorganca/ollama) and pull
-[zephyr](https://ollama.ai/library/zephyr). You can use `ellama` with
-other model or other llm provider. In that case you should customize
-ellama configuration like this:
-
-``` emacs-lisp
-(use-package ellama
- :init
- (setopt ellama-language "German")
- (require 'llm-ollama)
- (setopt ellama-provider
- (make-llm-ollama
- :chat-model "mistral:7b-instruct-v0.2-q6_K" :embedding-model
"mistral:7b-instruct-v0.2-q6_K"))
- ;; Predefined llm providers for interactive switching.
- ;; You shouldn't add ollama providers here - it can be selected interactively
- ;; without it. It is just example.
- (setopt ellama-providers
- '(("zephyr" . (make-llm-ollama
- :chat-model
"zephyr:7b-beta-q6_K"
- :embedding-model
"zephyr:7b-beta-q6_K"))
- ("mistral" . (make-llm-ollama
- :chat-model
"mistral:7b-instruct-v0.2-q6_K"
- :embedding-model
"mistral:7b-instruct-v0.2-q6_K"))
- ("mixtral" . (make-llm-ollama
- :chat-model
"mixtral:8x7b-instruct-v0.1-q3_K_M-4k"
- :embedding-model
"mixtral:8x7b-instruct-v0.1-q3_K_M-4k")))))
-```
-
-## Commands
-
-### ellama-chat
-
-Ask Ellama about something by entering a prompt in an interactive
-buffer and continue conversation.
-
-
-### ellama-ask-about
-
-Ask Ellama about a selected region or the current buffer.
-
-
-### ellama-ask-selection
-
-Send selected region or current buffer to ellama chat.
-
-### ellama-ask-line
-
-Send current line to ellama chat.
-
-### ellama-complete
-
-Complete text in current buffer with ellama.
-
-### ellama-translate
-
-Ask Ellama to translate a selected region or word at the point.
-
-
-### ellama-define-word
-
-Find the definition of the current word using Ellama.
-
-
-### ellama-summarize
-
-Summarize a selected region or the current buffer using Ellama.
-
-
-### ellama-code-review
-
-Review code in a selected region or the current buffer using Ellama.
-
-
-### ellama-change
-
-Change text in a selected region or the current buffer according to a
-provided change.
-
-### ellama-make-list
-
-Create a markdown list from the active region or the current buffer using
Ellama.
-
-### ellama-make-table
-
-Create a markdown table from the active region or the current buffer using
Ellama.
-
-### ellama-summarize-webpage
-
-Summarize a webpage fetched from a URL using Ellama.
-
-### ellama-provider-select
-
-Select ellama provider.
-
-### ellama-code-complete
-
-Complete selected code or code in the current buffer according to a
-provided change using Ellama.
-
-### ellama-code-add
-
-Add new code according to a description, generating it with a provided
-context from the selected region or the current buffer using Ellama.
-
-### ellama-code-edit
-
-Change selected code or code in the current buffer according to a
-provided change using Ellama.
-
-### ellama-code-improve
-
-Change selected code or code in the current buffer according to a
-provided change using Ellama.
-
-### ellama-improve-wording
-
-Enhance the wording in the currently selected region or buffer using Ellama.
-
-### ellama-improve-grammar
-Enhance the grammar and spelling in the currently selected region or
-buffer using Ellama.
-
-
-### ellama-improve-conciseness
-
-Make the text of the currently selected region or buffer concise and
-simple using Ellama.
-
-### ellama-make-format
-
-Render the currently selected text or the text in the current buffer
-as a specified format using Ellama.
-
-### ellama-load-session
-
-Load ellama session from file.
-
-### ellama-session-remove
-
-Remove ellama session.
-
-### ellama-session-switch
-
-Change current active session.
-
-### ellama-session-rename
-
-Rename current ellama session.
-
-## Keymap
-
-Here is a table of keybindings and their associated functions in
-Ellama, using the `C-c e` prefix:
-
-| Keymap | Function | Description |
-|--------|----------------------------|------------------------------------|
-| "c c" | ellama-code-complete | Code complete |
-| "c a" | ellama-code-add | Code add |
-| "c e" | ellama-code-edit | Code edit |
-| "c i" | ellama-code-improve | Code improve |
-| "c r" | ellama-code-review | Code review |
-| "s s" | ellama-summarize | Summarize |
-| "s w" | ellama-summarize-webpage | Summarize webpage |
-| "i w" | ellama-improve-wording | Improve wording |
-| "i g" | ellama-improve-grammar | Improve grammar and spelling |
-| "i c" | ellama-improve-conciseness | Improve conciseness |
-| "m l" | ellama-make-list | Make list |
-| "m t" | ellama-make-table | Make table |
-| "m f" | ellama-make-format | Make format |
-| "a a" | ellama-ask-about | Ask about |
-| "a i" | ellama-chat | Chat (ask interactively) |
-| "a l" | ellama-ask-line | Ask about current line |
-| "a s" | ellama-ask-selection | Ask about selection |
-| "t t" | ellama-translate | Text translate |
-| "t c" | ellama-complete | Text complete |
-| "d w" | ellama-define-word | Define word |
-| "p s" | ellama-provider-select | Provider select |
-
-## Configuration
-
-The following variables can be customized for the Ellama client:
-
-- `ellama-enable-keymap`: Enable the Ellama keymap.
-- `ellama-keymap-prefix`: The keymap prefix for Ellama.
-- `ellama-user-nick`: The user nick in logs.
-- `ellama-assistant-nick`: The assistant nick in logs.
-- `ellama-language`: The language for Ollama translation. Default
-language is english.
-- `ellama-provider`: llm provider for ellama. Default provider is
-`ollama` with [zephyr](https://ollama.ai/library/zephyr) model.
-There are many supported providers: `ollama`, `open ai`, `vertex`,
-`GPT4All`. For more information see [llm
-documentation](https://elpa.gnu.org/packages/llm.html)
-- `ellama-providers`: association list of model llm providers with
- name as key.
-- `ellama-spinner-type`: Spinner type for ellama. Default type is
-`progress-bar`.
-- `ellama-ollama-binary`: Path to ollama binary.
-- `ellama-auto-scroll`: If enabled ellama buffer will scroll
- automatically during generation. Disabled by default.
-- `ellama-fill-paragraphs`: Option to customize ellama paragraphs
- filling behaviour.
-- `ellama-name-prompt-words-count`: Count of words in prompt to
- generate name.
-- Prompt templates for every command.
-- `ellama-chat-done-callback`: Callback that will be called on ellama
-chat response generation done. It should be a function with single
-argument generated text string.
-- `ellama-nick-prefix`: User and assistant nick prefix in logs.
-- `ellama-session-file-extension`: File extension for saving ellama
- session. Default value "org".
-- `ellama-sessions-directory`: Directory for saved ellama sessions.
-- `ellama-instant-mode`: Major mode for ellama instant commands. Org
- mode by default.
-- `ellama-long-lines-length`: Long lines length for fill paragraph call.
-Too low value can break generated code by splitting long comment
-lines. Default value 100.
-
-## Acknowledgments
-
-Thanks [Jeffrey Morgan](https://github.com/jmorganca) for excellent
-project [ollama](https://github.com/jmorganca/ollama). This project
-cannot exist without it.
-
-Thanks [zweifisch](https://github.com/zweifisch) - I got some ideas
-from [ollama.el](https://github.com/zweifisch/ollama) what ollama
-client in Emacs can do.
-
-Thanks [Dr. David A. Kunz](https://github.com/David-Kunz) - I got more
-ideas from [gen.nvim](https://github.com/David-Kunz/gen.nvim).
-
-Thanks [Andrew Hyatt](https://github.com/ahyatt) for `llm` library.
-Without it only `ollama` would be supported.
-
-# Contributions
-
-If you are interested in creating a provider, please send a pull
-request, or open a bug. This library is part of GNU ELPA, so any major
-provider that we include in this module needs to be written by someone
-with FSF papers. However, you can always write a module and put it on
-a different package archive, such as MELPA.
diff --git a/README.org b/README.org
new file mode 100644
index 0000000000..d808450904
--- /dev/null
+++ b/README.org
@@ -0,0 +1,254 @@
+* Ellama
+
+[[http://www.gnu.org/licenses/gpl-3.0.txt][file:https://img.shields.io/badge/license-GPL_3-green.svg]]
+[[https://melpa.org/#/ellama][file:https://melpa.org/packages/ellama-badge.svg]]
+[[https://stable.melpa.org/#/ellama][file:https://stable.melpa.org/packages/ellama-badge.svg]]
+[[https://elpa.gnu.org/packages/ellama.html][file:https://elpa.gnu.org/packages/ellama.svg]]
+
+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
+review, summarization, enhancing grammar/spelling or wording and
+more through the Emacs interface. Ellama natively supports streaming
+output, making it effortless to use with your preferred text editor.
+
+** Installation
+
+Just ~M-x~ ~package-install~ @@html:<kbd>Enter</kbd>@@ ~ellama~
+@@html:<kbd>Enter</kbd>@@. By default it uses
[[https://github.com/jmorganca/ollama][ollama]] provider and
+[[https://ollama.ai/library/zephyr][zephyr]] model. If you ok with it, you
need to install [[https://github.com/jmorganca/ollama][ollama]] and pull
+[[https://ollama.ai/library/zephyr][zephyr]]. You can use ~ellama~ with other
model or other llm provider.
+In that case you should customize ellama configuration like this:
+
+#+BEGIN_SRC emacs-lisp
+ (use-package ellama
+ :init
+ (setopt ellama-language "German")
+ (require 'llm-ollama)
+ (setopt ellama-provider
+ (make-llm-ollama
+ :chat-model "mistral:7b-instruct-v0.2-q6/K"
+ :embedding-model "mistral:7b-instruct-v0.2-q6/K"))
+ ;; Predefined llm providers for interactive switching.
+ ;; You shouldn't add ollama providers here - it can be selected
interactively
+ ;; without it. It is just example.
+ (setopt ellama-providers
+ '(("zephyr" . (make-llm-ollama
+ :chat-model "zephyr:7b-beta-q6_K"
+ :embedding-model "zephyr:7b-beta-q6_K"))
+ ("mistral" . (make-llm-ollama
+ :chat-model "mistral:7b-instruct-v0.2-q6_K"
+ :embedding-model
"mistral:7b-instruct-v0.2-q6_K"))
+ ("mixtral" . (make-llm-ollama
+ :chat-model
"mixtral:8x7b-instruct-v0.1-q3/K/M-4k"
+ :embedding-model
"mixtral:8x7b-instruct-v0.1-q3/K/M-4k")))))
+#+END_SRC
+
+** Commands
+
+*** ellama-chat
+
+Ask Ellama about something by entering a prompt in an interactive
+buffer and continue conversation.
+![[imgs/ellama-ask.gif][ellama-chat]]
+
+*** ellama-ask-about
+
+Ask Ellama about a selected region or the current buffer.
+![[imgs/ellama-ask-about.gif][ellama-ask-about]]
+
+*** ellama-ask-selection
+
+Send selected region or current buffer to ellama chat.
+
+*** ellama-ask-line
+
+Send current line to ellama chat.
+
+*** ellama-complete
+
+Complete text in current buffer with ellama.
+
+*** ellama-translate
+
+Ask Ellama to translate a selected region or word at the point.
+![[imgs/ellama-translate.gif][ellama-translate]]
+
+*** ellama-define-word
+
+Find the definition of the current word using Ellama.
+![[imgs/ellama-define-word.gif][ellama-define-word]]
+
+*** ellama-summarize
+
+Summarize a selected region or the current buffer using Ellama.
+![[imgs/ellama-summarize.gif][ellama-summarize]]
+
+*** ellama-code-review
+
+Review code in a selected region or the current buffer using Ellama.
+![[imgs/ellama-code-review.gif][ellama-code-review]]
+
+*** ellama-change
+
+Change text in a selected region or the current buffer according to a
+provided change.
+
+*** ellama-make-list
+
+Create a markdown list from the active region or the current buffer using
Ellama.
+
+*** ellama-make-table
+
+Create a markdown table from the active region or the current buffer using
Ellama.
+
+*** ellama-summarize-webpage
+
+Summarize a webpage fetched from a URL using Ellama.
+
+*** ellama-provider-select
+
+Select ellama provider.
+
+*** ellama-code-complete
+
+Complete selected code or code in the current buffer according to a
+provided change using Ellama.
+
+*** ellama-code-add
+
+Add new code according to a description, generating it with a provided
+context from the selected region or the current buffer using Ellama.
+
+*** ellama-code-edit
+
+Change selected code or code in the current buffer according to a
+provided change using Ellama.
+
+*** ellama-code-improve
+
+Change selected code or code in the current buffer according to a
+provided change using Ellama.
+
+*** ellama-improve-wording
+
+Enhance the wording in the currently selected region or buffer using Ellama.
+
+*** ellama-improve-grammar
+Enhance the grammar and spelling in the currently selected region or
+buffer using Ellama.
+![[imgs/ellama-enhance-grammar-spelling.gif][ellama-improve-grammar]]
+
+*** ellama-improve-conciseness
+
+Make the text of the currently selected region or buffer concise and
+simple using Ellama.
+
+*** ellama-make-format
+
+Render the currently selected text or the text in the current buffer
+as a specified format using Ellama.
+
+*** ellama-load-session
+
+Load ellama session from file.
+
+*** ellama-session-remove
+
+Remove ellama session.
+
+*** ellama-session-switch
+
+Change current active session.
+
+*** ellama-session-rename
+
+Rename current ellama session.
+
+** Keymap
+
+Here is a table of keybindings and their associated functions in
+Ellama, using the ~C-c e~ prefix:
+
+| Keymap | Function | Description |
+|--------+----------------------------+------------------------------|
+| "c c" | ellama-code-complete | Code complete |
+| "c a" | ellama-code-add | Code add |
+| "c e" | ellama-code-edit | Code edit |
+| "c i" | ellama-code-improve | Code improve |
+| "c r" | ellama-code-review | Code review |
+| "s s" | ellama-summarize | Summarize |
+| "s w" | ellama-summarize-webpage | Summarize webpage |
+| "i w" | ellama-improve-wording | Improve wording |
+| "i g" | ellama-improve-grammar | Improve grammar and spelling |
+| "i c" | ellama-improve-conciseness | Improve conciseness |
+| "m l" | ellama-make-list | Make list |
+| "m t" | ellama-make-table | Make table |
+| "m f" | ellama-make-format | Make format |
+| "a a" | ellama-ask-about | Ask about |
+| "a i" | ellama-chat | Chat (ask interactively) |
+| "a l" | ellama-ask-line | Ask about current line |
+| "a s" | ellama-ask-selection | Ask about selection |
+| "t t" | ellama-translate | Text translate |
+| "t c" | ellama-complete | Text complete |
+| "d w" | ellama-define-word | Define word |
+| "p s" | ellama-provider-select | Provider select |
+
+** Configuration
+
+The following variables can be customized for the Ellama client:
+
+- ~ellama-enable-keymap~: Enable the Ellama keymap.
+- ~ellama-keymap-prefix~: The keymap prefix for Ellama.
+- ~ellama-user-nick~: The user nick in logs.
+- ~ellama-assistant-nick~: The assistant nick in logs.
+- ~ellama-language~: The language for Ollama translation. Default
+language is english.
+- ~ellama-provider~: llm provider for ellama. Default provider is
+~ollama~ with [[https://ollama.ai/library/zephyr][zephyr]] model.
+There are many supported providers: ~ollama~, ~open ai~, ~vertex~,
+~GPT4All~. For more information see
[[https://elpa.gnu.org/packages/llm.html][llm documentation]].
+- ~ellama-providers~: association list of model llm providers with
+ name as key.
+- ~ellama-spinner-type~: Spinner type for ellama. Default type is
+~progress-bar~.
+- ~ellama-ollama-binary~: Path to ollama binary.
+- ~ellama-auto-scroll~: If enabled ellama buffer will scroll
+ automatically during generation. Disabled by default.
+- ~ellama-fill-paragraphs~: Option to customize ellama paragraphs
+ filling behaviour.
+- ~ellama-name-prompt-words-count~: Count of words in prompt to
+ generate name.
+- Prompt templates for every command.
+- ~ellama-chat-done-callback~: Callback that will be called on ellama
+chat response generation done. It should be a function with single
+argument generated text string.
+- ~ellama-nick-prefix~: User and assistant nick prefix in logs.
+- ~ellama-session-file-extension~: File extension for saving ellama
+ session. Default value "org".
+- ~ellama-sessions-directory~: Directory for saved ellama sessions.
+- ~ellama-instant-mode~: Major mode for ellama instant commands. Org
+ mode by default.
+- ~ellama-long-lines-length~: Long lines length for fill paragraph call.
+Too low value can break generated code by splitting long comment
+lines. Default value 100.
+
+** Acknowledgments
+
+Thanks [[https://github.com/jmorganca][Jeffrey Morgan]] for excellent project
[[https://github.com/jmorganca/ollama][ollama]]. This project
+cannot exist without it.
+
+Thanks [[https://github.com/zweifisch][zweifisch]] - I got some ideas from
[[https://github.com/zweifisch/ollama][ollama.el]] what ollama client
+in Emacs can do.
+
+Thanks [[https://github.com/David-Kunz][Dr. David A. Kunz]] - I got more ideas
from [[https://github.com/David-Kunz/gen.nvim][gen.nvim]].
+
+Thanks [[https://github.com/ahyatt][Andrew Hyatt]] for ~llm~ library. Without
it only ~ollama~ would
+be supported.
+
+* Contributions
+
+To contribute, submit a pull request or report a bug. This library is
+part of GNU ELPA; major contributions must be from someone with FSF
+papers. Alternatively, you can write a module and share it on a
+different archive like MELPA.
diff --git a/ellama.el b/ellama.el
index 538728a888..7d8afc6298 100644
--- a/ellama.el
+++ b/ellama.el
@@ -6,7 +6,7 @@
;; URL: http://github.com/s-kostyaev/ellama
;; Keywords: help local tools
;; Package-Requires: ((emacs "28.1") (llm "0.6.0") (spinner "1.7.4") (dash
"2.19.1"))
-;; Version: 0.7.0
+;; Version: 0.7.1
;; SPDX-License-Identifier: GPL-3.0-or-later
;; Created: 8th Oct 2023
@@ -305,15 +305,38 @@ Too low value can break generated code by splitting long
comment lines."
"Filter to translate code blocks from markdown syntax to org syntax in TEXT.
This filter contains only subset of markdown syntax to be good enough."
(->> text
+ ;; code blocks
(replace-regexp-in-string "^```\\(.+\\)$" "#+BEGIN_SRC \\1")
+ (replace-regexp-in-string "^<!-- language: \\(.+\\) -->\n```"
"#+BEGIN_SRC \\1")
(replace-regexp-in-string "^```$" "#+END_SRC")
+ ;; lists
+ (replace-regexp-in-string "^\\* " "+ ")
+ ;; bold
+ (replace-regexp-in-string "\\*\\*\\(.+?\\)\\*\\*" "*\\1*")
+ (replace-regexp-in-string "__\\(.+?\\)__" "*\\1*")
+ (replace-regexp-in-string "<b>\\(.+?\\)</b>" "*\\1*")
+ ;; italic
+ (replace-regexp-in-string "_\\(.+?\\)_" "/\\1/")
+ (replace-regexp-in-string "<i>\\(.+?\\)</i>" "/\\1/")
+ ;; inline code
+ (replace-regexp-in-string "`\\(.+?\\)`" "~\\1~")
+ ;; underlined
+ (replace-regexp-in-string "<u>\\(.+?\\)</u>" "_\\1_")
+ ;; strikethrough
+ (replace-regexp-in-string "~~\\(.+?\\)~~" "+\\1+")
+ (replace-regexp-in-string "<s>\\(.+?\\)</s>" "+\\1+")
+ ;; headings
(replace-regexp-in-string "^# " "* ")
(replace-regexp-in-string "^## " "** ")
(replace-regexp-in-string "^### " "*** ")
(replace-regexp-in-string "^#### " "**** ")
(replace-regexp-in-string "^##### " "***** ")
(replace-regexp-in-string "^###### " "***** ")
- (replace-regexp-in-string "^* " "- ")
+ ;; badges
+ (replace-regexp-in-string "\\[\\!\\[.*?\\](\\(.*?\\))\\](\\(.*?\\))"
"[[\\2][file:\\1]]")
+ ;;links
+ (replace-regexp-in-string "\\[\\(.*?\\)\\](\\(.*?\\))" "[[\\2][\\1]]")
+ ;; filling long lines
(ellama--fill-long-lines)))
(defcustom ellama-enable-keymap t
| [Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/ellama 4848d51d6c: Improve markdown to org conversion,
ELPA Syncer <=