branch: externals/ellama
commit c491bf4c5b6449751a55afa6772c8cdb0e167a41
Merge: e3a5280bb1 109607e12c
Author: Sergey Kostyaev <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #369 from s-kostyaev/tools-fixes
Remove explicit handling of numeric arguments in ellama-tools
---
NEWS.org | 4 +++
README.org | 28 ++++++++++++++++
ellama-tools.el | 16 +++++++--
ellama.el | 2 +-
ellama.info | 100 +++++++++++++++++++++++++++++++++++++-------------------
5 files changed, 112 insertions(+), 38 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index 47cb8b8196..830120061d 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -1,3 +1,7 @@
+* Version 1.10.11
+- Remove explicit handling of numeric arguments in ellama-tools.
+- Add argument processing and type wrapping to tool definitions.
+- Add MCP Integration documentation.
* Version 1.10.10
- Refactored tool confirmation and simplified tool definitions.
- Simplified tool calling response handling.
diff --git a/README.org b/README.org
index 31e5d4137a..c51399e195 100644
--- a/README.org
+++ b/README.org
@@ -672,6 +672,34 @@ blueprint. It pre-fills variables based on the provided
arguments.
(global-set-key (kbd "C-c e M") #'my-chat-with-morpheus)
#+END_SRC
+* MCP Integration
+
+You can also use MCP (Model Context Protocol) tools with ~ellama~. You need
+Emacs 30 or higher version. Install ~mcp.el~ -
+https://github.com/lizqwerscott/mcp.el. For example to add web search
capability
+to ~ellama~ you can add duckduckgo mcp server
+(https://github.com/nickclyde/duckduckgo-mcp-server):
+
+#+begin_src emacs-lisp
+(use-package mcp
+ :ensure t
+ :demand t
+ :custom
+ (mcp-hub-servers
+ `(("ddg" . (:command "uvx"
+ :args
+ ("duckduckgo-mcp-server")))))
+ :config
+ (require 'mcp-hub)
+ (mcp-hub-start-all-server
+ (lambda ()
+ (let ((tools (mcp-hub-get-all-tool :asyncp t :categoryp t)))
+ (mapcar #'(lambda (tool)
+ (apply #'ellama-tools-define-tool
+ (list tool)))
+ tools)))))
+#+end_src
+
* Acknowledgments
Thanks [[https://github.com/jmorganca][Jeffrey Morgan]] for excellent project
[[https://github.com/jmorganca/ollama][ollama]]. This project
diff --git a/ellama-tools.el b/ellama-tools.el
index 6900812eeb..47db0e700a 100644
--- a/ellama-tools.el
+++ b/ellama-tools.el
@@ -88,8 +88,6 @@ FUNCTION if approved, \"Forbidden by the user\" otherwise."
(string-truncate-left
arg
ellama-tools-argument-max-length))
- ((numberp arg)
- (number-to-string arg))
(t
(format "%S" arg))))
args))
@@ -119,10 +117,22 @@ FUNCTION if approved, \"Forbidden by the user\"
otherwise."
TOOL-PLIST is a property list in the format expected by `llm-make-tool'.
Returns a new tool definition with the :function wrapped."
(let* ((func (plist-get tool-plist :function))
+ (args (plist-get tool-plist :args))
+ (wrapped-args
+ (mapcar
+ (lambda (arg)
+ (let*
+ ((type (plist-get tool-plist :type))
+ (wrapped-type (if (symbolp type)
+ type
+ (intern type))))
+ (plist-put arg :type wrapped-type)))
+ args))
(wrapped-func (lambda (&rest args)
(apply #'ellama-tools-confirm func args))))
;; Return a new plist with the wrapped function
- (plist-put tool-plist :function wrapped-func)))
+ (setq tool-plist (plist-put tool-plist :function wrapped-func))
+ (plist-put tool-plist :args wrapped-args)))
(defun ellama-tools-define-tool (tool-plist)
"Define a new ellama tool with automatic confirmation wrapping.
diff --git a/ellama.el b/ellama.el
index 15b1ee126e..b02659d5f4 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.24.0") (plz "0.8") (transient
"0.7") (compat "29.1"))
-;; Version: 1.10.10
+;; Version: 1.10.11
;; SPDX-License-Identifier: GPL-3.0-or-later
;; Created: 8th Oct 2023
diff --git a/ellama.info b/ellama.info
index 85e0dbe649..31d09b1732 100644
--- a/ellama.info
+++ b/ellama.info
@@ -65,6 +65,7 @@ Assistant". Previous sentence was written by Ellama itself.
* Context Management::
* Minor modes::
* Using Blueprints::
+* MCP Integration::
* Acknowledgments::
* Contributions::
* GNU Free Documentation License::
@@ -797,7 +798,7 @@ The session ID is displayed with a customizable face called
‘ellama-face’. You can customize this face to change its appearance.
-File: ellama.info, Node: Using Blueprints, Next: Acknowledgments, Prev:
Minor modes, Up: Top
+File: ellama.info, Node: Using Blueprints, Next: MCP Integration, Prev:
Minor modes, Up: Top
7 Using Blueprints
******************
@@ -924,9 +925,39 @@ arguments.
(global-set-key (kbd "C-c e M") #'my-chat-with-morpheus)
-File: ellama.info, Node: Acknowledgments, Next: Contributions, Prev: Using
Blueprints, Up: Top
+File: ellama.info, Node: MCP Integration, Next: Acknowledgments, Prev:
Using Blueprints, Up: Top
-8 Acknowledgments
+8 MCP Integration
+*****************
+
+You can also use MCP (Model Context Protocol) tools with ‘ellama’. You
+need Emacs 30 or higher version. Install ‘mcp.el’ -
+<https://github.com/lizqwerscott/mcp.el>. For example to add web search
+capability to ‘ellama’ you can add duckduckgo mcp server
+(<https://github.com/nickclyde/duckduckgo-mcp-server>):
+
+ (use-package mcp
+ :ensure t
+ :demand t
+ :custom
+ (mcp-hub-servers
+ `(("ddg" . (:command "uvx"
+ :args
+ ("duckduckgo-mcp-server")))))
+ :config
+ (require 'mcp-hub)
+ (mcp-hub-start-all-server
+ (lambda ()
+ (let ((tools (mcp-hub-get-all-tool :asyncp t :categoryp t)))
+ (mapcar #'(lambda (tool)
+ (apply #'ellama-tools-define-tool
+ (list tool)))
+ tools)))))
+
+
+File: ellama.info, Node: Acknowledgments, Next: Contributions, Prev: MCP
Integration, Up: Top
+
+9 Acknowledgments
*****************
Thanks Jeffrey Morgan (https://github.com/jmorganca) for excellent
@@ -946,8 +977,8 @@ Without it only ‘ollama’ would be supported.
File: ellama.info, Node: Contributions, Next: GNU Free Documentation
License, Prev: Acknowledgments, Up: Top
-9 Contributions
-***************
+10 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
@@ -1440,35 +1471,36 @@ their use in free software.
Tag Table:
Node: Top1379
-Node: Installation3613
-Node: Commands8621
-Node: Keymap16060
-Node: Configuration18893
-Node: Context Management24901
-Node: Transient Menus for Context Management25809
-Node: Managing the Context27423
-Node: Considerations28198
-Node: Minor modes28791
-Node: ellama-context-header-line-mode30779
-Node: ellama-context-header-line-global-mode31604
-Node: ellama-context-mode-line-mode32324
-Node: ellama-context-mode-line-global-mode33172
-Node: Ellama Session Header Line Mode33876
-Node: Enabling and Disabling34445
-Node: Customization34892
-Node: Ellama Session Mode Line Mode35180
-Node: Enabling and Disabling (1)35765
-Node: Customization (1)36212
-Node: Using Blueprints36506
-Node: Key Components of Ellama Blueprints37125
-Node: Creating and Managing Blueprints37732
-Node: Variable Management38713
-Node: Keymap and Mode39182
-Node: Transient Menus40118
-Node: Running Blueprints programmatically40664
-Node: Acknowledgments41251
-Node: Contributions41964
-Node: GNU Free Documentation License42348
+Node: Installation3633
+Node: Commands8641
+Node: Keymap16080
+Node: Configuration18913
+Node: Context Management24921
+Node: Transient Menus for Context Management25829
+Node: Managing the Context27443
+Node: Considerations28218
+Node: Minor modes28811
+Node: ellama-context-header-line-mode30799
+Node: ellama-context-header-line-global-mode31624
+Node: ellama-context-mode-line-mode32344
+Node: ellama-context-mode-line-global-mode33192
+Node: Ellama Session Header Line Mode33896
+Node: Enabling and Disabling34465
+Node: Customization34912
+Node: Ellama Session Mode Line Mode35200
+Node: Enabling and Disabling (1)35785
+Node: Customization (1)36232
+Node: Using Blueprints36526
+Node: Key Components of Ellama Blueprints37145
+Node: Creating and Managing Blueprints37752
+Node: Variable Management38733
+Node: Keymap and Mode39202
+Node: Transient Menus40138
+Node: Running Blueprints programmatically40684
+Node: MCP Integration41271
+Node: Acknowledgments42296
+Node: Contributions43008
+Node: GNU Free Documentation License43394
End Tag Table