Skip to content

Commit 26f0894

Browse files
committed
Simplify
1 parent a7211cd commit 26f0894

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

src/cwhy/explain.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,14 @@ def complete(client: openai.OpenAI, args: argparse.Namespace, prompt: str) -> No
6565
raise e
6666

6767

68-
def evaluate(client: openai.OpenAI, args: argparse.Namespace, stdin: str) -> None:
69-
evaluate_text_prompt(client, args, prompts.explain_prompt(args, stdin))
70-
71-
7268
def explain(args: argparse.Namespace, stdin: str) -> None:
7369
if (
7470
"OPENAI_BASE_URL" in os.environ
7571
and "api.openai.com" not in os.environ["OPENAI_BASE_URL"]
7672
):
77-
# Pass a dummy API key on purpose:
78-
# None would make the OpenAI client throw an error.
79-
# A blank string will cause an invalid HTTP header error.
73+
# Pass a dummy API key in the default case on purpose:
74+
# 'None' will make the OpenAI client throw an error.
75+
# '""' will cause an invalid HTTP header error.
8076
client = openai.OpenAI(
8177
api_key=os.environ.get("OPENAI_API_KEY", "OPENAI_API_KEY")
8278
)
@@ -102,14 +98,4 @@ def explain(args: argparse.Namespace, stdin: str) -> None:
10298
else:
10399
client = openai.OpenAI()
104100

105-
evaluate(client, args, stdin)
106-
107-
108-
def evaluate_text_prompt(
109-
client: openai.OpenAI, args: argparse.Namespace, prompt: str, wrap: bool = True
110-
) -> None:
111-
usage = complete(client, args, prompt)
112-
# print(usage)
113-
# text += "\n\n"
114-
# text += f"({completion.usage.prompt_tokens} prompt tokens, "
115-
# text += f"{completion.usage.completion_tokens} completion tokens.)"
101+
complete(client, args, prompts.explain_prompt(args, stdin))

0 commit comments

Comments
 (0)