Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Merge branch 'openai' into production
Tomas Valenta9c83466c619e
diff --cc api-service/agent/smol_agent.pyindex 246f282cb,af40e56cb..fd1fec744--- a/api-service/agent/smol_agent.py+++ b/api-service/agent/smol_agent.py@@@ -319,67 -239,40 +327,74 @@@ Exclusively focus on the names of the suser_prompt,)+ await self.on_logs(+ {+ "message": f"Generated shared dependencies",+ "properties": {+ "result": shared_dependencies,+ "model": "gpt-4",+ },+ "type": "model",+ }+ )+- print(shared_dependencies)# write shared dependencies as a md file inside the generated directoryawait playground.write_file(os.path.join(rootdir, "shared_dependencies.md"),shared_dependencies,)+ await self.on_logs(+ {+ "message": f"Saved shared dependencies",+ "properties": {+ "filename": "shared_dependencies.md",+ "content": shared_dependencies,+ "tool": "filesystem",+ },+ "type": "tool",+ }+ )+ # Maximum number of allowed concurrent calls+ semaphore = asyncio.Semaphore(3)++ async def with_semaphore(coro):+ async with semaphore:+ return await coro# execute the file generation in paralell and wait for all of them to finish. Use list comprehension to generate the tasks- tasks = [- generate_file(- name,- filepaths_string=filepaths_string,- shared_dependencies=shared_dependencies,- prompt=user_prompt,+ coros = [+ with_semaphore(+ generate_file(+ name,+ filepaths_string=filepaths_string,+ shared_dependencies=shared_dependencies,+ prompt=user_prompt,+ ))for name in list_actual- # Filter out files that end with extensions we don't want to generate+ # Filter out files that end with esxtensions we don't want to generateif not any(name.endswith(extension) for extension in extensions_to_skip)]- generated_files = await asyncio.gather(*tasks)+ generated_files = await asyncio.gather(*coros)for name, content in generated_files:- await playground.write_file(os.path.join(rootdir, name), content)+ filepath = os.path.join(rootdir, name)+ await playground.write_file(filepath, content)+ await self.on_logs(+ {+ "message": f"Saved file",+ "properties": {+ "filename": filepath,+ "content": content,+ "tool": "filesystem",+ },+ "type": "tool",+ }+ )await fixClockDriftawait playground.push_repo(@@@ -416,19 -295,10 +431,19 @@@raisefinally:if playground is not None:-- playground.close()++ await playground.close()+ await self.on_logs(+ {+ "message": f"Closed playground",+ "properties": {+ "playground": "closed",+ },+ "type": "playground",+ }+ )async def _dev_in_background(self, instructions: Any):- print("Start agent run", self._dev_loop)+ print("Start agent run", bool(self._dev_loop))if self._dev_loop:print("Agent run already in progress - restarting")diff --cc pages/agent/smol-developer/setup.tsxindex cdd37ae32,ec5f52839..95c50d683--- a/pages/agent/smol-developer/setup.tsx+++ b/pages/agent/smol-developer/setup.tsx@@@ -143,42 -136,22 +143,33 @@@ function Setup()console.error('No instructions provided')return}- if (!openAIAPIKey) {- console.error('No OpenAI API key provided')- return- }+ console.log('DEPLOY AGENT', selectedRepository, instructions)- const modelConfig = getSmolDevModelConfig({- OpenAI: {- creds: {- openai_api_key: openAIAPIKey,- },- },- })+ const modelConfig = getSmolDevModelConfig({})- await createAgent({- defaultBranch: selectedRepository.defaultBranch,- installationID: selectedRepository.installationID,- owner: selectedRepository.owner,- repo: selectedRepository.repo,- repositoryID: selectedRepository.repositoryID,- title: 'Smol PR',- branch: `pr/smol-dev/${nanoid(6).toLowerCase()}`,- body: instructions,- commitMessage: 'Smol dev initial commit',- modelConfig,- })+ try {+ setIsDeploying(true)+ const response = await createAgent({+ defaultBranch: selectedRepository.defaultBranch,+ installationID: selectedRepository.installationID,+ owner: selectedRepository.owner,+ repo: selectedRepository.repo,+ repositoryID: selectedRepository.repositoryID,+ title: 'Smol PR',+ branch: `pr/smol-dev/${nanoid(6).toLowerCase()}`,+ body: instructions,+ commitMessage: 'Smol dev initial commit',+ modelConfig,+ })+ // Redirect to the dashboard.+ if (response) {+ router.push(`/${response.projectID}`)+ } else {+ console.error('No response from agent creation')+ }+ } finally {+ setIsDeploying(false)+ }}function nextStep() {