Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tofarr committed Dec 31, 2024
1 parent 5b197b4 commit 4181d09
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
1 change: 1 addition & 0 deletions openhands/server/data_models/conversation_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ class ConversationMetadata:
conversation_id: str
github_user_id: str
selected_repository: str | None
title: str | None = None
20 changes: 10 additions & 10 deletions openhands/server/routes/new_conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ async def new_conversation(request: Request, data: InitSessionRequest):
After successful initialization, the client should connect to the WebSocket
using the returned conversation ID
"""
github_token = ''
if data.github_token:
github_token = data.github_token

github_token = data.github_token or ''
settings_store = await SettingsStoreImpl.get_instance(config, github_token)
settings = await settings_store.load()

Expand Down Expand Up @@ -110,10 +107,11 @@ async def search_conversations(


async def _get_conversation_info(
session_id: str, is_running: bool, file_store: FileStore
session_id: str, is_running: bool, file_store: FileStore, request: Request,
) -> ConversationInfo | None:
try:
conversation_store = await ConversationStoreImpl.get_instance(config)
github_token = getattr(request.state, 'github_token', '') or ''
conversation_store = await ConversationStoreImpl.get_instance(config, github_token)
metadata = await conversation_store.get_metadata(session_id)
events_dir = get_conversation_events_dir(session_id)
events = file_store.list(events_dir)
Expand Down Expand Up @@ -149,8 +147,9 @@ async def get_conversation(conversation_id: str) -> ConversationInfo | None:


@app.post('/conversations/{conversation_id}')
async def update_conversation(conversation_id: str, title: str) -> bool:
conversation_store = await ConversationStoreImpl.get_instance(config)
async def update_conversation(conversation_id: str, title: str, request: Request) -> bool:
github_token = getattr(request.state, 'github_token', '') or ''
conversation_store = await ConversationStoreImpl.get_instance(config, github_token)
metadata = await conversation_store.get_metadata(conversation_id)
if not metadata:
return False
Expand All @@ -160,8 +159,9 @@ async def update_conversation(conversation_id: str, title: str) -> bool:


@app.delete('/conversations/{conversation_id}')
async def delete_conversation(conversation_id: str) -> bool:
conversation_store = await ConversationStoreImpl.get_instance(config)
async def delete_conversation(conversation_id: str, request: Request,) -> bool:
github_token = getattr(request.state, 'github_token', '') or ''
conversation_store = await ConversationStoreImpl.get_instance(config, github_token)
try:
await conversation_store.get_metadata(conversation_id)
except FileNotFoundError:
Expand Down
8 changes: 2 additions & 6 deletions openhands/server/routes/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@


@app.get('/settings')
async def load_settings(
request: Request,
) -> Settings | None:
github_token = ''
if hasattr(request.state, 'github_token'):
github_token = request.state.github_token
async def load_settings(request: Request) -> Settings | None:
github_token = getattr(request.state, 'github_token', '') or ''
try:
settings_store = await SettingsStoreImpl.get_instance(config, github_token)
settings = await settings_store.load()
Expand Down

0 comments on commit 4181d09

Please sign in to comment.