Update create_session.dspy to use await redirect() for proper navigation after session creation
This commit is contained in:
parent
a0ef78ac8d
commit
2ab47efd03
@ -22,24 +22,21 @@ try:
|
|||||||
initial_prompt = form_data.get('initial-prompt', '')
|
initial_prompt = form_data.get('initial-prompt', '')
|
||||||
|
|
||||||
if not service_id:
|
if not service_id:
|
||||||
return {"error": "Service ID is required", "success": False}
|
# Redirect back to form with error
|
||||||
|
await 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
|
||||||
session_result = create_session(service_id, initial_prompt)
|
session_result = create_session(service_id, initial_prompt)
|
||||||
|
|
||||||
if session_result:
|
if session_result:
|
||||||
# Return success response with session details
|
# Redirect to the new session's user interaction page
|
||||||
return {
|
await redirect(f"/hermes-web-cli/sessions/{session_result}")
|
||||||
"success": True,
|
|
||||||
"session_id": session_result,
|
|
||||||
"service_id": service_id,
|
|
||||||
"redirect_url": f"/hermes-web-cli/sessions/{session_result}"
|
|
||||||
}
|
|
||||||
else:
|
else:
|
||||||
return {"error": "Failed to create session", "success": False}
|
# Redirect back to form with error
|
||||||
|
await redirect("/hermes-web-cli/new_session.ui?error=Failed+to+create+session")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Log the error and return failure
|
# Log the error and redirect back with error message
|
||||||
print(f"Error creating session: {str(e)}")
|
print(f"Error creating session: {str(e)}")
|
||||||
return {"error": f"Internal error: {str(e)}", "success": False}
|
await redirect(f"/hermes-web-cli/new_session.ui?error=Internal+error:+{str(e)}")
|
||||||
Loading…
x
Reference in New Issue
Block a user