From 54b5e3b6ea822a46951587db7ac799ddc55c95ef Mon Sep 17 00:00:00 2001 From: "abuzarmahmood (aider)" Date: Tue, 6 May 2025 09:17:08 +0000 Subject: [PATCH 1/7] feat: enable independent model configuration for each agent in bot --- src/agents.py | 6 ++---- src/git_utils.py | 3 ++- src/response_agent.py | 14 +++++++++++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/agents.py b/src/agents.py index a7bcf4c..4535906 100644 --- a/src/agents.py +++ b/src/agents.py @@ -134,15 +134,13 @@ def create_user_agent(): def create_agent(agent_name: str, llm_config: dict) -> AssistantAgent: """Create and configure the autogen agents""" - + agent_config = llm_config.get(agent_name, {}) agent = AssistantAgent( name=agent_name, - llm_config=llm_config, + llm_config=agent_config, system_message=agent_system_messages[agent_name], ) - agent = register_functions(agent, register_how="llm") - return agent ############################################################ diff --git a/src/git_utils.py b/src/git_utils.py index b28cc71..9534cd4 100644 --- a/src/git_utils.py +++ b/src/git_utils.py @@ -166,7 +166,8 @@ def write_issue_response(issue: Issue, response_text: str) -> IssueComment: # Import the model info from response_agent if available try: from response_agent import llm_config - signature = f"\n\n---\n*This response was automatically generated by blech_bot using model {llm_config['model']}*" + agent_model = llm_config.get(agent_name, {}).get('model', 'default-model') + signature = f"\n\n---\n*This response was automatically generated by blech_bot using model {agent_model}*" except (ImportError, KeyError): signature = basic_signature response_text += signature diff --git a/src/response_agent.py b/src/response_agent.py index eeb4bfc..c13218f 100644 --- a/src/response_agent.py +++ b/src/response_agent.py @@ -74,9 +74,17 @@ raise ValueError("OpenAI API key not found in environment variables") llm_config = { - "model": params.get("model", "gpt-4o"), - "api_key": api_key, - "temperature": random.uniform(0, 0.2), + "file_assistant": { + "model": params.get("file_assistant_model", "gpt-4o"), + "api_key": api_key, + "temperature": random.uniform(0, 0.2), + }, + "edit_assistant": { + "model": params.get("edit_assistant_model", "gpt-4o"), + "api_key": api_key, + "temperature": random.uniform(0, 0.2), + }, + # Add configurations for other agents similarly } ############################################################ # Response patterns From 313536a56110cfe654fa38bb9ac756669160cfd1 Mon Sep 17 00:00:00 2001 From: "abuzarmahmood (aider)" Date: Tue, 6 May 2025 09:17:21 +0000 Subject: [PATCH 2/7] fix: define agent_name parameter in write_issue_response function --- src/git_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/git_utils.py b/src/git_utils.py index 9534cd4..64e6362 100644 --- a/src/git_utils.py +++ b/src/git_utils.py @@ -139,7 +139,7 @@ def search_issues(repo: Repository, query: str) -> List[Issue]: return list(repo.get_issues(state='all', labels=[query])) -def write_issue_response(issue: Issue, response_text: str) -> IssueComment: +def write_issue_response(issue: Issue, response_text: str, agent_name: str) -> IssueComment: """ Write a response to an issue with the blech_bot signature From 9f5462b995def1dfc15feb989124c5980a740fc2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 09:17:30 +0000 Subject: [PATCH 3/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/git_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/git_utils.py b/src/git_utils.py index 64e6362..d9df412 100644 --- a/src/git_utils.py +++ b/src/git_utils.py @@ -166,7 +166,8 @@ def write_issue_response(issue: Issue, response_text: str, agent_name: str) -> I # Import the model info from response_agent if available try: from response_agent import llm_config - agent_model = llm_config.get(agent_name, {}).get('model', 'default-model') + agent_model = llm_config.get( + agent_name, {}).get('model', 'default-model') signature = f"\n\n---\n*This response was automatically generated by blech_bot using model {agent_model}*" except (ImportError, KeyError): signature = basic_signature From 27665c0cacdf8a3847ffec6e87853c84ca0435bb Mon Sep 17 00:00:00 2001 From: "abuzarmahmood (aider)" Date: Tue, 6 May 2025 09:24:15 +0000 Subject: [PATCH 4/7] test: add unit tests for missing coverage in git_utils.py --- tests/test_git_utils.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/test_git_utils.py diff --git a/tests/test_git_utils.py b/tests/test_git_utils.py new file mode 100644 index 0000000..7134c89 --- /dev/null +++ b/tests/test_git_utils.py @@ -0,0 +1,30 @@ +import unittest +from unittest.mock import patch, Mock +from src.git_utils import get_github_client, get_repository, get_open_issues + +class TestGitUtils(unittest.TestCase): + + @patch('src.git_utils.Github') + def test_get_github_client(self, MockGithub): + mock_instance = MockGithub.return_value + client = get_github_client() + self.assertEqual(client, mock_instance) + + @patch('src.git_utils.Github') + def test_get_repository(self, MockGithub): + mock_instance = MockGithub.return_value + mock_repo = Mock() + mock_instance.get_repo.return_value = mock_repo + repo = get_repository(mock_instance, 'owner/repo') + self.assertEqual(repo, mock_repo) + + @patch('src.git_utils.Repository') + def test_get_open_issues(self, MockRepository): + mock_repo = MockRepository.return_value + mock_issue = Mock() + mock_repo.get_issues.return_value = [mock_issue] + issues = get_open_issues(mock_repo) + self.assertEqual(issues, [mock_issue]) + +if __name__ == '__main__': + unittest.main() From be859bbde3260e07e5ae3c26c5300ab9b347d90a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 09:24:34 +0000 Subject: [PATCH 5/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_git_utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_git_utils.py b/tests/test_git_utils.py index 7134c89..ec88b77 100644 --- a/tests/test_git_utils.py +++ b/tests/test_git_utils.py @@ -2,6 +2,7 @@ from unittest.mock import patch, Mock from src.git_utils import get_github_client, get_repository, get_open_issues + class TestGitUtils(unittest.TestCase): @patch('src.git_utils.Github') @@ -26,5 +27,6 @@ def test_get_open_issues(self, MockRepository): issues = get_open_issues(mock_repo) self.assertEqual(issues, [mock_issue]) + if __name__ == '__main__': unittest.main() From e05131d9b70f7268122630ef1bc60b598396580f Mon Sep 17 00:00:00 2001 From: "abuzarmahmood (aider)" Date: Tue, 6 May 2025 12:03:18 +0000 Subject: [PATCH 6/7] feat: update params.json to support independent model settings for agents --- config/params.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/params.json b/config/params.json index 38ff245..a2833f9 100644 --- a/config/params.json +++ b/config/params.json @@ -1,6 +1,6 @@ { "auto_update": false, "print_llm_output": false, - "model": "gpt-4o", - "aider_model": "gpt-4o" + "file_assistant_model": "gpt-4o", + "edit_assistant_model": "gpt-4o" } From 36ab7e81a9085a21a022e7d44720367cc9530d18 Mon Sep 17 00:00:00 2001 From: "abuzarmahmood (aider)" Date: Tue, 6 May 2025 19:25:13 +0000 Subject: [PATCH 7/7] feat: update agent configurations to support specific model settings --- config/params.json | 4 +++- src/agents.py | 1 + src/response_agent.py | 11 ++++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/config/params.json b/config/params.json index a2833f9..67db403 100644 --- a/config/params.json +++ b/config/params.json @@ -2,5 +2,7 @@ "auto_update": false, "print_llm_output": false, "file_assistant_model": "gpt-4o", - "edit_assistant_model": "gpt-4o" + "edit_assistant_model": "gpt-4o", + "summary_assistant_model": "gpt-4o", + "feedback_assistant_model": "gpt-4o" } diff --git a/src/agents.py b/src/agents.py index 4535906..98c43f7 100644 --- a/src/agents.py +++ b/src/agents.py @@ -135,6 +135,7 @@ def create_user_agent(): def create_agent(agent_name: str, llm_config: dict) -> AssistantAgent: """Create and configure the autogen agents""" agent_config = llm_config.get(agent_name, {}) + agent_config = llm_config.get(agent_name, {}) agent = AssistantAgent( name=agent_name, llm_config=agent_config, diff --git a/src/response_agent.py b/src/response_agent.py index c13218f..dfe1ccd 100644 --- a/src/response_agent.py +++ b/src/response_agent.py @@ -84,7 +84,16 @@ "api_key": api_key, "temperature": random.uniform(0, 0.2), }, - # Add configurations for other agents similarly + "summary_assistant": { + "model": params.get("summary_assistant_model", "gpt-4o"), + "api_key": api_key, + "temperature": random.uniform(0, 0.2), + }, + "feedback_assistant": { + "model": params.get("feedback_assistant_model", "gpt-4o"), + "api_key": api_key, + "temperature": random.uniform(0, 0.2), + }, } ############################################################ # Response patterns