Devika is the first open-source implementation of an Agentic Software Engineer. Initially started as an open-source alternative to Devin.
Python
Merge branch 'main' into prompts-logging
Mufeed VH4a470de7e86d
diff --cc config.tomlindex a898fd1,92273c6..6ed3682--- a/config.toml+++ b/config.toml@@@ -14,7 -15,4 +15,8 @@@ GROQ = "<YOUR_GROQ_API_KEY>[API_ENDPOINTS]BING = "https://api.bing.microsoft.com/v7.0/search"+ OLLAMA = "http://127.0.0.1:11434"++[LOGGING]+LOG_REST_API = "true"- LOG_PROMPTS = "false"++LOG_PROMPTS = "false"diff --cc src/config.pyindex 41be3ff,e324f1c..063ae8b--- a/src/config.py+++ b/src/config.py@@@ -1,6 -1,17 +1,16 @@@import toml+ from os import environ+class Config:-+ _instance = None++ def __new__(cls):+ if cls._instance is None:+ cls._instance = super().__new__(cls)+ cls._instance.config = toml.load("config.toml")+ return cls._instance+def __init__(self):self.config = toml.load("config.toml")@@@ -8,44 -19,46 +18,52 @@@return self.configdef get_bing_api_key(self):- return self.config["API_KEYS"]["BING"]-+ return environ.get("BING_API_KEY", self.config["API_KEYS"]["BING"])+def get_bing_api_endpoint(self):- return self.config["API_ENDPOINTS"]["BING"]-+ return environ.get("BING_API_ENDPOINT", self.config["API_ENDPOINTS"]["BING"])++ def get_ollama_api_endpoint(self):+ return environ.get(+ "OLLAMA_API_ENDPOINT", self.config["API_ENDPOINTS"]["OLLAMA"]+ )+def get_claude_api_key(self):- return self.config["API_KEYS"]["CLAUDE"]-+ return environ.get("CLAUDE_API_KEY", self.config["API_KEYS"]["CLAUDE"])+def get_openai_api_key(self):- return self.config["API_KEYS"]["OPENAI"]-+ return environ.get("OPENAI_API_KEY", self.config["API_KEYS"]["OPENAI"])+def get_netlify_api_key(self):- return self.config["API_KEYS"]["NETLIFY"]+ return environ.get("NETLIFY_API_KEY", self.config["API_KEYS"]["NETLIFY"])+ def get_groq_api_key(self):+ return environ.get("GROQ_API_KEY", self.config["API_KEYS"]["GROQ"])+def get_sqlite_db(self):- return self.config["STORAGE"]["SQLITE_DB"]-+ return environ.get("SQLITE_DB_PATH", self.config["STORAGE"]["SQLITE_DB"])+def get_screenshots_dir(self):- return self.config["STORAGE"]["SCREENSHOTS_DIR"]-+ return environ.get("SCREENSHOTS_DIR", self.config["STORAGE"]["SCREENSHOTS_DIR"])+def get_pdfs_dir(self):- return self.config["STORAGE"]["PDFS_DIR"]-+ return environ.get("PDFS_DIR", self.config["STORAGE"]["PDFS_DIR"])+def get_projects_dir(self):- return self.config["STORAGE"]["PROJECTS_DIR"]-+ return environ.get("PROJECTS_DIR", self.config["STORAGE"]["PROJECTS_DIR"])+def get_logs_dir(self):- return self.config["STORAGE"]["LOGS_DIR"]-+ return environ.get("LOGS_DIR", self.config["STORAGE"]["LOGS_DIR"])+def get_repos_dir(self):- return self.config["STORAGE"]["REPOS_DIR"]+ return environ.get("REPOS_DIR", self.config["STORAGE"]["REPOS_DIR"])+ def get_logging_rest_api(self):+ return self.config["LOGGING"]["LOG_REST_API"] == "true"++ def get_logging_prompts(self):+ return self.config["LOGGING"]["LOG_PROMPTS"] == "true"+def set_bing_api_key(self, key):self.config["API_KEYS"]["BING"] = keyself.save_config()diff --cc src/llm/llm.pyindex be292bd,626b43d..bf04bb8--- a/src/llm/llm.py+++ b/src/llm/llm.py@@@ -25,16 -25,13 +29,17 @@@ class Model(Enum))for model in Ollama.list_models()]+ GROQ = ("GROQ Mixtral", "mixtral-8x7b-32768")++logger = Logger(filename="devika_prompts.log")+class LLM:def __init__(self, model_id: str = None):self.model_id = model_id+ self.log_prompts = Config().get_logging_prompts()-- def list_models(self) -> list[tuple[str, str]]:++ def list_models(self) -> List[Tuple[str, str]]:return [model.value for model in Model if model.name != "OLLAMA_MODELS"] + list(Model.OLLAMA_MODELS.value)@@@ -69,9 -64,6 +75,9 @@@else:raise ValueError(f"Model {model} not supported")+ if self.log_prompts:+ logger.debug(f"Response ({model}): --> {response}")+- self.update_global_token_usage(response)+ self.update_global_token_usage(response, project_name)return response