reasoning-deployment-service 0.2.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of reasoning-deployment-service might be problematic. Click here for more details.
- examples/programmatic_usage.py +154 -0
- reasoning_deployment_service/__init__.py +25 -0
- reasoning_deployment_service/cli_editor/__init__.py +5 -0
- reasoning_deployment_service/cli_editor/api_client.py +666 -0
- reasoning_deployment_service/cli_editor/cli_runner.py +343 -0
- reasoning_deployment_service/cli_editor/config.py +82 -0
- reasoning_deployment_service/cli_editor/google_deps.py +29 -0
- reasoning_deployment_service/cli_editor/reasoning_engine_creator.py +448 -0
- reasoning_deployment_service/gui_editor/__init__.py +5 -0
- reasoning_deployment_service/gui_editor/main.py +280 -0
- reasoning_deployment_service/gui_editor/requirements_minimal.txt +54 -0
- reasoning_deployment_service/gui_editor/run_program.sh +55 -0
- reasoning_deployment_service/gui_editor/src/__init__.py +1 -0
- reasoning_deployment_service/gui_editor/src/core/__init__.py +1 -0
- reasoning_deployment_service/gui_editor/src/core/api_client.py +647 -0
- reasoning_deployment_service/gui_editor/src/core/config.py +43 -0
- reasoning_deployment_service/gui_editor/src/core/google_deps.py +22 -0
- reasoning_deployment_service/gui_editor/src/core/reasoning_engine_creator.py +448 -0
- reasoning_deployment_service/gui_editor/src/ui/__init__.py +1 -0
- reasoning_deployment_service/gui_editor/src/ui/agent_space_view.py +312 -0
- reasoning_deployment_service/gui_editor/src/ui/authorization_view.py +280 -0
- reasoning_deployment_service/gui_editor/src/ui/reasoning_engine_view.py +354 -0
- reasoning_deployment_service/gui_editor/src/ui/reasoning_engines_view.py +204 -0
- reasoning_deployment_service/gui_editor/src/ui/ui_components.py +1221 -0
- reasoning_deployment_service/reasoning_deployment_service.py +687 -0
- reasoning_deployment_service-0.2.8.dist-info/METADATA +177 -0
- reasoning_deployment_service-0.2.8.dist-info/RECORD +29 -0
- reasoning_deployment_service-0.2.8.dist-info/WHEEL +5 -0
- reasoning_deployment_service-0.2.8.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
"""Main application window and orchestration."""
|
|
2
|
+
import tkinter as tk
|
|
3
|
+
from tkinter import ttk
|
|
4
|
+
from tkinter import messagebox
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
7
|
+
from dotenv import load_dotenv
|
|
8
|
+
load_dotenv()
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
# Try package-level imports first (when installed as package)
|
|
12
|
+
from reasoning_deployment_service.gui_editor.src.core.config import Config, loadenv
|
|
13
|
+
from reasoning_deployment_service.gui_editor.src.core.api_client import ApiClient
|
|
14
|
+
from reasoning_deployment_service.gui_editor.src.core.google_deps import HAS_GOOGLE
|
|
15
|
+
from reasoning_deployment_service.gui_editor.src.ui.ui_components import LogConsole, async_operation
|
|
16
|
+
from reasoning_deployment_service.gui_editor.src.ui.agent_space_view import AgentSpaceView
|
|
17
|
+
from reasoning_deployment_service.gui_editor.src.ui.reasoning_engine_view import ReasoningEngineView
|
|
18
|
+
from reasoning_deployment_service.gui_editor.src.ui.authorization_view import AuthorizationView
|
|
19
|
+
except ImportError:
|
|
20
|
+
try:
|
|
21
|
+
# Try relative imports (when running from within the package)
|
|
22
|
+
from .src.core.config import Config, loadenv
|
|
23
|
+
from .src.core.api_client import ApiClient
|
|
24
|
+
from .src.core.google_deps import HAS_GOOGLE
|
|
25
|
+
from .src.ui.ui_components import LogConsole, async_operation
|
|
26
|
+
from .src.ui.agent_space_view import AgentSpaceView
|
|
27
|
+
from .src.ui.reasoning_engine_view import ReasoningEngineView
|
|
28
|
+
from .src.ui.authorization_view import AuthorizationView
|
|
29
|
+
except ImportError:
|
|
30
|
+
# Fall back to absolute imports (when running directly)
|
|
31
|
+
from src.core.config import Config, loadenv
|
|
32
|
+
from src.core.api_client import ApiClient
|
|
33
|
+
from src.core.google_deps import HAS_GOOGLE
|
|
34
|
+
from src.ui.ui_components import LogConsole, async_operation
|
|
35
|
+
from src.ui.agent_space_view import AgentSpaceView
|
|
36
|
+
from src.ui.reasoning_engine_view import ReasoningEngineView
|
|
37
|
+
from src.ui.authorization_view import AuthorizationView
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class GuiEditorApp(tk.Tk):
|
|
41
|
+
"""Main application window."""
|
|
42
|
+
|
|
43
|
+
def __init__(self):
|
|
44
|
+
super().__init__()
|
|
45
|
+
self.title("Agent Space / Reasoning Engine Manager")
|
|
46
|
+
self.geometry("1120x760")
|
|
47
|
+
|
|
48
|
+
# Load environment variables from env.agent
|
|
49
|
+
loadenv(".env.agent")
|
|
50
|
+
|
|
51
|
+
# Show blocking dropdown for environment selection
|
|
52
|
+
self.env_var = tk.StringVar(value="dev")
|
|
53
|
+
self._show_env_selector()
|
|
54
|
+
|
|
55
|
+
# Load configuration
|
|
56
|
+
self.config = Config()
|
|
57
|
+
|
|
58
|
+
# Validate environment
|
|
59
|
+
if not self._validate_env():
|
|
60
|
+
self.destroy()
|
|
61
|
+
return
|
|
62
|
+
|
|
63
|
+
# Create API client
|
|
64
|
+
self.api_client = self._create_api_client()
|
|
65
|
+
|
|
66
|
+
# Setup UI
|
|
67
|
+
self._setup_ui()
|
|
68
|
+
|
|
69
|
+
# Initial state
|
|
70
|
+
self._check_and_auto_load()
|
|
71
|
+
|
|
72
|
+
def _create_api_client(self) -> ApiClient:
|
|
73
|
+
"""Create live API client."""
|
|
74
|
+
cfg = self.config.to_dict()
|
|
75
|
+
|
|
76
|
+
# Rename 'agent_space' to 'engine_name' for ApiClient compatibility
|
|
77
|
+
cfg["engine_name"] = cfg.pop("agent_space", None)
|
|
78
|
+
|
|
79
|
+
try:
|
|
80
|
+
return ApiClient(**cfg, mode="live", profile_path="agent_profile.live.json")
|
|
81
|
+
except Exception as e:
|
|
82
|
+
print(f"[Live mode disabled] {e}")
|
|
83
|
+
raise
|
|
84
|
+
|
|
85
|
+
def _setup_ui(self):
|
|
86
|
+
"""Setup the user interface."""
|
|
87
|
+
# Top control bar
|
|
88
|
+
self._setup_top_bar()
|
|
89
|
+
|
|
90
|
+
# Main content tabs
|
|
91
|
+
self._setup_tabs()
|
|
92
|
+
|
|
93
|
+
# Bottom console
|
|
94
|
+
self._setup_console()
|
|
95
|
+
|
|
96
|
+
def _setup_top_bar(self):
|
|
97
|
+
"""Setup the top control bar."""
|
|
98
|
+
top = ttk.Frame(self, padding=(10, 8, 10, 0))
|
|
99
|
+
top.pack(fill="x")
|
|
100
|
+
|
|
101
|
+
# Auth button
|
|
102
|
+
self.auth_btn = ttk.Button(top, text="Authenticate (ADC)", command=self._authenticate)
|
|
103
|
+
self.auth_btn.pack(side="left")
|
|
104
|
+
|
|
105
|
+
# Configuration status
|
|
106
|
+
config_status = "✅ Configured" if self.config.is_configured else "⚠️ Check environment variables"
|
|
107
|
+
ttk.Label(top, text=f"Config: {config_status}").pack(side="left", padx=(16, 0))
|
|
108
|
+
|
|
109
|
+
def _setup_tabs(self):
|
|
110
|
+
"""Setup the main content tabs."""
|
|
111
|
+
self.nb = ttk.Notebook(self)
|
|
112
|
+
self.nb.pack(fill="both", expand=True, padx=10, pady=10)
|
|
113
|
+
|
|
114
|
+
# Create views
|
|
115
|
+
self.agent_space = AgentSpaceView(self.nb, self.api_client, self._log)
|
|
116
|
+
self.engine_view = ReasoningEngineView(
|
|
117
|
+
self.nb, self.api_client, self._log, self.agent_space.refresh
|
|
118
|
+
)
|
|
119
|
+
self.auth_view = AuthorizationView(self.nb, self.api_client, self._log)
|
|
120
|
+
|
|
121
|
+
self.nb.add(self.agent_space, text="Agent Space")
|
|
122
|
+
self.nb.add(self.engine_view, text="Reasoning Engines")
|
|
123
|
+
self.nb.add(self.auth_view, text="Authorizations")
|
|
124
|
+
|
|
125
|
+
# Bind tab selection event to handle auto-loading
|
|
126
|
+
self.nb.bind("<<NotebookTabChanged>>", self._on_tab_changed)
|
|
127
|
+
|
|
128
|
+
def _setup_console(self):
|
|
129
|
+
"""Setup the bottom console."""
|
|
130
|
+
self.console = LogConsole(self)
|
|
131
|
+
self.console.pack(fill="both", expand=False, padx=10, pady=(0, 10))
|
|
132
|
+
self._log("Ready. Data will auto-load if credentials are available.")
|
|
133
|
+
|
|
134
|
+
def _log(self, message: str):
|
|
135
|
+
"""Log a message to the console."""
|
|
136
|
+
self.console.log(message)
|
|
137
|
+
|
|
138
|
+
def _on_tab_changed(self, event):
|
|
139
|
+
"""Handle tab selection changes to trigger auto-loading."""
|
|
140
|
+
selected_tab = self.nb.select()
|
|
141
|
+
tab_text = self.nb.tab(selected_tab, "text")
|
|
142
|
+
|
|
143
|
+
# Auto-load reasoning engines when that tab is first selected
|
|
144
|
+
if tab_text == "Reasoning Engines":
|
|
145
|
+
try:
|
|
146
|
+
self.engine_view.on_tab_selected()
|
|
147
|
+
except Exception as e:
|
|
148
|
+
self._log(f"⚠️ Error loading reasoning engines: {e}")
|
|
149
|
+
elif tab_text == "Authorizations":
|
|
150
|
+
try:
|
|
151
|
+
self.auth_view.on_tab_selected()
|
|
152
|
+
except Exception as e:
|
|
153
|
+
self._log(f"⚠️ Error loading authorizations: {e}")
|
|
154
|
+
|
|
155
|
+
def _authenticate(self):
|
|
156
|
+
"""Authenticate with Google Cloud."""
|
|
157
|
+
self._log("Authenticating…")
|
|
158
|
+
|
|
159
|
+
def callback(res):
|
|
160
|
+
if isinstance(res, Exception):
|
|
161
|
+
self._log(f"❌ Auth error: {res}")
|
|
162
|
+
return
|
|
163
|
+
self._log("✅ Auth complete. Auto-loading data...")
|
|
164
|
+
# Refresh auth cache after successful authentication
|
|
165
|
+
self.api_client.refresh_auth_cache()
|
|
166
|
+
# Auto-refresh data after successful authentication
|
|
167
|
+
self.agent_space.refresh()
|
|
168
|
+
|
|
169
|
+
async_operation(self.api_client.authenticate, callback=callback, ui_widget=self)
|
|
170
|
+
|
|
171
|
+
def _check_and_auto_load(self):
|
|
172
|
+
"""Check authentication and auto-load data if credentials are available."""
|
|
173
|
+
if self.api_client.is_authenticated:
|
|
174
|
+
self._log("✅ Credentials available. Auto-loading data...")
|
|
175
|
+
self.agent_space.refresh()
|
|
176
|
+
self.engine_view._refresh_engines() # Ensure reasoning engines are loaded
|
|
177
|
+
else:
|
|
178
|
+
self._log("🔐 Click 'Authenticate' to load data, or use Refresh buttons.")
|
|
179
|
+
|
|
180
|
+
def _show_env_selector(self):
|
|
181
|
+
"""Show a blocking dropdown for selecting environment."""
|
|
182
|
+
# Create a simple dialog without grab_set to avoid crashes
|
|
183
|
+
selector = tk.Toplevel(self)
|
|
184
|
+
selector.title("Select Environment")
|
|
185
|
+
selector.geometry("400x200")
|
|
186
|
+
selector.resizable(False, False)
|
|
187
|
+
|
|
188
|
+
# Center the dialog
|
|
189
|
+
self.update_idletasks()
|
|
190
|
+
x = (self.winfo_screenwidth() // 2) - 200
|
|
191
|
+
y = (self.winfo_screenheight() // 2) - 100
|
|
192
|
+
selector.geometry(f"400x200+{x}+{y}")
|
|
193
|
+
|
|
194
|
+
# Make it stay on top but don't use grab_set
|
|
195
|
+
selector.attributes('-topmost', True)
|
|
196
|
+
|
|
197
|
+
# Variables to track dialog state
|
|
198
|
+
self.env_selected = False
|
|
199
|
+
|
|
200
|
+
frame = ttk.Frame(selector, padding=20)
|
|
201
|
+
frame.pack(fill="both", expand=True)
|
|
202
|
+
|
|
203
|
+
ttk.Label(frame, text="Select Environment:", font=("TkDefaultFont", 12)).pack(pady=10)
|
|
204
|
+
|
|
205
|
+
env_frame = ttk.Frame(frame)
|
|
206
|
+
env_frame.pack(pady=10)
|
|
207
|
+
ttk.Label(env_frame, text="Environment:").pack(side="left", padx=(0, 10))
|
|
208
|
+
env_menu = ttk.OptionMenu(env_frame, self.env_var, self.env_var.get(), "dev", "prod")
|
|
209
|
+
env_menu.pack(side="left")
|
|
210
|
+
|
|
211
|
+
def on_confirm():
|
|
212
|
+
selected_env = self.env_var.get()
|
|
213
|
+
|
|
214
|
+
# Load environment variables based on selection
|
|
215
|
+
import os
|
|
216
|
+
env_prefix = selected_env.upper()
|
|
217
|
+
|
|
218
|
+
# Map environment variables
|
|
219
|
+
os.environ["PROJECT_ID"] = os.getenv(f"{env_prefix}_PROJECT_ID", "")
|
|
220
|
+
os.environ["PROJECT_NUMBER"] = os.getenv(f"{env_prefix}_PROJECT_NUMBER", "")
|
|
221
|
+
os.environ["PROJECT_LOCATION"] = os.getenv(f"{env_prefix}_PROJECT_LOCATION", "")
|
|
222
|
+
os.environ["AGENT_SPACE_ENGINE"] = os.getenv(f"{env_prefix}_AGENT_SPACE_ENGINE", "")
|
|
223
|
+
|
|
224
|
+
self.config = Config() # Reload configuration
|
|
225
|
+
|
|
226
|
+
if self._validate_env():
|
|
227
|
+
self.env_selected = True
|
|
228
|
+
selector.destroy()
|
|
229
|
+
else:
|
|
230
|
+
messagebox.showerror(
|
|
231
|
+
"Validation Error",
|
|
232
|
+
f"Missing required fields in {selected_env} environment.\n"
|
|
233
|
+
f"Please ensure all required fields are set in .env.agent file:\n"
|
|
234
|
+
f"- {env_prefix}_PROJECT_ID\n"
|
|
235
|
+
f"- {env_prefix}_PROJECT_NUMBER\n"
|
|
236
|
+
f"- {env_prefix}_PROJECT_LOCATION\n"
|
|
237
|
+
f"- {env_prefix}_AGENT_SPACE_ENGINE"
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
def on_close():
|
|
241
|
+
selector.destroy()
|
|
242
|
+
self.destroy()
|
|
243
|
+
exit()
|
|
244
|
+
|
|
245
|
+
button_frame = ttk.Frame(frame)
|
|
246
|
+
button_frame.pack(pady=20)
|
|
247
|
+
|
|
248
|
+
ttk.Button(button_frame, text="Confirm", command=on_confirm).pack(side="left", padx=10)
|
|
249
|
+
ttk.Button(button_frame, text="Close App", command=on_close).pack(side="left", padx=10)
|
|
250
|
+
|
|
251
|
+
# Handle window close event
|
|
252
|
+
selector.protocol("WM_DELETE_WINDOW", on_close)
|
|
253
|
+
|
|
254
|
+
# Wait for the dialog to be closed
|
|
255
|
+
self.wait_window(selector)
|
|
256
|
+
|
|
257
|
+
# If environment not selected, exit
|
|
258
|
+
if not hasattr(self, 'env_selected') or not self.env_selected:
|
|
259
|
+
self.destroy()
|
|
260
|
+
exit()
|
|
261
|
+
|
|
262
|
+
def _validate_env(self):
|
|
263
|
+
"""Validate the selected environment for required fields."""
|
|
264
|
+
required_fields = ["project_id", "project_number", "location", "agent_space"]
|
|
265
|
+
missing_fields = []
|
|
266
|
+
|
|
267
|
+
for field in required_fields:
|
|
268
|
+
value = getattr(self.config, field, None)
|
|
269
|
+
if not value or value.strip() == "":
|
|
270
|
+
missing_fields.append(field)
|
|
271
|
+
|
|
272
|
+
return len(missing_fields) == 0
|
|
273
|
+
|
|
274
|
+
def run(self):
|
|
275
|
+
self.mainloop()
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
if __name__ == "__main__":
|
|
279
|
+
GuiEditorApp().run()
|
|
280
|
+
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Bare minimum requirements for Agent Space Deployment Service
|
|
2
|
+
# Core functionality dependencies only
|
|
3
|
+
|
|
4
|
+
# Google Cloud & Vertex AI (CORE REQUIREMENT)
|
|
5
|
+
google-cloud-aiplatform==1.108.0
|
|
6
|
+
vertexai==1.43.0
|
|
7
|
+
google-auth==2.40.3
|
|
8
|
+
google-auth-oauthlib==1.2.2
|
|
9
|
+
google-api-python-client==2.178.0
|
|
10
|
+
|
|
11
|
+
# Environment management (CORE REQUIREMENT)
|
|
12
|
+
python-dotenv==1.1.1
|
|
13
|
+
|
|
14
|
+
# HTTP requests (CORE REQUIREMENT)
|
|
15
|
+
requests==2.32.4
|
|
16
|
+
|
|
17
|
+
# Google Cloud dependencies (CORE REQUIREMENT)
|
|
18
|
+
google-api-core==2.25.1
|
|
19
|
+
googleapis-common-protos==1.70.0
|
|
20
|
+
grpcio==1.74.0
|
|
21
|
+
protobuf==6.31.1
|
|
22
|
+
|
|
23
|
+
# Authentication dependencies (CORE REQUIREMENT)
|
|
24
|
+
google-auth-httplib2==0.2.0
|
|
25
|
+
cachetools==5.5.2
|
|
26
|
+
pyasn1==0.6.1
|
|
27
|
+
pyasn1_modules==0.4.2
|
|
28
|
+
rsa==4.9.1
|
|
29
|
+
|
|
30
|
+
# Core Python utilities (CORE REQUIREMENT)
|
|
31
|
+
certifi==2025.8.3
|
|
32
|
+
urllib3==2.5.0
|
|
33
|
+
six==1.17.0
|
|
34
|
+
|
|
35
|
+
# OPTIONAL: For enhanced functionality
|
|
36
|
+
# Uncomment if you need these features:
|
|
37
|
+
|
|
38
|
+
# For MCP server support:
|
|
39
|
+
# mcp==1.12.4
|
|
40
|
+
|
|
41
|
+
# For FastAPI endpoints (if you plan to add web interface):
|
|
42
|
+
# fastapi==0.116.1
|
|
43
|
+
# uvicorn==0.35.0
|
|
44
|
+
# pydantic==2.11.7
|
|
45
|
+
|
|
46
|
+
# For document processing in agents:
|
|
47
|
+
# PyPDF2==3.0.1
|
|
48
|
+
# python-docx==1.2.0
|
|
49
|
+
|
|
50
|
+
# For web scraping/HTTP in agents:
|
|
51
|
+
# httpx==0.28.1
|
|
52
|
+
|
|
53
|
+
# For YAML configuration:
|
|
54
|
+
# PyYAML==6.0.2
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
VENV_DIR=".venv"
|
|
5
|
+
|
|
6
|
+
# Detect Python executable
|
|
7
|
+
if command -v python3 &>/dev/null; then
|
|
8
|
+
PYTHON=python3
|
|
9
|
+
elif command -v python &>/dev/null; then
|
|
10
|
+
PYTHON=python
|
|
11
|
+
else
|
|
12
|
+
echo "❌ Python is not installed. Please install Python 3.9+."
|
|
13
|
+
exit 1
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
# Create venv if missing
|
|
17
|
+
if [ ! -d "$VENV_DIR" ]; then
|
|
18
|
+
echo "🔧 Creating virtual environment..."
|
|
19
|
+
$PYTHON -m venv "$VENV_DIR"
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
# Activate venv (POSIX)
|
|
23
|
+
if [ -f "$VENV_DIR/bin/activate" ]; then
|
|
24
|
+
source "$VENV_DIR/bin/activate"
|
|
25
|
+
# Activate venv (Windows Git Bash or Cygwin)
|
|
26
|
+
elif [ -f "$VENV_DIR/Scripts/activate" ]; then
|
|
27
|
+
source "$VENV_DIR/Scripts/activate"
|
|
28
|
+
else
|
|
29
|
+
echo "❌ Could not find venv activation script."
|
|
30
|
+
exit 1
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
# Install Tkinter if on Linux
|
|
34
|
+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|
35
|
+
echo "🖼 Installing Tkinter for Linux..."
|
|
36
|
+
if command -v apt-get &>/dev/null; then
|
|
37
|
+
sudo apt-get update && sudo apt-get install -y python3-tk
|
|
38
|
+
elif command -v dnf &>/dev/null; then
|
|
39
|
+
sudo dnf install -y python3-tkinter
|
|
40
|
+
elif command -v pacman &>/dev/null; then
|
|
41
|
+
sudo pacman -S --noconfirm tk
|
|
42
|
+
else
|
|
43
|
+
echo "⚠️ Could not determine package manager. Install python3-tk manually."
|
|
44
|
+
fi
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
# Install dependencies
|
|
48
|
+
echo "📦 Installing dependencies..."
|
|
49
|
+
pip3 install --upgrade pip
|
|
50
|
+
# Install the reasoning deployment service with GUI extras
|
|
51
|
+
pip3 install "reasoning-deployment-service[gui]"
|
|
52
|
+
|
|
53
|
+
# Run your app
|
|
54
|
+
echo "🚀 Starting app..."
|
|
55
|
+
$PYTHON main.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# GUI Editor src package
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Core application logic and API clients."""
|