Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileSearchToolCall.file_search has empty results #1966

Open
1 task
dominpm opened this issue Dec 19, 2024 · 2 comments
Open
1 task

FileSearchToolCall.file_search has empty results #1966

dominpm opened this issue Dec 19, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@dominpm
Copy link

dominpm commented Dec 19, 2024

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

Continuing from issue : #1938

The error seems to be fixed with openai==1.58.1 (it does not return a 400 error anymore). However if we capture the output of the stream with a custom class inheriting from AssistantEventHandler the results of the fileSearch tool are not available:

@override
def on_tool_call_done(self, tool_call: ToolCall):
    print(tool_call)

Of which the results are:

FileSearchToolCall(id='call_ID', file_search=FileSearch(ranking_options=FileSearchRankingOptions(ranker='default_2024_08_21', score_threshold=0.0), results=[]), type='file_search', index=0)

where following from openai.types.beta.threads.runs.file_search_tool_call.py it supposed to show:

class FileSearch(BaseModel):
    ranking_options: Optional[FileSearchRankingOptions] = None
    """The ranking options for the file search."""

    results: Optional[List[FileSearchResult]] = None
    """The results of the file search."""

when creating the run as follows:

  with client.beta.threads.runs.stream(
      thread_id=thread.id,
      assistant_id=ass_id,
      event_handler=CustomEventHandler(),
      include=["step_details.tool_calls[*].file_search.results[*].content"]
      ) as stream:
      # Wait for the stream to complete
      stream.until_done()

To Reproduce

  1. Run this with the id of an assistant connected to a vector store and the file search enabled (for simplicity do such thing through platform.openai.com)
from typing import override
from openai import AssistantEventHandler
from openai import OpenAI
from openai.types.beta.threads.runs.tool_call import ToolCall

client = OpenAI()
messages = [
    {
        "content": <QUESTION_TO_THE_ASSISTANT>,
    }
]

# Create a new thread for the assistant
thread = client.beta.threads.create()
client.beta.threads.messages.create(
    thread_id=thread.id,
    role="user",
    content=messages[-1]["content"]
)


class CustomEventHandler(AssistantEventHandler):
    @override
    def on_tool_call_done(self, tool_call: ToolCall):
        print(tool_call)

# Stream the assistant's response
with client.beta.threads.runs.stream(
    thread_id=thread.id,
    assistant_id=<ASSISTANT_ID>,
    event_handler=CustomEventHandler(),
    include=["step_details.tool_calls[*].file_search.results[*].content"]
    ) as stream:
    # Wait for the stream to complete
    stream.until_done()

Code snippets

No response

OS

Windows

Python version

Python 3.11.10

Library version

openai 1.58.1

@dominpm dominpm added the bug Something isn't working label Dec 19, 2024
@dominpm
Copy link
Author

dominpm commented Dec 26, 2024

It seems it has been chosen not to retrieve (or show) the results as we can see from the comments on this class:

class FileSearchToolCall(BaseModel):
    id: str
    """The ID of the tool call object."""

    file_search: FileSearch
    """For now, this is always going to be an empty object."""

    type: Literal["file_search"]
    """The type of tool call.

    This is always going to be `file_search` for this type of tool call.
    """

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants
@dominpm and others