Skip to content

Commit

Permalink
doc: updating README
Browse files Browse the repository at this point in the history
- update README with the new functionalities
- update the demo gif with the new functionalities
- update function docstrings to fix melpazoid checks
- fix payload function verification to take into account the new rag api_key
  • Loading branch information
SamuelVanie committed Feb 7, 2024
1 parent 1919672 commit f4e2546
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Pretty neat alternative to eww in emacs.

## ❓ Why?

I wanted to use Youdotcom search engine from Emacs, so I wrote this package.
The You API is very simple and cheap to use, so I thought it would be an alternative for people who still want to use a search engine instead of chatbots.
I wanted to use Youdotcom engine directly in Emacs, so I wrote this package.
The You API is very simple, so I thought it would be an alternative for people who want to use a search engine boosted by AI directly in Emacs.
You will no more need to filter the results by yourself on the web and directly get the results inside of Emacs without leaving it.

You can also use it as a simple web browser, but this is not the spirit of an emacs user, right ?
Expand All @@ -43,35 +43,40 @@ You can also use it as a simple web browser, but this is not the spirit of an em

### MELPA

To be done...

```elisp
(use-package youdotcom
:bind ("C-c y" . youdotcom-enter))
```

## 🔑 Obtaining an API key

You need to obtain an API key from [You.com](https://api.you.com/).
Go to that website and get the Web Search API key, the Web LLM integration is not yet supported (I'm planning to add it in the future).
Go to that website and get the Web Search API key, and the Web LLM API key is you want to use the RAG LLM model.


## 💻 Usage

You will have to set the API key in your init file:

```elisp
(setq youdotcom-api-key "YOUR_API_KEY")
(setq youdotcom-search-api-key "YOUR_API_KEY")
(setq youdotcom-rag-api-key "YOUR_API_KEY")
```

Then you can use the following commands:

- `youdotcom-enter` : Will start the client and open the prompt for you to enter your query.
You can setup a keybinding for this command. (e.g. `(global-set-key (kbd "C-c y") 'youdotcom-enter)`)
You can setup a keybinding for this command. (e.g. `(global-set-key (kbd "C-c y") 'youdotcom-enter)`) or use the one provided in the use-package installation process.

In the prompt, you can use the following commands:

- `/help` : Will display the help message.
- `/clear` : Will clear the buffer.
- `/quit` : Stop the search engine's session and close the buffer.
- `/search <query>` : Will start the search with the query you entered. The results will be displayed in the buffer, each results will have a description and the URL associated with it.
- `/rag <query>` : Will start the search with the query you entered using the RAG LLM model. Using AI, the results will be done by the engine on the internet, analyzed and an answer will be given to you.

*NB: You can change the number of results displayed by changing the variable `youdotcom-number-of-results` (default is 1).*
*NB: You can change the number of results displayed by the search command by changing the variable `youdotcom-number-of-results` (default is 1).*

## 👊 Contributing

Expand Down
Binary file modified demo_2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions youdotcom.el
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@

(defun youdotcom-verify-payload ()
"Verify that the payload is valid."
(unless (and (not (string-empty-p youdotcom-search-api-key))
(unless (and (or (not (string-empty-p youdotcom-search-api-key))
(not (string-empty-p youdotcom-rag-api-key)))
(not (string-empty-p youdotcom-base-api-endpoint))
(> youdotcom-number-of-results 0))
(error "Invalid arguments or global variables")))

(defun youdotcom-send-request (query type callback)
"Send a request to the You.com's API with the given QUERY and CALLBACK."
"Send a request of TYPE to the API with the given QUERY and CALLBACK."
(youdotcom-verify-payload)
(let ((url-request-method "GET")
(url-request-extra-headers
Expand All @@ -94,6 +95,7 @@
(add-face-text-property current-point (point-max) '(:foreground "red")))
(dolist (message messages)
(insert (youdotcom-format-message message)))
(insert "\n")
(goto-char (point-min))))

(defun youdotcom-parse-response (json type)
Expand Down Expand Up @@ -151,7 +153,7 @@
(youdotcom-format-answer content response)))

(defun youdotcom-send-message (content type)
"Send a message with CONTENT and display the response."
"Send a message with CONTENT and display the response depending on TYPE."
(youdotcom-send-request content type #'youdotcom-handle-response))


Expand Down

0 comments on commit f4e2546

Please sign in to comment.