artefactual.preprocessing.openai_parser#
Functions
|
Detects if the output follows the signature of the new OpenAI Responses API. |
|
Processes log probabilities from OpenAI Chat Completion (classic 'choices' format). |
|
Parses the response from the 'client.responses.create' API to extract log probabilities. |
- artefactual.preprocessing.openai_parser.is_openai_responses_api(outputs)[source]#
Detects if the output follows the signature of the new OpenAI Responses API.
- Return type:
- Args:
outputs (Any): The output object or dictionary to inspect.
- Returns:
bool: True if the output matches the OpenAI Responses API signature, False otherwise.
- artefactual.preprocessing.openai_parser.process_openai_chat_completion(response, iterations)[source]#
Processes log probabilities from OpenAI Chat Completion (classic ‘choices’ format).
- Args:
response (Any): The response object or dictionary from OpenAI API (ChatCompletion). iterations (int): The number of iterations (choices) to process.
- Returns:
list[dict[int, list[float]]]: A list of dictionaries, where each dictionary maps token indices to lists of log probabilities for a sequence.
- artefactual.preprocessing.openai_parser.process_openai_responses_api(response)[source]#
Parses the response from the ‘client.responses.create’ API to extract log probabilities.
Structure expected: response.output -> [item] -> item.content -> [part] -> part.logprobs
- Args:
response (Any): The response object from the OpenAI Responses API.
- Returns:
list[dict[int, list[float]]]: A list of dictionaries, where each dictionary maps token indices to lists of log probabilities for a sequence.