Skip to content

Commit

Permalink
codacy: set encoding when reading & writing output
Browse files Browse the repository at this point in the history
  • Loading branch information
phanhongan committed Nov 15, 2024
1 parent 9984030 commit 45837c8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/llamarine/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def main(use_domain_lm: bool = False):

if 'agent_solutions' not in st.session_state:
if os.path.exists(OUTPUT_FILE_PATH):
with open(file=OUTPUT_FILE_PATH, mode='r') as f:
with open(file=OUTPUT_FILE_PATH, mode='r', encoding='utf-8') as f:
st.session_state.agent_solutions: defaultdict[str, str] = defaultdict(str, json.loads(f.read()))
else:
st.session_state.agent_solutions: defaultdict[str, str] = defaultdict(str)
Expand All @@ -87,7 +87,7 @@ def main(use_domain_lm: bool = False):
get_or_create_agent(use_domain_lm).solve(
problem=st.session_state.typed_problem, allow_reject=True)
# write st.session_state.agent_solutions to JSON file
with open(file=OUTPUT_FILE_PATH, mode='w') as f:
with open(file=OUTPUT_FILE_PATH, mode='w', encoding='utf-8') as f:
f.write(json.dumps(st.session_state.agent_solutions))

solution = st.session_state.agent_solutions[st.session_state.typed_problem]
Expand Down

0 comments on commit 45837c8

Please sign in to comment.