-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmulti_language_execution.py
More file actions
63 lines (51 loc) · 1.77 KB
/
multi_language_execution.py
File metadata and controls
63 lines (51 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""Example: Execute code in multiple programming languages.
This example demonstrates executing Python, JavaScript, and TypeScript code
in the Daytona sandbox.
Requirements:
- DAYTONA_API_KEY environment variable set
- GOOGLE_API_KEY environment variable set
"""
import asyncio
from google.adk.agents import Agent
from google.adk.runners import InMemoryRunner
from daytona_adk import DaytonaPlugin
async def main() -> None:
"""Execute code in Python, JavaScript, and TypeScript."""
plugin = DaytonaPlugin()
agent = Agent(
model="gemini-2.0-flash",
name="multi_language_executor",
tools=plugin.get_tools(),
)
async with InMemoryRunner(
app_name="multi_language_example",
agent=agent,
plugins=[plugin],
) as runner:
# Python
print("\n" + "=" * 60)
print("Testing Python Execution")
print("=" * 60)
response = await runner.run_debug(
"Execute Python code: import sys; print(f'Python {sys.version}')"
)
print(f"Response: {response}\n")
# JavaScript
print("\n" + "=" * 60)
print("Testing JavaScript Execution")
print("=" * 60)
response = await runner.run_debug(
"Execute JavaScript: console.log('Hello from Node.js ' + process.version)"
)
print(f"Response: {response}\n")
# TypeScript
print("\n" + "=" * 60)
print("Testing TypeScript Execution")
print("=" * 60)
response = await runner.run_debug(
"Execute TypeScript: const msg: string = 'Hello from TypeScript'; console.log(msg)"
)
print(f"Response: {response}\n")
print("\nAll languages executed successfully!")
if __name__ == "__main__":
asyncio.run(main())