anycoder-29f1e621 / utils.py
lana backwoodz
Upload utils.py with huggingface_hub
83a8d8b verified
Raw History Blame Contribute Delete
1.12 kB
import os
import json
import base64
import zipfile
import tempfile
from pathlib import Path
from datetime import datetime
from typing import Dict, List, Optional
import re
def create_agent_template(
agent_name: str,
agent_type: str,
generated_code: str,
programming_language: str = "Python"
) -> Dict[str, str]:
"""Create a complete agent template with all necessary files."""
files = {}
# Main agent file
if programming_language == "Python":
files[f"{agent_name}.py"] = generated_code
# Configuration file
files["config.json"] = json.dumps({
"name": agent_name,
"type": agent_type,
"language": programming_language,
"created": datetime.now().isoformat(),
"version": "1.0.0"
}, indent=2)
# Requirements file
files["requirements.txt"] = "daggr>=0.5.4\ngradio>=6.0.2\nstreamlit>=1.28.0"
# README
files["README.md"] = f"""# {agent_name}
## Description
{agent_type} agent built with natural language.
## Usage
Run the agent with: