From 208541d909292e1a477cb600cf0178b68485b7ca Mon Sep 17 00:00:00 2001 From: Fluder-Paradyne <121793617+Fluder-Paradyne@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:21:42 +0530 Subject: [PATCH] comment out prints --- migrations/env.py | 2 +- superagi/agent/agent_prompt_builder.py | 4 ++-- superagi/agent/agent_tool_step_handler.py | 4 ++-- superagi/agent/queue_step_handler.py | 4 ++-- superagi/agent/task_queue.py | 2 +- superagi/controllers/agent_execution_permission.py | 2 +- superagi/controllers/agent_template.py | 4 ++-- superagi/controllers/google_oauth.py | 6 +++--- superagi/controllers/models_controller.py | 12 ++++++------ superagi/helper/prompt_reader.py | 4 ++-- superagi/helper/s3_helper.py | 2 +- superagi/helper/token_counter.py | 2 +- superagi/helper/tool_helper.py | 8 ++++---- superagi/helper/twitter_helper.py | 4 ++-- superagi/jobs/agent_executor.py | 2 +- superagi/llms/google_palm.py | 2 +- superagi/llms/llm_model_factory.py | 12 ++++++------ superagi/llms/replicate.py | 4 ++-- superagi/models/models.py | 4 ++-- superagi/resource_manager/resource_summary.py | 2 +- superagi/tools/apollo/apollo_search.py | 2 +- superagi/tools/email/send_email.py | 10 +++++----- superagi/tools/google_search/google_search.py | 6 +++--- superagi/tools/instagram_tool/instagram.py | 2 +- superagi/vector_store/redis.py | 2 +- tests/unit_tests/tools/code/test_write_code.py | 6 +++--- 26 files changed, 57 insertions(+), 57 deletions(-) diff --git a/migrations/env.py b/migrations/env.py index d57b279bf..1ff0563c5 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -85,7 +85,7 @@ def run_migrations_online() -> None: "DB_HOST": os.getenv("DB_HOST", ""), "DB_NAME": os.getenv("DB_NAME", "") } - print("HERE ARE THE VARIABLES", url_tokens) + #print("HERE ARE THE VARIABLES", url_tokens) config.set_main_option('sqlalchemy.url', f"postgresql://{url_tokens['DB_USER']}:{url_tokens['DB_PASS']}@{url_tokens['DB_HOST']}:5432/{url_tokens['DB_NAME']}") connectable = engine_from_config( config.get_section(config.config_ini_section, {}), diff --git a/superagi/agent/agent_prompt_builder.py b/superagi/agent/agent_prompt_builder.py index 4b9bce554..e31c745d1 100644 --- a/superagi/agent/agent_prompt_builder.py +++ b/superagi/agent/agent_prompt_builder.py @@ -29,7 +29,7 @@ def add_tools_to_prompt(cls, tools: List[BaseTool], add_finish: bool = True) -> add_finish (bool): Whether to add finish tool or not. """ final_string = "" - print(tools) + #print(tools) for i, item in enumerate(tools): final_string += f"{i + 1}. {cls._generate_tool_string(item)}\n" finish_description = ( @@ -53,7 +53,7 @@ def add_tools_to_prompt(cls, tools: List[BaseTool], add_finish: bool = True) -> @classmethod def _generate_tool_string(cls, tool: BaseTool) -> str: output = f"\"{tool.name}\": {tool.description}" - # print(tool.args) + # #print(tool.args) output += f", args json schema: {json.dumps(tool.args)}" return output diff --git a/superagi/agent/agent_tool_step_handler.py b/superagi/agent/agent_tool_step_handler.py index 5b8c1c127..d1b045f54 100644 --- a/superagi/agent/agent_tool_step_handler.py +++ b/superagi/agent/agent_tool_step_handler.py @@ -42,7 +42,7 @@ def execute_step(self): step_tool = AgentWorkflowStepTool.find_by_id(self.session, workflow_step.action_reference_id) agent_config = Agent.fetch_configuration(self.session, self.agent_id) agent_execution_config = AgentExecutionConfiguration.fetch_configuration(self.session, self.agent_execution_id) - # print(agent_execution_config) + # #print(agent_execution_config) if not self._handle_wait_for_permission(execution, workflow_step): return @@ -103,7 +103,7 @@ def _process_input_instruction(self, agent_config, agent_execution_config, step_ messages = AgentLlmMessageBuilder(self.session, self.llm, self.llm.get_model(), self.agent_id, self.agent_execution_id) \ .build_agent_messages(prompt, agent_feeds, history_enabled=step_tool.history_enabled, completion_prompt=step_tool.completion_prompt) - # print(messages) + # #print(messages) current_tokens = TokenCounter.count_message_tokens(messages, self.llm.get_model()) response = self.llm.chat_completion(messages, TokenCounter(session=self.session, organisation_id=self.organisation.id).token_limit(self.llm.get_model()) - current_tokens) diff --git a/superagi/agent/queue_step_handler.py b/superagi/agent/queue_step_handler.py index fcd9baf1f..102d01e44 100644 --- a/superagi/agent/queue_step_handler.py +++ b/superagi/agent/queue_step_handler.py @@ -75,7 +75,7 @@ def _consume_from_queue(self, task_queue: TaskQueue): def _process_reply(self, task_queue: TaskQueue, assistant_reply: str): assistant_reply = JsonCleaner.extract_json_array_section(assistant_reply) - print("Queue reply:", assistant_reply) + #print("Queue reply:", assistant_reply) task_array = np.array(eval(assistant_reply)).flatten().tolist() for task in task_array: task_queue.add_task(str(task)) @@ -85,7 +85,7 @@ def _process_input_instruction(self, step_tool): prompt = self._build_queue_input_prompt(step_tool) logger.info("Prompt: ", prompt) agent_feeds = AgentExecutionFeed.fetch_agent_execution_feeds(self.session, self.agent_execution_id) - print(".........//////////////..........2") + #print(".........//////////////..........2") messages = AgentLlmMessageBuilder(self.session, self.llm, self.llm.get_model(), self.agent_id, self.agent_execution_id) \ .build_agent_messages(prompt, agent_feeds, history_enabled=step_tool.history_enabled, completion_prompt=step_tool.completion_prompt) diff --git a/superagi/agent/task_queue.py b/superagi/agent/task_queue.py index 6acddf3f3..2b3e3a2b9 100644 --- a/superagi/agent/task_queue.py +++ b/superagi/agent/task_queue.py @@ -14,7 +14,7 @@ def __init__(self, queue_name: str): def add_task(self, task: str): self.db.lpush(self.queue_name, task) - # print("Added task. New tasks:", str(self.get_tasks())) + # #print("Added task. New tasks:", str(self.get_tasks())) def complete_task(self, response): if len(self.get_tasks()) <= 0: diff --git a/superagi/controllers/agent_execution_permission.py b/superagi/controllers/agent_execution_permission.py index 4b41c3b03..4adf38664 100644 --- a/superagi/controllers/agent_execution_permission.py +++ b/superagi/controllers/agent_execution_permission.py @@ -144,7 +144,7 @@ def update_agent_execution_permission_status(agent_execution_permission_id: int, """ agent_execution_permission = db.session.query(AgentExecutionPermission).get(agent_execution_permission_id) - print(agent_execution_permission) + #print(agent_execution_permission) if agent_execution_permission is None: raise HTTPException(status_code=400, detail="Invalid Request") if status is None: diff --git a/superagi/controllers/agent_template.py b/superagi/controllers/agent_template.py index 799df391b..68e7ffe7e 100644 --- a/superagi/controllers/agent_template.py +++ b/superagi/controllers/agent_template.py @@ -283,9 +283,9 @@ def list_agent_templates(template_source="local", search_str="", page=0, organis local_templates_hash = {} for local_template in local_templates: local_templates_hash[local_template.marketplace_template_id] = True - print(local_templates_hash) + #print(local_templates_hash) templates = AgentTemplate.fetch_marketplace_list(search_str, page) - print(templates) + #print(templates) for template in templates: template["is_installed"] = local_templates_hash.get(template["id"], False) template["organisation_id"] = organisation.id diff --git a/superagi/controllers/google_oauth.py b/superagi/controllers/google_oauth.py index 8cfa29592..9c49be643 100644 --- a/superagi/controllers/google_oauth.py +++ b/superagi/controllers/google_oauth.py @@ -55,8 +55,8 @@ async def google_auth_calendar(code: str = Query(...), state: str = Query(...)): if response.status_code != 200: raise HTTPException(status_code=400, detail="Invalid Client Secret") response = response.json() - print("----------------------------------------------------------------") - print(response) + #print("----------------------------------------------------------------") + #print(response) expire_time = datetime.utcnow() + timedelta(seconds=response['expires_in']) expire_time = expire_time - timedelta(minutes=5) response['expiry'] = expire_time.strftime("%Y-%m-%dT%H:%M:%S.%fZ") @@ -74,7 +74,7 @@ def send_google_calendar_configs(google_creds: dict, toolkit_id: int, Authorize: user_id = current_user.id toolkit = db.session.query(Toolkit).filter(Toolkit.id == toolkit_id).first() google_creds = json.dumps(google_creds) - print(google_creds) + #print(google_creds) tokens = OauthTokens().add_or_update(session, toolkit_id, user_id, toolkit.organisation_id, "GOOGLE_CALENDAR_OAUTH_TOKENS", google_creds) if tokens: success = True diff --git a/superagi/controllers/models_controller.py b/superagi/controllers/models_controller.py index e35198295..38fadf7e8 100644 --- a/superagi/controllers/models_controller.py +++ b/superagi/controllers/models_controller.py @@ -145,14 +145,14 @@ def get_marketplace_models_list(page: int = 0): models_list = [] try: - print("///////////////////1") - print(models) + #print("///////////////////1") + #print(models) for model in models: model_dict = model.__dict__ - print(model_dict) - print("///////////////////2") - print(db.session.query(ModelsConfig).filter(ModelsConfig.id == model.model_provider_id).first()) - print(db.session.query(ModelsConfig).filter(ModelsConfig.id == model.model_provider_id).first().provider) + #print(model_dict) + #print("///////////////////2") + #print(db.session.query(ModelsConfig).filter(ModelsConfig.id == model.model_provider_id).first()) + #print(db.session.query(ModelsConfig).filter(ModelsConfig.id == model.model_provider_id).first().provider) model_dict["provider"] = db.session.query(ModelsConfig).filter(ModelsConfig.id == model.model_provider_id).first().provider models_list.append(model_dict) except Exception as e: diff --git a/superagi/helper/prompt_reader.py b/superagi/helper/prompt_reader.py index 16121145e..6a1c519d1 100644 --- a/superagi/helper/prompt_reader.py +++ b/superagi/helper/prompt_reader.py @@ -10,7 +10,7 @@ def read_tools_prompt(current_file: str, prompt_file: str) -> str: file_content = f.read() f.close() except FileNotFoundError as e: - print(e.__str__()) + #print(e.__str__()) raise e return file_content @@ -22,6 +22,6 @@ def read_agent_prompt(current_file: str, prompt_file: str) -> str: file_content = f.read() f.close() except FileNotFoundError as e: - print(e.__str__()) + #print(e.__str__()) raise e return file_content diff --git a/superagi/helper/s3_helper.py b/superagi/helper/s3_helper.py index 6a653c081..31aad6b43 100644 --- a/superagi/helper/s3_helper.py +++ b/superagi/helper/s3_helper.py @@ -66,7 +66,7 @@ def read_from_s3(self, file_path): def read_binary_from_s3(self, file_path): file_path = "resources" + file_path - print("____________________________________________LOG TEST: FINAL PATH_____________", file_path) + #print("____________________________________________LOG TEST: FINAL PATH_____________", file_path) logger.info(f"Reading file from s3: {file_path}") response = self.s3.get_object(Bucket=get_config("BUCKET_NAME"), Key=file_path) if response['ResponseMetadata']['HTTPStatusCode'] == 200: diff --git a/superagi/helper/token_counter.py b/superagi/helper/token_counter.py index b0d442558..9a7a44701 100644 --- a/superagi/helper/token_counter.py +++ b/superagi/helper/token_counter.py @@ -79,7 +79,7 @@ def count_message_tokens(messages: List[BaseMessage], model: str = "gpt-3.5-turb num_tokens += len(encoding.encode(message['content'])) num_tokens += 3 - print("tokens",num_tokens) + #print("tokens",num_tokens) return num_tokens @staticmethod diff --git a/superagi/helper/tool_helper.py b/superagi/helper/tool_helper.py index c0afd9760..be1db8799 100644 --- a/superagi/helper/tool_helper.py +++ b/superagi/helper/tool_helper.py @@ -295,7 +295,7 @@ def add_tool_to_json(repo_link): def handle_tools_import(): - print("Handling tools import") + #print("Handling tools import") tool_paths = ["superagi/tools", "superagi/tools/marketplace_tools", "superagi/tools/external_tools"] for tool_path in tool_paths: if not os.path.exists(tool_path): @@ -335,7 +335,7 @@ def compare_toolkit(toolkit1, toolkit2): tool_configs_diff = any(compare_configs(config1, config2) for config1, config2 in zip(tool_configs1, tool_configs2)) - print("toolkit_diff : ", toolkit_diff) - print("tools_diff : ", tools_diff) - print("tool_configs_diff : ", tool_configs_diff) + #print("toolkit_diff : ", toolkit_diff) + #print("tools_diff : ", tools_diff) + #print("tool_configs_diff : ", tool_configs_diff) return toolkit_diff or tools_diff or tool_configs_diff diff --git a/superagi/helper/twitter_helper.py b/superagi/helper/twitter_helper.py index 8e31f1d05..d35ac5c62 100644 --- a/superagi/helper/twitter_helper.py +++ b/superagi/helper/twitter_helper.py @@ -41,9 +41,9 @@ def get_file_path(self, session, file_name, agent_id, agent_execution_id): return final_path def _get_image_data(self, file_path): - print("______________________________________________LOG TEST : FILE PATH _______________________ ",file_path) + #print("______________________________________________LOG TEST : FILE PATH _______________________ ",file_path) if StorageType.get_storage_type(get_config("STORAGE_TYPE", StorageType.FILE.value)) == StorageType.S3: - print("______________________Testing__________________ S3___________") + #print("______________________Testing__________________ S3___________") attachment_data = S3Helper().read_binary_from_s3(file_path) else: with open(file_path, "rb") as file: diff --git a/superagi/jobs/agent_executor.py b/superagi/jobs/agent_executor.py index 45e91ee4d..2e8a24afe 100644 --- a/superagi/jobs/agent_executor.py +++ b/superagi/jobs/agent_executor.py @@ -119,7 +119,7 @@ def __execute_workflow_step(self, agent, agent_config, agent_execution_id, agent organisation_id=organisation.id) , agent_id=agent.id, agent_execution_id=agent_execution_id, memory=memory) - print(get_model(model=agent_config["model"], api_key=model_api_key, organisation_id=organisation.id)) + #print(get_model(model=agent_config["model"], api_key=model_api_key, organisation_id=organisation.id)) iteration_step_handler.execute_step() elif agent_workflow_step.action_type == AgentWorkflowStepAction.WAIT_STEP.value: (AgentWaitStepHandler(session=session, agent_id=agent.id, diff --git a/superagi/llms/google_palm.py b/superagi/llms/google_palm.py index 40e25d82f..928842f94 100644 --- a/superagi/llms/google_palm.py +++ b/superagi/llms/google_palm.py @@ -71,7 +71,7 @@ def chat_completion(self, messages, max_tokens=get_config("MAX_MODEL_TOKEN_LIMIT prompt=prompt, max_output_tokens=int(max_tokens), ) - # print(completion.result) + # #print(completion.result) return {"response": completion, "content": completion.result} except Exception as exception: logger.info("Google palm Exception:", exception) diff --git a/superagi/llms/llm_model_factory.py b/superagi/llms/llm_model_factory.py index 345c4f8c7..a77806f05 100644 --- a/superagi/llms/llm_model_factory.py +++ b/superagi/llms/llm_model_factory.py @@ -10,7 +10,7 @@ def get_model(organisation_id, api_key, model="gpt-3.5-turbo", **kwargs): - print("Fetching model details from database...") + #print("Fetching model details from database...") engine = connect_db() Session = sessionmaker(bind=engine) session = Session() @@ -23,19 +23,19 @@ def get_model(organisation_id, api_key, model="gpt-3.5-turbo", **kwargs): session.close() if provider_name == 'OpenAI': - print("Provider is OpenAI") + #print("Provider is OpenAI") return OpenAi(model=model_instance.model_name, api_key=api_key, **kwargs) elif provider_name == 'Replicate': - print("Provider is Replicate") + #print("Provider is Replicate") return Replicate(model=model_instance.model_name, version=model_instance.version, api_key=api_key, **kwargs) elif provider_name == 'Google Palm': - print("Provider is Google Palm") + #print("Provider is Google Palm") return GooglePalm(model=model_instance.model_name, api_key=api_key, **kwargs) elif provider_name == 'Hugging Face': - print("Provider is Hugging Face") + #print("Provider is Hugging Face") return HuggingFace(model=model_instance.model_name, end_point=model_instance.end_point, api_key=api_key, **kwargs) elif provider_name == 'Local LLM': - print("Provider is Local LLM") + #print("Provider is Local LLM") return LocalLLM(model=model_instance.model_name, context_length=model_instance.context_length) else: print('Unknown provider.') diff --git a/superagi/llms/replicate.py b/superagi/llms/replicate.py index b612ab774..d100b23cd 100644 --- a/superagi/llms/replicate.py +++ b/superagi/llms/replicate.py @@ -86,8 +86,8 @@ def chat_completion(self, messages, max_tokens=get_config("MAX_MODEL_TOKEN_LIMIT if not final_output: logger.error("Replicate model didn't return any output.") return {"error": "Replicate model didn't return any output."} - print(final_output) - print(temp_output) + #print(final_output) + #print(temp_output) logger.info("Replicate response:", final_output) return {"response": temp_output, "content": final_output} diff --git a/superagi/models/models.py b/superagi/models/models.py index 47241afea..b88a41474 100644 --- a/superagi/models/models.py +++ b/superagi/models/models.py @@ -68,8 +68,8 @@ def fetch_marketplace_list(cls, page): @classmethod def get_model_install_details(cls, session, marketplace_models, organisation_id, type=ModelsTypes.CUSTOM.value): - print("///////////////////////3") - print(marketplace_models) + #print("///////////////////////3") + #print(marketplace_models) installed_models = session.query(Models).filter(Models.org_id == organisation_id).all() model_counts_dict = dict( session.query(Models.model_name, func.count(Models.org_id)).group_by(Models.model_name).all() diff --git a/superagi/resource_manager/resource_summary.py b/superagi/resource_manager/resource_summary.py index b9f7f9663..9e784a87f 100644 --- a/superagi/resource_manager/resource_summary.py +++ b/superagi/resource_manager/resource_summary.py @@ -78,7 +78,7 @@ def generate_agent_summary(self, generate_all: bool = False) -> str: self.session.commit() def fetch_or_create_agent_resource_summary(self, default_summary: str): - print(self.__get_model_source()) + #print(self.__get_model_source()) if ModelSourceType.GooglePalm.value in self.__get_model_source(): return self.generate_agent_summary(generate_all=True) diff --git a/superagi/tools/apollo/apollo_search.py b/superagi/tools/apollo/apollo_search.py index 974638cc7..eba744d4f 100644 --- a/superagi/tools/apollo/apollo_search.py +++ b/superagi/tools/apollo/apollo_search.py @@ -125,7 +125,7 @@ def apollo_search_results(self, page, per_page, person_titles, num_of_employees data["person_locations"] = [person_location] response = requests.post(url, headers=headers, data=json.dumps(data)) - print(response) + #print(response) if response.status_code == 200: return response.json() else: diff --git a/superagi/tools/email/send_email.py b/superagi/tools/email/send_email.py index aa5c4965d..1c26bdf64 100644 --- a/superagi/tools/email/send_email.py +++ b/superagi/tools/email/send_email.py @@ -40,13 +40,13 @@ def _execute(self, to: str, subject: str, body: str) -> str: Returns: success or error message. """ - print("to: ", to, "/////////////////////////////////////") - print("subject: ", subject, "/////////////////////////////////////") - print("body: ", body, "/////////////////////////////////////") + #print("to: ", to, "/////////////////////////////////////") + #print("subject: ", subject, "/////////////////////////////////////") + #print("body: ", body, "/////////////////////////////////////") email_sender = self.get_tool_config('EMAIL_ADDRESS') email_password = self.get_tool_config('EMAIL_PASSWORD') - print("email_sender: ", email_sender, "/////////////////////////////////////") - print("email_password: ", email_password, "/////////////////////////////////////") + #print("email_sender: ", email_sender, "/////////////////////////////////////") + #print("email_password: ", email_password, "/////////////////////////////////////") if email_sender is None or email_sender == "" or email_sender.isspace(): return "Error: Email Not Sent. Enter a valid Email Address." if email_password is None or email_password == "" or email_password.isspace(): diff --git a/superagi/tools/google_search/google_search.py b/superagi/tools/google_search/google_search.py index 2bda48b39..8d3653a66 100644 --- a/superagi/tools/google_search/google_search.py +++ b/superagi/tools/google_search/google_search.py @@ -49,11 +49,11 @@ def _execute(self, query: str) -> tuple: Returns: Search result summary along with related links """ - print("query: ", query, "/////////////////////////////////////") + #print("query: ", query, "/////////////////////////////////////") api_key = self.get_tool_config("GOOGLE_API_KEY") search_engine_id = self.get_tool_config("SEARCH_ENGINE_ID") - print("api_key: ", api_key, "/////////////////////////////////////") - print("search_engine_id: ", search_engine_id, "/////////////////////////////////////") + #print("api_key: ", api_key, "/////////////////////////////////////") + #print("search_engine_id: ", search_engine_id, "/////////////////////////////////////") num_results = 10 num_pages = 1 num_extracts = 3 diff --git a/superagi/tools/instagram_tool/instagram.py b/superagi/tools/instagram_tool/instagram.py index 5d9e68b35..8a71bf3c4 100644 --- a/superagi/tools/instagram_tool/instagram.py +++ b/superagi/tools/instagram_tool/instagram.py @@ -168,7 +168,7 @@ def get_img_url_and_encoded_caption(self,photo_description,file_path,filename): #encoding the caption with possible emojis and hashtags and removing the starting and ending double quotes encoded_caption=self.create_caption(photo_description) - print(image_url, encoded_caption) + #print(image_url, encoded_caption) return image_url,encoded_caption diff --git a/superagi/vector_store/redis.py b/superagi/vector_store/redis.py index 93e1b906f..c422c6dc7 100644 --- a/superagi/vector_store/redis.py +++ b/superagi/vector_store/redis.py @@ -98,7 +98,7 @@ def get_matching_text(self, query: str, top_k: int = 5, metadata: Optional[dict] .tobytes() } - # print(self.index) + # #print(self.index) results = self.redis_client.ft(self.index).search(query,params_dict) # Prepare document results diff --git a/tests/unit_tests/tools/code/test_write_code.py b/tests/unit_tests/tools/code/test_write_code.py index e173db2a8..821fd5ea6 100644 --- a/tests/unit_tests/tools/code/test_write_code.py +++ b/tests/unit_tests/tools/code/test_write_code.py @@ -32,9 +32,9 @@ def test_execute(self, tool): tool.tool_response_manager.get_last_response.return_value = "Mocked Spec" response = tool._execute("Test spec description") - assert response == "File1.py\n```python\nprint('Hello World')\n```\n\nFile2.py\n```python\nprint('Hello again')\n```\n Codes generated and saved successfully in File1.py, File2.py" + assert response == "File1.py\n```python\n#print('Hello World')\n```\n\nFile2.py\n```python\n#print('Hello again')\n```\n Codes generated and saved successfully in File1.py, File2.py" tool.resource_manager.write_file.assert_any_call("README.md", 'File1.py\n') - tool.resource_manager.write_file.assert_any_call("File1.py", "print('Hello World')\n") - tool.resource_manager.write_file.assert_any_call("File2.py", "print('Hello again')\n") + tool.resource_manager.write_file.assert_any_call("File1.py", "#print('Hello World')\n") + tool.resource_manager.write_file.assert_any_call("File2.py", "#print('Hello again')\n") tool.tool_response_manager.get_last_response.assert_called_once_with("WriteSpecTool") \ No newline at end of file