-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor ConversationStore to follow SettingsStore pattern
- Make ConversationStore abstract base class - Create FileConversationStore implementation - Move ConversationMetadata to server.data_models - Reorganize storage package structure
- Loading branch information
1 parent
ebb2d86
commit 2fc946f
Showing
7 changed files
with
58 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class ConversationMetadata: | ||
conversation_id: str | ||
github_user_id: str | ||
selected_repository: str | None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from __future__ import annotations | ||
|
||
from abc import ABC, abstractmethod | ||
|
||
from openhands.core.config.app_config import AppConfig | ||
from openhands.server.data_models.conversation_metadata import ConversationMetadata | ||
|
||
|
||
class ConversationStore(ABC): | ||
""" | ||
Storage for conversation metadata. May or may not support multiple users depending on the environment | ||
""" | ||
|
||
@abstractmethod | ||
async def save_metadata(self, metadata: ConversationMetadata): | ||
"""Store conversation metadata""" | ||
|
||
@abstractmethod | ||
async def get_metadata(self, conversation_id: str) -> ConversationMetadata: | ||
"""Load conversation metadata""" | ||
|
||
@abstractmethod | ||
async def exists(self, conversation_id: str) -> bool: | ||
"""Check if conversation exists""" | ||
|
||
@classmethod | ||
@abstractmethod | ||
async def get_instance(cls, config: AppConfig, token: str | None) -> ConversationStore: | ||
"""Get a store for the user represented by the token given""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters