[F] Use responses api

This commit is contained in:
2026-03-10 16:34:46 -04:00
parent a02ec2101d
commit 5fca24abab
3 changed files with 104 additions and 53 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+28 -17
View File
@@ -17,20 +17,25 @@ def select_best_torrents(torrents_text: str) -> str:
""" """
prompt_path = Path(__file__).parent / "prompt_select_torrents.json" prompt_path = Path(__file__).parent / "prompt_select_torrents.json"
with open(prompt_path, "r", encoding="utf-8") as f: with open(prompt_path, "r", encoding="utf-8") as f:
messages = json.load(f) inputs = json.load(f)
messages.append({ inputs.append({
"role": "user", "role": "user",
"content": torrents_text "content": [
{
"type": "input_text",
"text": torrents_text
}
]
}) })
response = client.chat.completions.create( response = client.responses.create(
model="gpt-5.4", model="gpt-5.4",
messages=messages, input=inputs,
response_format={"type": "text"}, text={"format": {"type": "text"}, "verbosity": "medium"},
verbosity="medium", reasoning={"effort": "medium", "summary": "auto"},
reasoning_effort="medium", store=True,
store=True include=["reasoning.encrypted_content", "web_search_call.action.sources"]
) )
return response.choices[0].message.content return response.choices[0].message.content
@@ -46,19 +51,25 @@ def generate_rename_mapping(directory_text: str) -> dict[str, str]:
""" """
prompt_path = Path(__file__).parent / "prompt_generate_mapping.json" prompt_path = Path(__file__).parent / "prompt_generate_mapping.json"
with open(prompt_path, "r", encoding="utf-8") as f: with open(prompt_path, "r", encoding="utf-8") as f:
messages = json.load(f) inputs = json.load(f)
messages.append({ inputs.append({
"role": "user", "role": "user",
"content": directory_text "content": [
{
"type": "input_text",
"text": directory_text
}
]
}) })
response = client.chat.completions.create( response = client.responses.create(
model="gpt-5.1-codex-mini", model="gpt-5.1-codex-mini",
messages=messages, input=inputs,
response_format={"type": "text"}, text={"format": {"type": "text"}},
reasoning_effort="low", reasoning={"effort": "low"},
store=True store=True,
include=["reasoning.encrypted_content", "web_search_call.action.sources"]
) )
raw_response = response.choices[0].message.content raw_response = response.choices[0].message.content