Skip to content

Commit 916b7b3

Browse files
committed
Improve robustness of promptfoo runner subprocess.run call
1 parent 134dc7e commit 916b7b3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

promptfoo/promptfoo_test_runner.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import re
33
import subprocess
4+
import sys
45
from typing import Tuple
56

67

@@ -26,7 +27,7 @@ def call_api(prompt: str, context: dict, metadata: dict) -> dict:
2627
submission_type = None
2728

2829
cmd_args = [
29-
"python3",
30+
sys.executable,
3031
"-m",
3132
"ai_feedback",
3233
"--scope",
@@ -76,7 +77,7 @@ def call_api(prompt: str, context: dict, metadata: dict) -> dict:
7677
result = subprocess.run(
7778
cmd_args,
7879
capture_output=True,
79-
env=env,
80+
env={'PYTHONIOENCODING': 'utf-8', **env},
8081
text=True,
8182
)
8283

0 commit comments

Comments
 (0)