Skip to content

[Feature]: Ad-hoc fixes for OpenAI GPT-5.X models #91

Description

@iamyifan

Is your feature request related to a problem? Please describe.

First, thanks for developing this awesome tool :)
I've checked the Issues and Pull requests sessions but it seems like no one mentioned how to customize the current code base for the latest GPT-5.X models.
Hope this ad-hoc style fix will help other people.

Problem and ad-hoc fixes:

When I am using api-endpoint in config.yaml file, the default model=gpt-4o works perfectly fine with my API key. However, when I set, e.g., model=gpt-5.2, then run the create step:
1, The error shows that "max_token" is not a valid parameter from OpenAI, then I changed max_token to max_completion_tokens in several places in API calling functions.
2. The error shows that top_p is not a valid parameter from OpenAI, then I removed top_p from several places in API calling functions.
3. The error shows that temperature has to be set to the default value 1, then I hard coded temperature=1 in several places in API calling functions.

# llm_client.py

# line 174 - 180
response = self.openai_client.chat.completions.create(
                    model=self.model,
                    messages=messages,
                    temperature=1,  # hard code to 1
                    max_completion_tokens=max_tokens, # change from max_tokens
                    #top_p=top_p  # ignore top_p
                )

# line 513 - 520
task = self._process_message_async(
                        messages=messages,
                        temperature=1,  # hard code to 1
                        max_tokens=max_tokens,
                        top_p=top_p,
                        verbose=verbose,
                        debug_mode=debug_mode
                    )

Until now, the code can run create step and generate QA pairs successfully with GPT-5.X models.
4. Still, in the log, it shows ERROR:asyncio ... RuntimeError('Event loop is closed') after finishing each document.
To fix the annoying errors, I modified async def _process_message_async from:

async_client = AsyncOpenAI(**client_kwargs)  # llm_client.py, line 366
        
for attempt in range(self.max_retries):  #  llm_client.py, line 368-484
    ...

to:

async with AsyncOpenAI(**client_kwargs) as async_client:  # llm_client.py
    for attempt in range(self.max_retries):

I.e., ensure the async HTTP client is closed while the event loop is still alive.

After finishing the all four steps, the code can now use GPT-5.X models with an API key from OpenAI.

Describe the solution you'd like

Update the code base to adapt to the latest OpenAI API calling format.

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions