From 23a49b6b951d33197a6c65b50e01faa1c58aad9b Mon Sep 17 00:00:00 2001 From: sabaimran Date: Fri, 1 Nov 2024 12:14:33 -0700 Subject: [PATCH] Add documentation for python code execution capability --- documentation/docs/features/chat.md | 3 ++ documentation/docs/features/code_execution.md | 30 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 documentation/docs/features/code_execution.md diff --git a/documentation/docs/features/chat.md b/documentation/docs/features/chat.md index 86c72098..a438bf5f 100644 --- a/documentation/docs/features/chat.md +++ b/documentation/docs/features/chat.md @@ -43,3 +43,6 @@ Slash commands allows you to change what Khoj uses to respond to your query - **/image**: Generate an image in response to your query. - **/help**: Use /help to get all available commands and general information about Khoj - **/summarize**: Can be used to summarize 1 selected file filter for that conversation. Refer to [File Summarization](summarization) for details. +- **/diagram**: Generate a diagram in response to your query. This is built on [Excalidraw](https://excalidraw.com/). +- **/code**: Generate and run very simple Python code snippets. Refer to [Code Generation](code_generation) for details. +- **/research**: Go deeper in a topic for more accurate, in-depth responses. diff --git a/documentation/docs/features/code_execution.md b/documentation/docs/features/code_execution.md new file mode 100644 index 00000000..8403d466 --- /dev/null +++ b/documentation/docs/features/code_execution.md @@ -0,0 +1,30 @@ +--- +--- + +# Code Execution + +Khoj can generate and run very simple Python code snippets as well. This is useful if you want to generate a plot, run a simple calculation, or do some basic data manipulation. LLMs by default aren't skilled at complex quantitative tasks. Code generation & execution can come in handy for such tasks. + +Just use `/code` in your chat command. + +### Setup (Self-Hosting) +Run [Cohere's Terrarium](https://github.com/cohere-ai/cohere-terrarium) on your machine to enable code generation and execution. + +Check the [instructions](https://github.com/cohere-ai/cohere-terrarium?tab=readme-ov-file#development) for running from source. + +For running with Docker, you can use our [docker-compose.yml](https://github.com/khoj-ai/khoj/blob/master/docker-compose.yml), or start it manually like this: + +```bash +docker pull ghcr.io/khoj-ai/terrarium:latest +docker run -d -p 8080:8080 ghcr.io/khoj-ai/terrarium:latest +``` + +#### Verify +Verify that it's running, by evaluating a simple Python expression: + +```bash +curl -X POST -H "Content-Type: application/json" \ +--url http://localhost:8080 \ +--data-raw '{"code": "1 + 1"}' \ +--no-buffer +```