Skip to content

Commit

Permalink
fix 404 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
rbren committed Nov 18, 2024
1 parent a87b859 commit d94dd7f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion frontend/src/api/open-hands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class OpenHands {
}

static async getRuntimeId(): Promise<{ runtime_id: string }> {
const response = await request("/api/config");
const response = await request("/api/conversation");
const data = await response.json();

return data;
Expand Down
27 changes: 10 additions & 17 deletions openhands/server/listen.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from pathspec import PathSpec
from pathspec.patterns import GitWildMatchPattern

from openhands.runtime.impl.remote.remote_runtime import RemoteRuntime
from openhands.security.options import SecurityAnalyzers
from openhands.server.data_models.feedback import FeedbackDataModel, store_feedback
from openhands.server.github import (
Expand Down Expand Up @@ -565,27 +564,21 @@ def sanitize_filename(filename):
return filename


@app.get('/api/config')
@app.get('/api/conversation')
async def get_remote_runtime_config(request: Request):
"""Retrieve the remote runtime configuration.
Currently, this is the runtime ID.
"""
try:
runtime = request.state.conversation.runtime
if isinstance(runtime, RemoteRuntime):
return JSONResponse(content={'runtime_id': runtime.runtime_id})
else:
return JSONResponse(
status_code=status.HTTP_404_NOT_FOUND,
content={'error': 'Runtime ID not available in this environment'},
)
except Exception as e:
logger.error(e)
return JSONResponse(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
content={'error': 'Something went wrong'},
)
runtime = request.state.conversation.runtime
runtime_id = runtime.runtime_id if hasattr(runtime, 'runtime_id') else None
session_id = runtime.sid if hasattr(runtime, 'sid') else None
return JSONResponse(
content={
'runtime_id': runtime_id,
'session_id': session_id,
}
)


@app.post('/api/upload-files')
Expand Down

0 comments on commit d94dd7f

Please sign in to comment.