diff --git a/memgpt/cli/cli_config.py b/memgpt/cli/cli_config.py index 444f20d261..b29381e910 100644 --- a/memgpt/cli/cli_config.py +++ b/memgpt/cli/cli_config.py @@ -1150,7 +1150,7 @@ def add( ms = MetadataStore(config) if filename: # read from file assert text is None, "Cannot specify both text and filename" - with open(filename, "r", encoding='utf-8') as f: + with open(filename, "r", encoding="utf-8") as f: text = f.read() if option == "persona": persona = ms.get_persona(name=name, user_id=user_id) diff --git a/memgpt/client/admin.py b/memgpt/client/admin.py index c30f795d71..9446995230 100644 --- a/memgpt/client/admin.py +++ b/memgpt/client/admin.py @@ -87,7 +87,7 @@ def _reset_server(self): # tools (currently only available for admin) def create_tool(self, name: str, file_path: str, source_type: Optional[str] = "python", tags: Optional[List[str]] = None) -> ToolModel: """Add a tool implemented in a file path""" - source_code = open(file_path, "r", encoding='utf-8').read() + source_code = open(file_path, "r", encoding="utf-8").read() data = {"name": name, "source_code": source_code, "source_type": source_type, "tags": tags} response = requests.post(f"{self.base_url}/api/tools", json=data, headers=self.headers) if response.status_code != 200: diff --git a/memgpt/functions/functions.py b/memgpt/functions/functions.py index e6097dea7c..c75c74a99c 100644 --- a/memgpt/functions/functions.py +++ b/memgpt/functions/functions.py @@ -69,7 +69,7 @@ def write_function(module_name: str, function_name: str, function_code: str): # Write the function to a file file_path = os.path.join(USER_FUNCTIONS_DIR, f"{module_name}.py") - with open(file_path, "w", encoding='utf-8') as f: + with open(file_path, "w", encoding="utf-8") as f: f.write(function_code) succ, error = validate_function(module_name, file_path) diff --git a/memgpt/local_llm/llm_chat_completion_wrappers/configurable_wrapper.py b/memgpt/local_llm/llm_chat_completion_wrappers/configurable_wrapper.py index cb8cb14caa..9d272449d5 100644 --- a/memgpt/local_llm/llm_chat_completion_wrappers/configurable_wrapper.py +++ b/memgpt/local_llm/llm_chat_completion_wrappers/configurable_wrapper.py @@ -346,7 +346,7 @@ def save_to_yaml(self, file_path: str): "default_stop_sequences": self.default_stop_sequences, } - with open(file_path, "w", encoding='utf-8') as yaml_file: + with open(file_path, "w", encoding="utf-8") as yaml_file: yaml.dump(data, yaml_file, default_flow_style=False) @staticmethod @@ -357,7 +357,7 @@ def load_from_yaml(file_path: str): Args: file_path (str): The path to the YAML file. """ - with open(file_path, "r", encoding='utf-8') as yaml_file: + with open(file_path, "r", encoding="utf-8") as yaml_file: data = yaml.safe_load(yaml_file) wrapper = ConfigurableJSONWrapper() diff --git a/memgpt/presets/presets.py b/memgpt/presets/presets.py index 919b36964f..fd5fe78556 100644 --- a/memgpt/presets/presets.py +++ b/memgpt/presets/presets.py @@ -53,7 +53,7 @@ def add_default_tools(user_id: uuid.UUID, ms: MetadataStore): def add_default_humans_and_personas(user_id: uuid.UUID, ms: MetadataStore): for persona_file in list_persona_files(): - text = open(persona_file, "r", encoding='utf-8').read() + text = open(persona_file, "r", encoding="utf-8").read() name = os.path.basename(persona_file).replace(".txt", "") if ms.get_persona(user_id=user_id, name=name) is not None: printd(f"Persona '{name}' already exists for user '{user_id}'") @@ -61,7 +61,7 @@ def add_default_humans_and_personas(user_id: uuid.UUID, ms: MetadataStore): persona = PersonaModel(name=name, text=text, user_id=user_id) ms.add_persona(persona) for human_file in list_human_files(): - text = open(human_file, "r", encoding='utf-8').read() + text = open(human_file, "r", encoding="utf-8").read() name = os.path.basename(human_file).replace(".txt", "") if ms.get_human(user_id=user_id, name=name) is not None: printd(f"Human '{name}' already exists for user '{user_id}'") diff --git a/memgpt/server/rest_api/server.py b/memgpt/server/rest_api/server.py index 0399d0e60a..6e080c37a3 100644 --- a/memgpt/server/rest_api/server.py +++ b/memgpt/server/rest_api/server.py @@ -121,7 +121,7 @@ def on_startup(): memgpt_api = app.openapi_schema.copy() memgpt_api["paths"] = {key: value for key, value in memgpt_api["paths"].items() if not key.startswith(OPENAI_API_PREFIX)} memgpt_api["info"]["title"] = "MemGPT API" - with open("openapi_memgpt.json", "w", encoding='utf-8') as file: + with open("openapi_memgpt.json", "w", encoding="utf-8") as file: print(f"Writing out openapi_memgpt.json file") json.dump(memgpt_api, file, indent=2) @@ -132,7 +132,7 @@ def on_startup(): if not (key.startswith(API_PREFIX) or key.startswith(ADMIN_PREFIX)) } openai_assistants_api["info"]["title"] = "OpenAI Assistants API" - with open("openapi_assistants.json", "w", encoding='utf-8') as file: + with open("openapi_assistants.json", "w", encoding="utf-8") as file: print(f"Writing out openapi_assistants.json file") json.dump(openai_assistants_api, file, indent=2) diff --git a/memgpt/utils.py b/memgpt/utils.py index a16f7cdeb4..1ff2c50862 100644 --- a/memgpt/utils.py +++ b/memgpt/utils.py @@ -978,7 +978,7 @@ def get_human_text(name: str, enforce_limit=True): for file_path in list_human_files(): file = os.path.basename(file_path) if f"{name}.txt" == file or name == file: - human_text = open(file_path, "r", encoding='utf-8').read().strip() + human_text = open(file_path, "r", encoding="utf-8").read().strip() if enforce_limit and len(human_text) > CORE_MEMORY_HUMAN_CHAR_LIMIT: raise ValueError(f"Contents of {name}.txt is over the character limit ({len(human_text)} > {CORE_MEMORY_HUMAN_CHAR_LIMIT})") return human_text @@ -990,7 +990,7 @@ def get_persona_text(name: str, enforce_limit=True): for file_path in list_persona_files(): file = os.path.basename(file_path) if f"{name}.txt" == file or name == file: - persona_text = open(file_path, "r", encoding='utf-8').read().strip() + persona_text = open(file_path, "r", encoding="utf-8").read().strip() if enforce_limit and len(persona_text) > CORE_MEMORY_PERSONA_CHAR_LIMIT: raise ValueError( f"Contents of {name}.txt is over the character limit ({len(persona_text)} > {CORE_MEMORY_PERSONA_CHAR_LIMIT})" @@ -1004,7 +1004,7 @@ def get_human_text(name: str): for file_path in list_human_files(): file = os.path.basename(file_path) if f"{name}.txt" == file or name == file: - return open(file_path, "r", encoding='utf-8').read().strip() + return open(file_path, "r", encoding="utf-8").read().strip() def get_schema_diff(schema_a, schema_b):