GithubHelp home page GithubHelp logo

emacs-llm-chat's Introduction

Example Configuration

(load! "../lib/llm-api/llm-api.el")
(load! "../lib/llm-chat/llm-chat.el")

;; ------------------------------
;; llm-api

(setq *togetherai-token* "<token>")
(setq *openrouter-token* "<token>")
(setq *pplx-token* "<token>")

(setq llm-api-enabled-platforms `(:open-router ,(llm--create-open-router-platform *openrouter-token*)
                                  :ollama ,(llm--create-ollama-platform)
                                  :ollama-completion ,(llm--create-ollama-comp-platform)
                                  :pplx ,(llm--create-pplx-platform *pplx-token*)
                                  :together-ai ,(llm--create-together-ai-platform *togetherai-token*)
                                  :openchat-team ,(llm--create-openchat-team-platform)))

(setq *ollama-inference-servers*
      '((:lan-erebos . "http://erebos.local:11434")
        (:local . "http://localhost:11434")))

;; ------------------------------
;; llm-chat

(llm-chat-set-platforms llm-api-enabled-platforms)

;; ------------------------------
;; general ai interface

(defun ai-chat (prompt)
  "Send a message to the AI chat."
  (interactive "s> ")
  (llm-chat-msg prompt))

(defun ai-chat-about ()
  "Ask AI about selected region or current buffer."
  (interactive)
  (llm-chat-interactive-chat-about))

(defun ai-clear-history ()
  "Clear the chat history"
  (interactive)
  (llm-chat-clear-history))

(defun ai-kill-process ()
  "Kill the chat process (interrupt generation)"
  (interactive)
  (llm-chat-kill-process))

(defun ai-change-region (change-prompt)
  "Send prompt and region to the AI and replace the region with the results."
  (interactive "s> ")
  (llm-chat-change change-prompt))

(defun ai-select-model ()
  "Select the model (for the active platform)"
  (interactive)
  (llm-chat-select-model))

(defun ai-new-chat (prompt)
  "Clear history and starts a new thread."
  (interactive "s> ")
  (ai-clear-history)
  (ai-chat prompt))

;; keybindings
(map!
 :in "C-c a" #'ai-chat
 :in "C-c C-a" #'ai-new-chat
 :in "C-c s" #'ai-chat-about
 :in "C-c r" #'ai-change-region
 :in "C-c l" #'ai-select-model
 :in "C-c c" #'ai-clear-history
 :in "C-c k" #'ai-kill-process
 :in "C-c p" #'set-ai-provider
 :in "C-c C-s" #'llm-chat-set-system-prompt
 :in "C-c C-." #'llm-chat-show-system-prompt
 :in "C-c C-p" #'llm-chat-select-platform
 :in "C-c C-t" #'llm-chat-set-temperature)

emacs-llm-chat's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.