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

Adding Cerebras support #372

Merged
merged 2 commits into from
Sep 5, 2024
Merged
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
37 changes: 37 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ gptel is a simple Large Language Model chat client for Emacs, with support for m
| OpenRouter | ✓ | [[https://openrouter.ai/keys][API key]] |
| PrivateGPT | ✓ | [[https://github.com/zylon-ai/private-gpt#-documentation][PrivateGPT running locally]] |
| DeepSeek | ✓ | [[https://platform.deepseek.com/api_keys][API key]] |
| Cerebras | ✓ | [[https://cloud.cerebras.ai/][API key]] |
#+html: </div>

*General usage*: ([[https://www.youtube.com/watch?v=bsRnh_brggM][YouTube Demo]])
Expand Down Expand Up @@ -69,6 +70,7 @@ gptel uses Curl if available, but falls back to url-retrieve to work without ext
- [[#openrouter][OpenRouter]]
- [[#privategpt][PrivateGPT]]
- [[#deepseek][DeepSeek]]
- [[#cerebras][Cerebras]]
- [[#usage][Usage]]
- [[#in-any-buffer][In any buffer:]]
- [[#in-a-dedicated-chat-buffer][In a dedicated chat buffer:]]
Expand Down Expand Up @@ -638,6 +640,41 @@ The above code makes the backend available to select. If you want it to be the

#+end_src

#+html: </details>
#+html: <details><summary>
**** Cerebras
#+html: </summary>

Register a backend with
#+begin_src emacs-lisp
;; Cerebras offers an instant OpenAI compatible API
(gptel-make-openai "Cerebras"
:host "api.cerebras.ai"
:endpoint "/v1/chat/completions"
:stream t ;optionally nil as Cerebras is instant AI
:key "your-api-key" ;can be a function that returns the key
:models '("llama3.1-70b"
"llama3.1-8b"))
#+end_src

You can pick this backend from the menu when using gptel (see [[#usage][Usage]]).

***** (Optional) Set as the default gptel backend

The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the value of =gptel-backend=. Use this instead of the above.
#+begin_src emacs-lisp
;; OPTIONAL configuration
(setq gptel-model "llama3.1-8b"
gptel-backend
(gptel-make-openai "Cerebras"
:host "api.cerebras.ai"
:endpoint "/v1/chat/completions"
:stream nil
:key "your-api-key"
:models '("llama3.1-70b"
"llama3.1-8b")))
#+end_src

#+html: </details>

** Usage
Expand Down
8 changes: 4 additions & 4 deletions gptel.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
;; gptel supports
;;
;; - The services ChatGPT, Azure, Gemini, Anthropic AI, Anyscale, Together.ai,
;; Perplexity, Anyscale, OpenRouter, Groq, PrivateGPT, DeepSeek and Kagi
;; (FastGPT & Summarizer)
;; Perplexity, Anyscale, OpenRouter, Groq, PrivateGPT, DeepSeek, Cerebras and
;; Kagi (FastGPT & Summarizer)
;; - Local models via Ollama, Llama.cpp, Llamafiles or GPT4All
;;
;; Additionally, any LLM service (local or remote) that provides an
Expand Down Expand Up @@ -61,8 +61,8 @@
;; - For Gemini: define a gptel-backend with `gptel-make-gemini', which see.
;; - For Anthropic (Claude): define a gptel-backend with `gptel-make-anthropic',
;; which see
;; - For Together.ai, Anyscale, Perplexity, Groq, OpenRouter or DeepSeek: define
;; a gptel-backend with `gptel-make-openai', which see.
;; - For Together.ai, Anyscale, Perplexity, Groq, OpenRouter, DeepSeek or
;; Cerebras: define a gptel-backend with `gptel-make-openai', which see.
;; - For PrivateGPT: define a backend with `gptel-make-privategpt', which see.
;; - For Kagi: define a gptel-backend with `gptel-make-kagi', which see.
;;
Expand Down