Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ Open [http://localhost:3000](http://localhost:3000) with your browser to see the

## Using the Sandbox

1. **Neuron Path**: Enter your Neuron's path in the format `organization/neuron-slug`
1. **Neuron Path**: Enter your Neuron's path in the format `organization/neuron-slug/revisionId`
2. **Authentication** (Optional): If your Neuron requires authentication, enter your API key or JWT token
3. **Input**: Type your input in the text area
4. **Cache Control**: Toggle the "Bypass Cache" option if you need fresh responses
5. **Run**: Click the "Run" button to execute the Neuron and see the results
3. **Key** (Optional): Key is required when running a specific neuron revision, to prevent public access to unpublished versions.
4. **Input**: Type your input in the text area
5. **Cache Control**: Toggle the "Bypass Cache" option if you need fresh responses
6. **Run**: Click the "Run" button to execute the Neuron and see the results

The Sandbox respects all Neuron security settings. If a Neuron requires authentication, you'll need to provide valid credentials to access it.

Expand All @@ -43,5 +44,6 @@ The Sandbox is open source and available on [GitHub](https://github.com/prompteu
## Learn More

To learn more about Prompteus and its features, visit:

- [Prompteus Documentation](https://docs.prompteus.com)
- [Prompteus Sandbox Documentation](https://docs.prompteus.com/features/sandbox)
Binary file modified app/favicon.ico
Binary file not shown.
45 changes: 42 additions & 3 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function SandboxContent() {
const [neuronPath, setNeuronPath] = useState("");
const [bypassCache, setBypassCache] = useState(false);
const [authToken, setAuthToken] = useState("");
const [key, setKey] = useState("");
const [isExecutionStopped, setIsExecutionStopped] = useState(false);

useEffect(() => {
Expand Down Expand Up @@ -48,18 +49,41 @@ function SandboxContent() {
}
}, [neuronPath, router, searchParams]);

useEffect(() => {
const keyFromUrl = searchParams.get("key");

if (keyFromUrl) {
setKey(decodeURIComponent(keyFromUrl));
} else {
const savedKey = localStorage.getItem("key");

if (savedKey) {
setKey(savedKey);
}
}
}, [searchParams]);

useEffect(() => {
localStorage.setItem("authToken", authToken);
}, [authToken]);

useEffect(() => {
if (key) {
localStorage.setItem("key", key);
const params = new URLSearchParams(searchParams.toString());
params.set("key", encodeURIComponent(key));
router.push(`?${params.toString()}`);
}
}, [key, neuronPath, router, searchParams]);

const handleRun = async () => {
try {
setIsLoading(true);
setOutput("");
const input = document.querySelector("textarea")?.value || "";

// Split the neuron path into org and neuron slugs
const [orgSlug, neuronSlug] = neuronPath.split("/");
// Split the neuron path into org and neuron slugs and revisionId
const [orgSlug, neuronSlug, revisionId] = neuronPath.split("/");
if (!orgSlug || !neuronSlug) {
throw new Error(
"Invalid neuron path. Use format: organization/neuron-slug"
Expand All @@ -75,6 +99,8 @@ function SandboxContent() {
input,
bypassCache,
rawOutput: false,
revisionId,
key,
});

setOutput(result.output || "");
Expand Down Expand Up @@ -111,7 +137,7 @@ function SandboxContent() {
<input
type="text"
className="font-mono rounded flex-grow ml-2 p-1 focus:outline-none font-bold bg-transparent border border-gray-300 dark:border-gray-600 dark:text-white"
placeholder="organization/neuron-slug"
placeholder="organization/neuron-slug/revisionId"
value={neuronPath}
onChange={(e) => setNeuronPath(e.target.value)}
/>
Expand All @@ -129,6 +155,19 @@ function SandboxContent() {
The sandbox respects all neuron security settings.
</p>
</div>
<div className="flex items-center flex-row h-8 w-full">
<input
type="password"
className="font-mono rounded w-full p-1 focus:outline-none border border-gray-300 dark:border-gray-600 bg-transparent dark:text-white"
placeholder="Key (optional)"
value={key}
onChange={(e) => setKey(e.target.value)}
/>
<p className="text-xs text-gray-600 dark:text-gray-400 ml-2 leading-tight min-w-80">
Note: Key is required when running a specific neuron revision, to
prevent public access to unpublished versions.
</p>
</div>
</div>
<div className="flex-grow flex flex-col">
<textarea
Expand Down
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
"start": "next start",
"lint": "next lint",
"preview": "opennextjs-cloudflare && wrangler dev",
"deploy": "opennextjs-cloudflare && wrangler deploy",
"deploy:prod": "opennextjs-cloudflare && wrangler deploy --env production",
"deploy:staging": "opennextjs-cloudflare && wrangler deploy --env staging",
"cf-typegen": "wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts"
},
"dependencies": {
"@prompteus-ai/neuron-runner": "^1.0.1",
"@prompteus-ai/neuron-runner": "^1.0.2",
"next": "15.2.1",
"next-themes": "^0.4.5",
"react": "^19.0.0",
Expand All @@ -31,4 +32,4 @@
"typescript": "^5",
"wrangler": "^4.4.0"
}
}
}
34 changes: 17 additions & 17 deletions wrangler.jsonc
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"$schema": "node_modules/wrangler/config-schema.json",
"main": ".open-next/worker.js",
"name": "prompteus-sandbox",
"compatibility_date": "2024-12-30",
"compatibility_flags": ["nodejs_compat"],
"assets": {
"directory": ".open-next/assets",
"binding": "ASSETS",
"$schema": "node_modules/wrangler/config-schema.json",
"main": ".open-next/worker.js",
"name": "prompteus-sandbox",
"compatibility_date": "2024-12-30",
"compatibility_flags": ["nodejs_compat"],
"assets": {
"directory": ".open-next/assets",
"binding": "ASSETS"
},
"env": {
"staging": {
"name": "prompteus-sandbox-staging"
},
"kv_namespaces": [
// Create a KV binding with the binding name "NEXT_CACHE_WORKERS_KV"
// to enable the KV based caching:
// {
// "binding": "NEXT_CACHE_WORKERS_KV",
// "id": "<BINDING_ID>"
// }
],
}
"production": {
"name": "prompteus-sandbox"
}
}
}