Skip to content

Commit

Permalink
Update: README and config
Browse files Browse the repository at this point in the history
  • Loading branch information
ARajgor committed Mar 31, 2024
2 parents 7cd567b + f0f33b2 commit b17ad66
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 201 deletions.
44 changes: 29 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ The easiest way to run the project locally:

1. Install `uv` - Python Package manager (https://github.com/astral-sh/uv)
2. Install `bun` - JavaScript runtime (https://bun.sh/docs/installation)
3. Install and setup `Ollama` (https://ollama.com/)
3. Install and setup `Ollama` (https://ollama.com/) (if you want don't want to use the local models then you can skip this step)

For ollama you need to install the [models](https://ollama.com/models)
For ollama you need to install the [models](https://ollama.com/models)<br>
For API models, configure the API keys in the `config.toml` file. For this, we provide `sample.config.toml` <br><br>
create and set the API Keys in the `config.toml` file. (This will soon be moving to the UI where you can set these keys from the UI itself without touching the command-line, want to implement it? See this issue: https://github.com/stitionai/devika/issues/3)
create and set the API Keys in the `config.toml` file. you can also set the API keys via the settings page in the UI.<br>

Then execute the following set of command:

Expand Down Expand Up @@ -124,7 +124,7 @@ To install Devika, follow these steps:
pip install -r requirements.txt
playwright install --with-deps # installs browsers in playwright (and their deps) if required
```
5. Set up the necessary API keys and configuration (see [Configuration](#configuration) section).
5. Set up the necessary API keys and [Configuration](#configuration)
6. Start the Devika server:
```bash
python devika.py
Expand Down Expand Up @@ -152,19 +152,33 @@ To start using Devika, follow these steps:

## Configuration

Devika requires certain configuration settings and API keys to function properly. use the `sample.config.toml` file with the following information:
Devika requires certain configuration settings and API keys to function properly. use the `sample.config.toml` file and create `config.toml`:

- STORAGE
- `SQLITE_DB`: The path to the SQLite database file for storing Devika's data.
- `SCREENSHOTS_DIR`: The directory where screenshots captured by Devika will be stored.
- `PDFS_DIR`: The directory where PDF files processed by Devika will be stored.
- `PROJECTS_DIR`: The directory where Devika's projects will be stored.
- `LOGS_DIR`: The directory where Devika's logs will be stored.
- `REPOS_DIR`: The directory where Git repositories cloned by Devika will be stored.
- `WEB_SEARCH`: This determines the default web search method for browsing the web. Accepted values are: google, bing, or ddgs.

- API KEYS
- `BING`: Your Bing Search API key for web searching capabilities.
- `GOOGLE_SEARCH`: Your Google Search API key for web searching capabilities.
- `GOOGLE_SEARCH_ENGINE_ID`: Your Google Search Engine Id for web searching using google.
- `OPENAI`: Your OpenAI API key for accessing GPT models.
- `GEMINI`: Your Gemini API key for accessing Gemini models.
- `CLAUDE`: Your Anthropic API key for accessing Claude models.
- `MISTRAL`: Your Mistral API key for accessing Mistral models.
- `GROQ`: Your Groq API key for accessing Groq models.
- `NETLIFY`: Your Netlify API key for deploying and managing web projects.

Make sure to keep your API keys secure and do not share them publicly.

- create a `config.toml` file in the root directory of the project.
- `OPENAI_API_KEY`: Your OpenAI API key for accessing GPT models.
- `CLAUDE_API_KEY`: Your Anthropic API key for accessing Claude models.
- `GEMINI_API_KEY`: Your Gemini API key for accessing Gemini models.
- `MISTRAL_API_KEY`: Your Mistral API key for accessing Mistral models.
- `BING_API_KEY`: Your Bing Search API key for web searching capabilities.
- `DATABASE_URL`: The URL for your database connection.
- `LOG_DIRECTORY`: The directory where Devika's logs will be stored.
- `PROJECT_DIRECTORY`: The directory where Devika's projects will be stored.
### Configuring web search method

Make sure to keep your API keys secure and do not share them publicly.
Devika currently supports Bing, Google, and DuckDuckGo for web searches. You can configure the web search method via UI.

## Under The Hood

Expand Down
5 changes: 2 additions & 3 deletions sample.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ PDFS_DIR = "data/pdfs"
PROJECTS_DIR = "data/projects"
LOGS_DIR = "data/logs"
REPOS_DIR = "data/repos"
WEB_SEARCH = "ddgs"

[API_KEYS]
NETLIFY = "<YOUR_NETLIFY_API_KEY>"
BING = "<YOUR_BING_API_KEY>"
GOOGLE = "<YOUR_GOOGLE_SEARCH_API_KEY>"
GOOGLE_SEARCH = "<YOUR_GOOGLE_SEARCH_API_KEY>"
GOOGLE_SEARCH_ENGINE_ID = "<YOUR_GOOGLE_SEARCH_ENGINE_ID>"
CLAUDE = "<YOUR_CLAUDE_API_KEY>"
OPENAI = "<YOUR_OPENAI_API_KEY>"
GEMINI = "<YOUR_GEMINI_API_KEY>"
MISTRAL = "<YOUR_MISTRAL_API_KEY>"
GROQ = "<YOUR_GROQ_API_KEY>"
NETLIFY = "<YOUR_NETLIFY_API_KEY>"

[API_ENDPOINTS]
BING = "https://api.bing.microsoft.com/v7.0/search"
Expand Down
19 changes: 10 additions & 9 deletions src/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import toml
from os import environ
import os


class Config:
Expand All @@ -8,9 +8,17 @@ class Config:
def __new__(cls):
if cls._instance is None:
cls._instance = super().__new__(cls)
cls._instance.config = toml.load("config.toml")
cls._instance._load_config()
return cls._instance

def _load_config(self):
# If the config file doesn't exist, copy from the sample
if not os.path.exists("config.toml"):
with open("sample.config.toml", "r") as f_in, open("config.toml", "w") as f_out:
f_out.write(f_in.read())

self.config = toml.load("config.toml")

def get_config(self):
return self.config

Expand Down Expand Up @@ -68,9 +76,6 @@ def get_logs_dir(self):
def get_repos_dir(self):
return self.config["STORAGE"]["REPOS_DIR"]

def get_web_search(self):
return self.config["STORAGE"]["WEB_SEARCH"]

def get_logging_rest_api(self):
return self.config["LOGGING"]["LOG_REST_API"] == "true"

Expand Down Expand Up @@ -157,10 +162,6 @@ def set_logging_prompts(self, value):
self.config["LOGGING"]["LOG_PROMPTS"] = "true" if value else "false"
self.save_config()

def set_web_search(self, value):
self.config["STORAGE"]["WEB_SEARCH"] = value
self.save_config()

def save_config(self):
with open("config.toml", "w") as f:
toml.dump(self.config, f)
174 changes: 0 additions & 174 deletions test.py

This file was deleted.

12 changes: 12 additions & 0 deletions ui/src/routes/settings/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
onMount(async () => {
settings = await fetchSettings();
// this is for correcting order of apis shown in the settings page
settings["API_KEYS"] = {
"BING": settings["API_KEYS"]["BING"],
"GOOGLE_SEARCH": settings["API_KEYS"]["GOOGLE_SEARCH"],
"GOOGLE_SEARCH_ENGINE_ID": settings["API_KEYS"]["GOOGLE_SEARCH_ENGINE_ID"],
"CLAUDE": settings["API_KEYS"]["CLAUDE"],
"OPENAI": settings["API_KEYS"]["OPENAI"],
"GEMINI": settings["API_KEYS"]["GEMINI"],
"MISTRAL": settings["API_KEYS"]["MISTRAL"],
"GROQ": settings["API_KEYS"]["GROQ"],
"NETLIFY": settings["API_KEYS"]["NETLIFY"]
};
// make a copy of the original settings
original = JSON.parse(JSON.stringify(settings));
Expand Down

0 comments on commit b17ad66

Please sign in to comment.