forked from i-am-bee/beeai-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpython.ts
32 lines (27 loc) · 908 Bytes
/
python.ts
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
import "dotenv/config";
import { CustomTool } from "bee-agent-framework/tools/custom";
const customTool = await CustomTool.fromSourceCode(
{
// Ensure the env exists
url: process.env.CODE_INTERPRETER_URL!,
},
`import requests
from typing import Optional, Union, Dict
def get_riddle() -> Optional[Dict[str, str]]:
"""
Fetches a random riddle from the Riddles API.
This function retrieves a random riddle and its answer. It does not accept any input parameters.
Returns:
Optional[Dict[str, str]]: A dictionary containing:
- 'riddle' (str): The riddle question.
- 'answer' (str): The answer to the riddle.
Returns None if the request fails.
"""
url = 'https://riddles-api.vercel.app/random'
try:
response = requests.get(url)
response.raise_for_status()
return response.json()
except Exception as e:
return None`,
);