Skip to content

Conversation

@mplawley
Copy link
Contributor

When the Assistants API is asked to search a file store, it replies with a response that does not include properties required by the MessageObject's CodingKeys. This leads to a decoding error. This PR makes those values optional so that:

  1. Current Assistants API responses that are successfully decoded are still decoded successfully
  2. Assistants API responses with data from a file_search, which do not contain FileCitation.type, FileCitation.text, FileCitation.startIndex, and FileCitation.endIndex, also work

TEST PLAN

  1. Create an Assistant AI in OpenAI and note its agent_id. Attach a file store with at least one text file.
  2. Create a skeleton project that utilizes SwiftOpenAI's current main branch to handle an Assistant interaction, such as in a conversation.
  3. Create a thread with the assistant and send a message, such as "May I ask you a question?"
  4. Note that the response is decoded successfully to an in-memory representation of the OpenAI Response.
  5. Now send a message such as "Please search your file store for advice on how to decode API responses."
  6. Note the CodingKeys error.
  7. Now switch to this branch. Perform steps 3-5. Note there are no errors and that the client can now receive responses that contain file citations from the Assistant.

Copy link
Owner

@jamesrochabrun jamesrochabrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! thanks

@jamesrochabrun jamesrochabrun merged commit df42703 into jamesrochabrun:main Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants