Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions flexeval/core/language_model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class LMOutput:
"""
The raw output text of the language model before post-processing.
"""
reasoning_text: str | None = None
"""
The output reasoning text of the language model.
"""
finish_reason: str | None = None
"""
The reason why the generation is finished.
Expand Down
9 changes: 7 additions & 2 deletions flexeval/core/language_model/openai_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def _parallel_run_chatgpt(
idx = future_to_idx[future]
results[idx] = future.result()
if prog_every_n and (done_count % prog_every_n == 0 or done_count == total):
logger.info(f"[progress] {done_count}/{total} ({done_count/total:.1%}) done")
logger.info(f"[progress] {done_count}/{total} ({done_count / total:.1%}) done")

return results

Expand All @@ -216,7 +216,11 @@ def _batch_complete_text(
**kwargs,
)
outputs = [
LMOutput(text=res.choices[0].message.content, finish_reason=res.choices[0].finish_reason)
LMOutput(
text=res.choices[0].message.content,
reasoning_text=getattr(res.choices[0].message, "reasoning_content", None),
finish_reason=res.choices[0].finish_reason,
)
for res in api_responses
]

Expand All @@ -234,6 +238,7 @@ def _batch_generate_chat_response(
outputs = [
LMOutput(
text=res.choices[0].message.content,
reasoning_text=getattr(res.choices[0].message, "reasoning_content", None),
finish_reason=res.choices[0].finish_reason,
tool_calls=[tool_call.to_dict() for tool_call in res.choices[0].message.tool_calls]
if res.choices[0].message.tool_calls
Expand Down
Loading