Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Fix init repo error [WIP]

Tomas Valentae940f41e2691
diff --git a/components/Repos.tsx b/components/Repos.tsx
index 5e534f849..866bfa10b 100644
--- a/components/Repos.tsx
+++ b/components/Repos.tsx
@@ -55,6 +55,8 @@ function Repos({ onRepoSelection }: Props) {
}, [refetch, setAccessToken])
useListenOnMessage(handleEvent)
+ console.log(repos)
+
async function selectRepository(r: Omit<RepoSetup, 'branches' | 'owner' | 'repo'>) {
const { owner, repo } = parseRepoName(r.fullName)
diff --git a/example_config.json b/example_config.json
deleted file mode 100644
index 7c595dbea..000000000
--- a/example_config.json
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "name": "GPT 3.5 Turbo",
- "provider": "OpenAI",
- "args": {
- "model_name": "gpt-3.5-turbo",
- "max_tokens": 2048,
- "temperature": 0,
- "presence_penalty": 0,
- "frequency_penalty": 0,
- "top_p": 1,
- "openai_api_key": ""
- },
- "prompt": [
- {
- "role": "system",
- "type": "prefix",
- "content": "\nYou are an AI JavaScript developer assistant:\nYou are building an Express server that handles REST API.\nThe `express` package is already installed.\nFollow the user's instructions carefully & to the letter.\nMinimize any other prose.\nYou have access to the following tools:"
- },
- {
- "role": "system",
- "type": "suffix",
- "content": "\nThe way you use the tools is by specifying a XML snippet.\nThe XML snippet MUST have a `<action tool=\"$TOOL_NAME\">$INPUT</action>` element with the name of the tool in the `tool` attribute and input for the tool inside the XML tag.\n\nHere is an example of a valid XML snippet:\n<action tool=\"$TOOL_NAME\">\n$INPUT\n</action>\n\nALWAYS use the following format:\nThought: you should always think about what to do\nAction:\n<action tool=\"$TOOL_NAME\">\n$INPUT\n</action>\nObservation: the result of the action\n... (this Thought/Action/Observation can repeat N times)\nThought: I now know the final server code and can show it.\nFinal Answer: the final answer"
- },
- {
- "role": "user",
- "type": "prefix",
- "content": "\n{{#Routes}}\nThe handler you are building should do the following:\n{{Description}}\n\n{{#RequestBody}}\nThe incoming request body is JSON that looks like this:```\n{\n{{RequestBody}}\n}\n```\n\n\n{{/RequestBody}}\n\nUse this starting template:```\nimport express from \"express\";\nconst app = express();\nconst port = 3000;\napp.use(express.json())\n\n// TODO: Implement the {{Method}} handler here\n\napp.listen(port, async () => {\n console.log(`Server listening on port ${ port }`)\n})\n```\n\n\nThe HTTP request handler is of type {{Method}}.\nThe request handler MUST be on the route `{{Path}}`.\nDo not forget to use async and await.\nAlways test that the generated server works without bugs and errors as required by running the code and making mock `curl` requests to the server.\nGenerate the full required server code.\n\n{{#Instructions}}\nHere are the required implementation instructions:\n{{Instructions}}\n{{/Instructions}}\n{{/Routes}}\nThought: Here is the plan of how I will go about solving this:"
- }
- ]
-}
\ No newline at end of file
diff --git a/github/pullRequest.ts b/github/pullRequest.ts
index 8cb9fadb8..0b7ca176a 100644
--- a/github/pullRequest.ts
+++ b/github/pullRequest.ts
@@ -24,12 +24,34 @@ export async function createPR({
repo: string,
branch: string,
}): Promise<{ issueID: number }> {
- const baseBranchRef = await client.git.getRef({
- owner,
- repo,
- ref: `heads/${defaultBranch}`,
+
+
+ let baseBranchRef: Awaited<ReturnType<typeof client.git.getRef>> | undefined
+ try {
+ baseBranchRef = await client.git.getRef({
+ owner,
+ repo,
+ ref: `heads/${defaultBranch}`,
+ })
+ } catch (error) {
+ baseBranchRef = await client.git.getRef({
+ owner,
+ repo,
+ ref: `heads/${defaultBranch}`,
+ })
+ }
+
+
+
+
+ client.git.createTree({
+
})
+
+
+ // Create main branch if the repo is empty or it does not exist
+
const newBranchRef = await client.git.createRef({
owner,
repo,
diff --git a/pages/agent/smol-developer/setup.tsx b/pages/agent/smol-developer/setup.tsx
index 1f84e688a..fcc3ed1cd 100644
--- a/pages/agent/smol-developer/setup.tsx
+++ b/pages/agent/smol-developer/setup.tsx
@@ -53,7 +53,7 @@ export interface PostAgentBody {
branch: string
// Commit message for the PR first empty commit
commitMessage: string
- modelConfig: ModelConfig
+ modelConfig: ModelConfig & { templateID: TemplateID }
}
async function handlePostAgent(url: string, { arg }: { arg: PostAgentBody }) {
@@ -67,7 +67,7 @@ async function handlePostAgent(url: string, { arg }: { arg: PostAgentBody }) {
}).then(r => r.json())
}
-function getSmolDevModelConfig(creds: Creds): ModelConfig {
+function getSmolDevModelConfig(creds: Creds): ModelConfig & { templateID: TemplateID } {
const templateID = TemplateID.SmolDeveloper
const modelConfig = getDefaultModelConfig(templateID)
return {
@@ -75,6 +75,7 @@ function getSmolDevModelConfig(creds: Creds): ModelConfig {
provider: modelConfig.provider,
args: getModelArgs(modelConfig, creds),
prompt: [],
+ templateID,
}
}
@@ -84,8 +85,8 @@ function Repo() {
const session = useSession()
const sessionCtx = useSessionContext()
const [selectedRepo, setSelectedRepo] = useState<RepoSetup>()
- const [initialPrompt, setInitialPrompt] = useState<string>()
- const [openAIAPIKey, setOpenAIAPIKey] = useState<string>()
+ const [initialPrompt, setInitialPrompt] = useState<string>('create chrome extension')
+ const [openAIAPIKey, setOpenAIAPIKey] = useState<string>('..')
async function signOut() {
await supabaseClient.auth.signOut()