Skip to content

Commit

Permalink
fix: use zoltraak prompt as md file
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu007 committed Jan 23, 2025
1 parent 7149565 commit 136594e
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/codeinterpreterapi/tools/zoltraak.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,27 @@ async def arun_prompt(self, prompt: str, name: str) -> str:
return self._common_run(prompt, name, ZoltraakCompilerEnum.PROMPT.value)

def _common_run(self, prompt: str, name: str, compiler: str):
# mdファイルを生成して内容をreturnする
input_md_filename = f"{name}.md"
output_md_path = f"pre_{input_md_filename}"
output_md_path = os.path.abspath(output_md_path)
# inputのmdファイル名と生成される場所
input_md_filename = f"{name}_{compiler}.md"
output_md_path = os.path.abspath(f"pre_{input_md_filename}")

# promptのmdファイルを生成する
prompt_md_filename = f"prompt_{input_md_filename}"
prompt_output_md_path = os.path.abspath(prompt_md_filename)

# promptをmdファイルに書き込む
with open(prompt_output_md_path, "w", encoding="utf-8") as file:
file.write(prompt)

try:
# シェルインジェクションを防ぐためにshlexを使用
args = []
args.append('zoltraak')
args.append(f"\"{input_md_filename}\"")
# args.append(f"\"{input_md_filename}\"")
args.append('-p')
args.append(f"\"{prompt}\"")
# args.append('-c')
# args.append(f"\"{compiler}\"")
args.append(f"\"{prompt_md_filename}\"")
args.append('-c')
args.append(f"\"{input_md_filename}\"")
args.append('-ml')
args.append('1_')
args.append('-mle')
Expand Down

0 comments on commit 136594e

Please sign in to comment.