Devika is the first open-source implementation of an Agentic Software Engineer. Initially started as an open-source alternative to Devin.
Python
added support for google search api, corrected set_gemini_api_key
nalaso91257612daa5
diff --git a/config.toml b/config.tomlindex 0deafc7..3a83c7a 100644--- a/config.toml+++ b/config.toml@@ -8,6 +8,8 @@ REPOS_DIR = "repos"[API_KEYS]BING = "<YOUR_BING_API_KEY>"+GOOGLE_SEARCH = "<YOUR_GOOGLE_SEARCH_API_KEY>"+GOOGLE_SEARCH_ENGINE_ID = "<YOUR_GOOGLE_SEARCH_ENGINE_ID>"CLAUDE = "<YOUR_CLAUDE_API_KEY>"NETLIFY = "<YOUR_NETLIFY_API_KEY>"OPENAI = "<YOUR_OPENAI_API_KEY>"@@ -15,3 +17,4 @@ GEMINI = "<YOUR_GEMINI_API_KEY>"[API_ENDPOINTS]BING = "https://api.bing.microsoft.com/v7.0/search"+GOOGLE_SEARCH = "https://www.googleapis.com/customsearch/v1"\ No newline at end of filediff --git a/src/agents/agent.py b/src/agents/agent.pyindex 37b6cdb..9158164 100644--- a/src/agents/agent.py+++ b/src/agents/agent.py@@ -17,7 +17,7 @@ from src.state import AgentStatefrom src.bert.sentence import SentenceBertfrom src.memory import KnowledgeBase-from src.browser.search import BingSearch,DuckDuckGoSearch+from src.browser.search import BingSearch,DuckDuckGoSearch,GoogleSearchfrom src.browser import Browserfrom src.browser import start_interactionfrom src.filesystem import ReadCode@@ -64,7 +64,8 @@ class Agent:knowledge_base = KnowledgeBase()# web_search = BingSearch()- web_search = DuckDuckGoSearch()+ # web_search = DuckDuckGoSearch()+ web_search = GoogleSearch()browser = Browser()for query in queries:diff --git a/src/browser/search.py b/src/browser/search.pyindex 41954db..172e2ab 100644--- a/src/browser/search.py+++ b/src/browser/search.py@@ -1,7 +1,6 @@import requestsfrom src.config import Configfrom duckduckgo_search import DDGS-class BingSearch:def __init__(self):self.config = Config()@@ -33,4 +32,30 @@ class DuckDuckGoSearch:return errdef get_first_link(self):- return self.query_result[0]["href"]\ No newline at end of file+ return self.query_result[0]["href"]++class GoogleSearch:+ def __init__(self):+ self.config = Config()+ self.google_search_api_key = self.config.get_google_search_api_key()+ self.google_search_engine_ID = self.config.get_google_search_engine_id()+ self.google_search_api_endpoint = self.config.get_google_search_api_endpoint()+ self.query_result = None++ def search(self, query):+ try:+ params = {+ 'q': query,+ 'key': self.google_search_api_key,+ 'cx': self.google_search_engine_ID+ }+ response = requests.get(self.google_search_api_endpoint, params=params)+ self.query_result = response.json()+ except Exception as err:+ return err++ def get_first_link(self):+ item = ""+ if 'items' in self.query_result:+ item = self.query_result['items'][0]['link']+ return item\ No newline at end of filediff --git a/src/config.py b/src/config.pyindex c594957..ae10151 100644--- a/src/config.py+++ b/src/config.py@@ -13,6 +13,15 @@ class Config:def get_bing_api_endpoint(self):return self.config["API_ENDPOINTS"]["BING"]+ def get_google_search_api_key(self):+ return self.config["API_KEYS"]["GOOGLE_SEARCH"]++ def get_google_search_engine_id(self):+ return self.config["API_KEYS"]["GOOGLE_SEARCH_ENGINE_ID"]++ def get_google_search_api_endpoint(self):+ return self.config["API_ENDPOINTS"]["GOOGLE_SEARCH"]+def get_claude_api_key(self):return self.config["API_KEYS"]["CLAUDE"]@@ -50,6 +59,18 @@ class Config:def set_bing_api_endpoint(self, endpoint):self.config["API_ENDPOINTS"]["BING"] = endpointself.save_config()++ def set_google_search_api_key(self, key):+ self.config["API_KEYS"]["GOOGLE_SEARCH"] = key+ self.save_config()++ def set_google_search_engine_id(self, key):+ self.config["API_KEYS"]["GOOGLE_SEARCH_ENGINE_ID"] = key+ self.save_config()++ def set_google_search_api_endpoint(self, endpoint):+ self.config["API_ENDPOINTS"]["GOOGLE_SEARCH"] = endpoint+ self.save_config()def set_claude_api_key(self, key):self.config["API_KEYS"]["CLAUDE"] = key@@ -59,7 +80,7 @@ class Config:self.config["API_KEYS"]["OPENAI"] = keyself.save_config()- def set_openai_api_key(self, key):+ def set_gemini_api_key(self, key):self.config["API_KEYS"]["GEMINI"] = keyself.save_config()