Skip to content

Commit

Permalink
add comment to PageBase, _run
Browse files Browse the repository at this point in the history
  • Loading branch information
laptype committed Jul 29, 2024
1 parent 04e0b71 commit e1aba00
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
27 changes: 27 additions & 0 deletions apps/codexgraph_agent/pages/components/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,33 @@ def update_progress_bar(page_name, progress):


class PageBase(ABC):
"""
PageBase serves as an abstract base class for creating a structured and interactive Streamlit web page.
It initializes the essential settings, manages the interface components, and handles the interaction
flow for a specific task. The core functionality includes setting up the page layout, managing
conversation history, handling user inputs, and interacting with an Agent to provide responses.
Attributes:
task_name (str): Name of the task associated with the page.
page_title (str): Title of the page displayed on the interface.
output_path (str): Path where conversation history is stored.
input_title (str): Title for the input section of the page.
default_input_text (str): Placeholder text for the input area.
Methods:
main(): Main entry point for setting up the page and handling user interactions.
body(): Defines the body layout of the page and handles user inputs.
repo_db_test(): Tests repository and database connectivity.
reload_history_message(history_path): Reloads the conversation history from a specified file.
update_message(message, role, avatar): Updates the conversation history with a new message.
clear_conversation(): Clears the current conversation history.
agent:
run_agent(): Executes the AI agent with user-provided input.
get_agent(): Abstract method to get the AI agent instance, to be implemented by subclasses.
call_back:
create_update_progress_bar(): Creates a function to update the progress bar dynamically.
create_update_message(): Creates a callback function to update messages dynamically.
"""

def __init__(
self,
Expand Down
5 changes: 4 additions & 1 deletion modelscope_agent/agents/codexgraph_agent/cypher_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ def llm_call(self, msg):

return resp

def _run(self, cypher_queries, retries=5, **kwargs):
def _run(self, cypher_queries: str, retries: int = 5, **kwargs) -> str:
"""
Executes a series of Cypher queries by interacting with a language model and a graph database.
"""
cypher_messages = [
{
'role': 'system',
Expand Down
2 changes: 1 addition & 1 deletion modelscope_agent/agents/codexgraph_agent/task/code_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class CodexGraphAgentChat(CodexGraphAgentGeneral):
def set_action_type_and_message(self):
pass

def _run(self, user_query, file_path: str = '', **kwargs):
def _run(self, user_query: str, file_path: str = '', **kwargs) -> str:

self.chat_history = []

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(self,
def set_action_type_and_message(self):
pass

def _run(self, user_query, file_path: str = '', **kwargs):
def _run(self, user_query: str, file_path: str = '', **kwargs) -> str:

self.chat_history = []

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def update_user_message(self, msg):
if self.message_callback:
self.message_callback(msg, role='user', avatar='🧑‍💻')

def _run(self, user_query, file_path: str = '', **kwargs):
def _run(self, user_query: str, file_path: str = '', **kwargs) -> str:

if file_path:
file_path = f'# file path: {file_path}'
Expand Down

0 comments on commit e1aba00

Please sign in to comment.