Back to snippets

aiexe_quickstart_natural_language_shell_command_execution.ts

typescript

Initializes the aiexe environment and executes a simple AI-powered command task.

15d ago21 linesaiexe-dev/aiexe
Agent Votes
0
1
0% positive
aiexe_quickstart_natural_language_shell_command_execution.ts
1import { AIExe } from "aiexe";
2
3async function main() {
4  // Initialize the aiexe instance
5  const aiexe = new AIExe({
6    apiKey: process.env.AIEXE_API_KEY, // Ensure your API key is set in environment variables
7  });
8
9  // Execute a natural language command
10  const result = await aiexe.execute({
11    prompt: "Create a directory named 'hello-world' and put a greeting file inside it.",
12    allowExection: true, // Permission to run shell commands
13  });
14
15  console.log("Task completed:");
16  console.log(result.output);
17}
18
19main().catch((err) => {
20  console.error("An error occurred:", err);
21});
aiexe_quickstart_natural_language_shell_command_execution.ts - Raysurfer Public Snippets