diff --git a/samples/agent/adk/contact_lookup/prompt_builder.py b/samples/agent/adk/contact_lookup/prompt_builder.py index 3fe269e6..ffd1ee33 100644 --- a/samples/agent/adk/contact_lookup/prompt_builder.py +++ b/samples/agent/adk/contact_lookup/prompt_builder.py @@ -113,6 +113,6 @@ def get_text_prompt() -> str: my_base_url = "http://localhost:8000" contact_prompt = get_ui_prompt(my_base_url, CONTACT_UI_EXAMPLES) print(contact_prompt) - with open("generated_prompt.txt", "w") as f: + with open("generated_prompt.txt", "w", encoding="utf-8") as f: f.write(contact_prompt) print("\nGenerated prompt saved to generated_prompt.txt") diff --git a/samples/agent/adk/contact_lookup/tools.py b/samples/agent/adk/contact_lookup/tools.py index 56c9e15e..4a73c4b7 100644 --- a/samples/agent/adk/contact_lookup/tools.py +++ b/samples/agent/adk/contact_lookup/tools.py @@ -34,7 +34,7 @@ def get_contact_info(name: str, tool_context: ToolContext, department: str = "") try: script_dir = os.path.dirname(__file__) file_path = os.path.join(script_dir, "contact_data.json") - with open(file_path) as f: + with open(file_path, encoding='utf-8') as f: contact_data_str = f.read() if base_url := tool_context.state.get("base_url"): contact_data_str = contact_data_str.replace("http://localhost:10002", base_url) diff --git a/samples/agent/adk/restaurant_finder/prompt_builder.py b/samples/agent/adk/restaurant_finder/prompt_builder.py index 1cc8445e..98499266 100644 --- a/samples/agent/adk/restaurant_finder/prompt_builder.py +++ b/samples/agent/adk/restaurant_finder/prompt_builder.py @@ -859,6 +859,6 @@ def get_text_prompt() -> str: print(restaurant_prompt) # This demonstrates how you could save the prompt to a file for inspection - with open("generated_prompt.txt", "w") as f: + with open("generated_prompt.txt", "w", encoding="utf-8") as f: f.write(restaurant_prompt) print("\nGenerated prompt saved to generated_prompt.txt") diff --git a/samples/agent/adk/restaurant_finder/tools.py b/samples/agent/adk/restaurant_finder/tools.py index 6a6dd453..a8c73b3a 100644 --- a/samples/agent/adk/restaurant_finder/tools.py +++ b/samples/agent/adk/restaurant_finder/tools.py @@ -34,7 +34,7 @@ def get_restaurants(cuisine: str, location: str, tool_context: ToolContext, cou try: script_dir = os.path.dirname(__file__) file_path = os.path.join(script_dir, "restaurant_data.json") - with open(file_path) as f: + with open(file_path, encoding='utf-8') as f: restaurant_data_str = f.read() if base_url := tool_context.state.get("base_url"): restaurant_data_str = restaurant_data_str.replace("http://localhost:10002", base_url)