Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Fix session repo reading

Tomas Valentadac269c50ab8
diff --git a/api-service/agent/basic_agent.py b/api-service/agent/basic_agent.py
index 46d1ec458..9c3431caf 100644
--- a/api-service/agent/basic_agent.py
+++ b/api-service/agent/basic_agent.py
@@ -5,7 +5,7 @@ import chevron
# Monkey patch chevron to not escape html
chevron.render.__globals__["_html_escape"] = lambda string: string
-from typing import Any, Dict, List, Literal, cast
+from typing import Any, Dict, List, Literal, Tuple, cast
from langchain.agents.tools import InvalidTool
from langchain.callbacks.base import AsyncCallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
@@ -187,7 +187,10 @@ class BasicAgent(AgentBase):
verbose=True,
)
- repo_files = await playground.get_files("/code", ["node_modules"])
+ repo_files: List[Tuple[str, str]] = []
+ async for file in playground.get_files("/code", ["node_modules"]):
+ repo_files.append(file)
+
vectordb = await get_memory(self.config, repo_files)
async def get_repo_context(prompt: str):
diff --git a/api-service/playground/src/sessions/filesystemController.ts b/api-service/playground/src/sessions/filesystemController.ts
index aadd5be71..ecc09bde8 100644
--- a/api-service/playground/src/sessions/filesystemController.ts
+++ b/api-service/playground/src/sessions/filesystemController.ts
@@ -27,20 +27,13 @@ export class FilesystemController extends Controller {
@Path() sessionID: string,
@Query() path: string,
): Promise<ListFilesystemDirResponse> {
- try {
- const entries = await CachedSession
- .findSession(sessionID)
- .session
- .filesystem!
- .list(path)
- return {
- entries,
- }
- } catch (error) {
- console.error(error)
- return {
- entries: [],
- }
+ const entries = await CachedSession
+ .findSession(sessionID)
+ .session
+ .filesystem!
+ .list(path)
+ return {
+ entries,
}
}
@@ -73,20 +66,13 @@ export class FilesystemController extends Controller {
@Path() sessionID: string,
@Query() path: string,
): Promise<ReadFilesystemFileResponse> {
- try {
- const content = await CachedSession
- .findSession(sessionID)
- .session
- .filesystem!
- .read(path)
- return {
- content,
- }
- } catch (error) {
- console.error(error)
- return {
- content: '',
- }
+ const content = await CachedSession
+ .findSession(sessionID)
+ .session
+ .filesystem!
+ .read(path)
+ return {
+ content,
}
}
diff --git a/api-service/session/playground/base.py b/api-service/session/playground/base.py
index 3521a5c37..78ecede4b 100644
--- a/api-service/session/playground/base.py
+++ b/api-service/session/playground/base.py
@@ -1,11 +1,8 @@
import math
-from typing import Any, Coroutine, List, Tuple
+from typing import Any, List
from asyncio import sleep
-from pydantic import StrictStr
-
-
from playground_client.models.entry_info import EntryInfo
from playground_client.models.list_filesystem_dir_response import (
ListFilesystemDirResponse,
@@ -62,15 +59,23 @@ class Playground(Session):
dir = dirs.pop()
entries = await self.list_dir(dir.name)
dirs.extend(
- entry for entry in entries if entry.is_dir and not entry.name in ignore
+ EntryInfo(isDir=True, name=f"{dir.name}/{entry.name}")
+ for entry in entries
+ if entry.is_dir and not entry.name in ignore
)
files.extend(
- entry
+ EntryInfo(isDir=False, name=f"{dir.name}/{entry.name}")
for entry in entries
if not entry.is_dir and not entry.name in ignore
)
- return [(entry.name, await self.read_file(entry.name)) for entry in files]
+ for file in files:
+ try:
+ content = await self.read_file(file.name)
+ yield (file.name, content)
+ except:
+ print("Skipping file", file.name)
+ continue
async def run_command(
self,