Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding workflow locks into Wilmer #7

Merged
merged 2 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Cleaned up discussion_id being extracted and removed, and corrected a…
…n issue with its removal.
  • Loading branch information
SomeOddCodeGuy committed Aug 13, 2024
commit 482d0fd65409ad797d55c72faab979d5769057a5
2 changes: 1 addition & 1 deletion Middleware/core/open_ai_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ def handle_user_prompt(prompt_collection: List[Dict[str, str]], stream: bool) ->
else:
print("handle_user_prompt workflow exists")
workflow_manager: WorkflowManager = WorkflowManager(get_active_custom_workflow_name())
return workflow_manager.run_workflow(prompt_collection, request_id, stream)
return workflow_manager.run_workflow(prompt_collection, request_id, stream=stream)
2 changes: 1 addition & 1 deletion Middleware/utilities/prompt_extraction_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def remove_discussion_id_tag_from_string(message: str) -> str:
Returns:
str: The message string with the discussion ID tag removed.
"""
pattern = f'{re.escape(discussion_identifiers["discussion_id_start"])}\\d+{re.escape(discussion_identifiers["discussion_id_end"])}'
pattern = f'{re.escape(discussion_identifiers["discussion_id_start"])}.*?{re.escape(discussion_identifiers["discussion_id_end"])}'
return re.sub(pattern, '', message)


Expand Down
14 changes: 8 additions & 6 deletions Middleware/workflows/categorization/prompt_categorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class PromptCategorizer:
"""

@staticmethod
def conversational_method(prompt, request_id, stream=False):
def conversational_method(prompt, request_id, discussion_id: str = None, stream=False):
"""
Run the default conversational workflow.

Expand All @@ -22,7 +22,9 @@ def conversational_method(prompt, request_id, stream=False):
Returns:
str: The result of the workflow execution.
"""
return WorkflowManager(workflow_config_name='_DefaultWorkflow').run_workflow(prompt, request_id, stream=stream)
return WorkflowManager(workflow_config_name='_DefaultWorkflow').run_workflow(prompt, request_id,
discussionId=discussion_id,
stream=stream)

@staticmethod
def _configure_workflow_manager(category_data):
Expand Down Expand Up @@ -62,7 +64,7 @@ def initialize(self):
print("Error decoding JSON from routing configuration file.")
raise

def get_prompt_category(self, prompt, stream, request_id):
def get_prompt_category(self, prompt, stream, request_id, discussion_id: str = None):
"""
Get the category of the prompt and run the appropriate workflow.

Expand All @@ -73,17 +75,17 @@ def get_prompt_category(self, prompt, stream, request_id):
Returns:
str: The result of the workflow execution.
"""
category = self._categorize_request(prompt)
category = self._categorize_request(prompt, request_id)
print("Category: ", category)

if category in self.categories:
print("Response initiated")
workflow_name = self.categories[category]['workflow']
workflow = WorkflowManager(workflow_config_name=workflow_name)
return workflow.run_workflow(prompt, request_id, stream=stream)
return workflow.run_workflow(prompt, request_id, discussionId=discussion_id, stream=stream)
else:
print("Default response initiated")
return self.conversational_method(prompt, request_id, stream)
return self.conversational_method(prompt, request_id, discussion_id, stream)

def _initialize_categories(self):
"""
Expand Down
Loading