Devika is the first open-source implementation of an Agentic Software Engineer. Initially started as an open-source alternative to Devin.
Python
Feature: Custom OpenAI API Endpoints (#442)
Wickes Wong4885f75551de
diff --git a/README.md b/README.mdindex 0f5717b..c5cbd83 100644--- a/README.md+++ b/README.md@@ -147,7 +147,7 @@ when you first time run Devika, it will create a `config.toml` file for you in t- `BING`: The Bing API endpoint for web searching.- `GOOGLE`: The Google API endpoint for web searching.- `OLLAMA`: The Ollama API endpoint for accessing Local LLMs.-+ - `OPENAI`: The OpenAI API endpoint for accessing OpenAI models.Make sure to keep your API keys secure and do not share them publicly. For setting up the Bing and Google search API keys, follow the instructions in the [search engine setup](docs/Installation/search_engine.md)diff --git a/sample.config.toml b/sample.config.tomlindex 0a09258..694d2e7 100644--- a/sample.config.toml+++ b/sample.config.toml@@ -21,6 +21,7 @@ NETLIFY = "<YOUR_NETLIFY_API_KEY>"BING = "https://api.bing.microsoft.com/v7.0/search"GOOGLE = "https://www.googleapis.com/customsearch/v1"OLLAMA = "http://127.0.0.1:11434"+OPENAI = "https://api.openai.com"[LOGGING]LOG_REST_API = "true"diff --git a/src/config.py b/src/config.pyindex 3b1ab35..d804a8c 100644--- a/src/config.py+++ b/src/config.py@@ -27,7 +27,7 @@ class Config:def get_bing_api_key(self):return self.config["API_KEYS"]["BING"]-+def get_google_search_api_key(self):return self.config["API_KEYS"]["GOOGLE_SEARCH"]@@ -36,7 +36,7 @@ class Config:def get_google_search_api_endpoint(self):return self.config["API_ENDPOINTS"]["GOOGLE"]-+def get_ollama_api_endpoint(self):return self.config["API_ENDPOINTS"]["OLLAMA"]@@ -46,6 +46,9 @@ class Config:def get_openai_api_key(self):return self.config["API_KEYS"]["OPENAI"]+ def get_openai_api_base_url(self):+ return self.config["API_ENDPOINTS"]["OPENAI"]+def get_gemini_api_key(self):return self.config["API_KEYS"]["GEMINI"]@@ -114,6 +117,10 @@ class Config:self.config["API_KEYS"]["OPENAI"] = keyself.save_config()+ def set_openai_api_endpoint(self,endpoint):+ self.config["API_ENDPOINTS"]["OPENAI"] = endpoint+ self.save_config()+def set_gemini_api_key(self, key):self.config["API_KEYS"]["GEMINI"] = keyself.save_config()diff --git a/src/llm/openai_client.py b/src/llm/openai_client.pyindex 4803e28..b6cfe20 100644--- a/src/llm/openai_client.py+++ b/src/llm/openai_client.py@@ -7,7 +7,8 @@ class OpenAi:def __init__(self):config = Config()api_key = config.get_openai_api_key()- self.client = OpenAI(api_key=api_key)+ base_url = config.get_openai_api_base_url()+ self.client = OpenAI(api_key=api_key, base_url=base_url)def inference(self, model_id: str, prompt: str) -> str:chat_completion = self.client.chat.completions.create(