Fix create_session.dspy: use return {'redirect': ...} instead of await redirect() to match ahserver convention
This commit is contained in:
parent
2ab47efd03
commit
72fc8656b9
@ -4,18 +4,11 @@
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# Extract form data from request context
|
# Extract form data from request context
|
||||||
# In Sage system, params passed via urlwidget are available in request.form
|
|
||||||
form_data = {}
|
form_data = {}
|
||||||
|
|
||||||
# Try to get data from request.form (standard for POST requests)
|
# Get data from request.form (standard for POST requests)
|
||||||
if hasattr(request, 'form'):
|
if hasattr(request, 'form'):
|
||||||
form_data = dict(request.form)
|
form_data = dict(request.form)
|
||||||
# Fallback: check if data is passed as keyword arguments
|
|
||||||
elif hasattr(locals(), 'service_id'):
|
|
||||||
form_data = {
|
|
||||||
'service_id': locals().get('service_id', ''),
|
|
||||||
'initial-prompt': locals().get('initial-prompt', '')
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get required parameters
|
# Get required parameters
|
||||||
service_id = form_data.get('service_id')
|
service_id = form_data.get('service_id')
|
||||||
@ -23,7 +16,7 @@ try:
|
|||||||
|
|
||||||
if not service_id:
|
if not service_id:
|
||||||
# Redirect back to form with error
|
# Redirect back to form with error
|
||||||
await redirect("/hermes-web-cli/new_session.ui?error=Service+ID+is+required")
|
return {"redirect": "/hermes-web-cli/new_session.ui?error=Service+ID+is+required"}
|
||||||
|
|
||||||
# Use the function provided by the hermes-web-cli module
|
# Use the function provided by the hermes-web-cli module
|
||||||
# This will call the remote hermes-service API
|
# This will call the remote hermes-service API
|
||||||
@ -31,12 +24,12 @@ try:
|
|||||||
|
|
||||||
if session_result:
|
if session_result:
|
||||||
# Redirect to the new session's user interaction page
|
# Redirect to the new session's user interaction page
|
||||||
await redirect(f"/hermes-web-cli/sessions/{session_result}")
|
return {"redirect": f"/hermes-web-cli/sessions/{session_result}"}
|
||||||
else:
|
else:
|
||||||
# Redirect back to form with error
|
# Redirect back to form with error
|
||||||
await redirect("/hermes-web-cli/new_session.ui?error=Failed+to+create+session")
|
return {"redirect": "/hermes-web-cli/new_session.ui?error=Failed+to+create+session"}
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Log the error and redirect back with error message
|
# Log the error and redirect back with error message
|
||||||
print(f"Error creating session: {str(e)}")
|
print(f"Error creating session: {str(e)}")
|
||||||
await redirect(f"/hermes-web-cli/new_session.ui?error=Internal+error:+{str(e)}")
|
return {"redirect": f"/hermes-web-cli/new_session.ui?error=Internal+error:+{str(e)}"}
|
||||||
Loading…
x
Reference in New Issue
Block a user