-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_env.py
More file actions
174 lines (136 loc) Β· 6.14 KB
/
Copy pathsetup_env.py
File metadata and controls
174 lines (136 loc) Β· 6.14 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/usr/bin/env python3
"""
Environment setup script for AI Agent Evaluation System.
This script helps configure the necessary environment variables.
"""
import os
import sys
from pathlib import Path
def create_env_file():
"""Create a .env file with the necessary environment variables"""
print("π§ AI Agent Evaluation System - Environment Setup")
print("=" * 50)
# Default values
default_base_url = "https://dev-i9bbrvz6i.agentuity.run"
default_agent_id = "agent_abcf9ad4245d2d89aed9eb38aef21fd6"
default_token = "" # Dev mode typically doesn't need auth
print("\nπ Development Environment Configuration:")
print(f"Base URL: {default_base_url}")
print(f"Agent ID: {default_agent_id}")
print(f"API Token: {'(not required for dev mode)' if not default_token else default_token}")
# Ask user if they want to customize
customize = input("\nπ€ Do you want to customize these values? (y/N): ").lower().strip()
if customize in ['y', 'yes']:
base_url = input(f"Enter Agentuity Base URL [{default_base_url}]: ").strip() or default_base_url
agent_id = input(f"Enter Dataset Loader Agent ID [{default_agent_id}]: ").strip() or default_agent_id
token = input(f"Enter Agentuity API Token (optional for dev) [{default_token or 'none'}]: ").strip() or default_token
else:
base_url = default_base_url
agent_id = default_agent_id
token = default_token
# Create .env file content
env_content = f"""# AI Agent Evaluation System Configuration
# Generated by setup_env.py
# Agentuity Development Environment
AGENTUITY_BASE_URL={base_url}
DATASET_LOADER_AGENT_ID={agent_id}
AGENTUITY_API_TOKEN={token}
# Note: Authentication is optional in development mode
# Make sure 'agentuity dev' is running for the agent to be accessible
# Optional: Model API Keys (configure these in your Agentuity project instead)
# ANTHROPIC_API_KEY=your_anthropic_key_here
# OPENAI_API_KEY=your_openai_key_here
"""
# Write .env file
env_file = Path(".env")
if env_file.exists():
backup = input("\nβ οΈ .env file already exists. Create backup? (Y/n): ").lower().strip()
if backup not in ['n', 'no']:
backup_file = Path(".env.backup")
env_file.rename(backup_file)
print(f"β
Backup created: {backup_file}")
with open(env_file, 'w') as f:
f.write(env_content)
print(f"\nβ
Environment file created: {env_file.absolute()}")
# Show next steps
print("\nπ Next Steps:")
print("1. Install backend dependencies: uv sync")
print("2. Install frontend dependencies: cd react-frontend && npm install")
print("3. Start backend: agentuity dev")
print("4. Start frontend: cd react-frontend && npm run dev")
print("5. Open http://localhost:5173 in your browser")
# Test connection option
test_connection = input("\nπ§ͺ Test API connection now? (Y/n): ").lower().strip()
if test_connection not in ['n', 'no']:
test_api_connection(base_url, agent_id, token)
def test_api_connection(base_url: str, agent_id: str, token: str):
"""Test the API connection"""
try:
import requests
print("\nπ Testing API connection...")
headers = {
'Content-Type': 'application/json'
}
# Add auth header only if token is provided
if token:
headers['Authorization'] = f'Bearer {token}'
print(f"Using authentication: Bearer {token[:8]}...{token[-8:] if len(token) > 16 else '***'}")
else:
print("No authentication (dev mode)")
response = requests.get(f"{base_url}/{agent_id}", headers=headers, timeout=10)
if response.status_code == 200:
print("β
API connection successful!")
print("π Your evaluation system is ready to use!")
elif response.status_code == 401:
print("β Authentication failed - check your API token")
elif response.status_code == 404:
print("β Agent not found - make sure 'agentuity dev' is running")
else:
print(f"β οΈ Unexpected response: {response.status_code}")
print(f"Response: {response.text[:200]}...")
except ImportError:
print("β οΈ requests library not found. Install dependencies first: uv sync")
except Exception as e:
print(f"β Connection test failed: {e}")
print("π‘ Make sure 'agentuity dev' is running in another terminal")
def show_usage():
"""Show usage information"""
print("""
π€ AI Agent Evaluation System - Environment Setup
Usage:
python setup_env.py # Interactive setup
python setup_env.py --help # Show this help
python setup_env.py --test # Test current configuration
Environment Variables:
AGENTUITY_BASE_URL # Agentuity API base URL
DATASET_LOADER_AGENT_ID # Agent ID for dataset loader
AGENTUITY_API_TOKEN # Bearer token for authentication
Example .env file:
AGENTUITY_BASE_URL=https://dev-uzeflmvib.agentuity.run
DATASET_LOADER_AGENT_ID=agent_abcf9ad4245d2d89aed9eb38aef21fd6
AGENTUITY_API_TOKEN=
""")
def test_current_config():
"""Test the current configuration"""
base_url = os.getenv("AGENTUITY_BASE_URL", "https://dev-uzeflmvib.agentuity.run")
agent_id = os.getenv("DATASET_LOADER_AGENT_ID", "agent_abcf9ad4245d2d89aed9eb38aef21fd6")
token = os.getenv("AGENTUITY_API_TOKEN", "")
print("π§ͺ Testing current configuration...")
print(f"Base URL: {base_url}")
print(f"Agent ID: {agent_id}")
print(f"Token: {token[:8]}...{token[-8:] if len(token) > 16 else '***'}")
test_api_connection(base_url, agent_id, token)
def main():
"""Main function"""
if len(sys.argv) > 1:
if sys.argv[1] in ['--help', '-h']:
show_usage()
elif sys.argv[1] == '--test':
test_current_config()
else:
print(f"Unknown option: {sys.argv[1]}")
show_usage()
else:
create_env_file()
if __name__ == "__main__":
main()