+
+
{searchParamsObj.error}+ {/* TODO: Nicer, but it should never happen */} + > + ) + } else if (state === 'success') { + content = ( + <> +
{content}
+} diff --git a/apps/web/src/app/(docs)/docs/legacy/cli/commands/page.mdx b/apps/web/src/app/(docs)/docs/legacy/cli/commands/page.mdx new file mode 100644 index 000000000..6397c7fcd --- /dev/null +++ b/apps/web/src/app/(docs)/docs/legacy/cli/commands/page.mdx @@ -0,0 +1,318 @@ +# CLI Commands + +Build your sandbox with our CLI. {{ className: 'lead' }} + +'
+const execution = await sandbox.notebook.execCell(code)
+
+// There was an error during execution, return the error and its traceback
+if (execution.error) {
+ return `There was an error during execution: ${execution.error.name}: ${execution.error.value}.\n
+ ${execution.error.traceback}`
+}
+
+// The execution has some result, summarize to LLM, what are the results
+if (execution.results.length > 0) {
+ let message = 'These are results of the execution:\n'
+ let counter = 1
+ for (const result of execution.results) {
+ message += `Result ${counter++}:\n`
+ if (result.isMainResult) {
+ message += `[Main result]: ${result.text}\n`
+ } else {
+ message += `[Display data]: ${result.text}\n`
+ }
+ if (result.formats().length > 0) {
+ message += `It has following formats: ${result.formats()}\n`
+ }
+ }
+
+ return message
+}
+
+// There were no results, check if there was something is stdout/err
+if (
+ execution.logs.stdout.length > 0 ||
+ execution.logs.stderr.length > 0
+) {
+ let message = 'There was no result of the execution, but here are the logs:\n'
+ if (execution.logs.stdout.length > 0) {
+ message += `Stdout: ${execution.logs.stdout.join('\n')}\n`
+ }
+ if (execution.logs.stderr.length > 0) {
+ message += `Stderr: ${execution.logs.stderr.join('\n')}\n`
+ }
+
+ return message
+}
+
+return 'There was no output of the execution.'
+```
+
+```python
+code = ""
+execution = sandbox.notebook.exec_cell(code)
+
+# There was an error during execution, return the error and its traceback
+if execution.error:
+ return (
+ f"There was an error during execution: {execution.error.name}: {execution.error.value}.\n"
+ f"{execution.error.traceback}"
+ )
+
+# The execution has some result, summarize to LLM, what are the results
+if execution.results:
+ message = "These are results of the execution:\n"
+ for i, result in enumerate(execution.results):
+ message += f"Result {i + 1}:\n"
+ if result.is_main_result:
+ message += f"[Main result]: {result.text}\n"
+ else:
+ message += f"[Display data]: {result.text}\n"
+
+ if result.formats():
+ message += f"It has also following formats: {result.formats()}\n"
+
+ return message
+
+# There were no results, check if there was something is stdout/err
+if execution.logs.stdout or execution.logs.stderr:
+ message = "There was no result of the execution, but here are the logs:\n"
+ if execution.logs.stdout:
+ message += "Stdout: " + "\n".join(execution.logs.stdout) + "\n"
+
+ if execution.logs.stderr:
+ message += "Stderr: " + "\n".join(execution.logs.stderr) + "\n"
+
+ return message
+
+return "There was no output of the execution."
+```
+
E2B_API_KEY
environment variable to avoid passing it
+ every time.
+
+ }
+ />
+ e2b auth login
.
+
+ E2B_ACCESS_TOKEN
as an environment variable.
+ This can be useful for CI/CD pipelines.
+