Skip to content

Conversation

codenamev
Copy link
Contributor

@codenamev codenamev commented Nov 7, 2023

This adds support for the new OpenAI Assistant Files API.

It is dependent on #361. I have rebased off of that.

@alexrudall
Copy link
Owner

That was fast :D

@Oldharlem
Copy link

Missing threads and messages for the complete assistant flow.
Will work on it tomorrow if not already on it.

@etewiah
Copy link

etewiah commented Nov 8, 2023

Looks like there is this too which is aiming for the same goal:

#361

@Haegin
Copy link
Contributor

Haegin commented Nov 8, 2023

Looks like there is this too which is aiming for the same goal:

#361

Yeah sorry, I didn't see this PR until I'd already written most of mine. I've not added any of the file handling stuff though so it'd be good to add these changes in as you're further ahead there. Are you okay with that @codenamev?

@codenamev
Copy link
Contributor Author

Looks like there is this too which is aiming for the same goal:
#361

Yeah sorry, I didn't see this PR until I'd already written most of mine. I've not added any of the file handling stuff though so it'd be good to add these changes in as you're further ahead there. Are you okay with that @codenamev?

Woah, #361 is way better than this 😆 Haha, yeah for sure, I'll update to focus on assistant file updates.

@codenamev codenamev changed the title Adds OpeAI::Assistants and .list, .create, .retrieve, .modify, .delete Adds OpeAI::AssistantFiles Nov 9, 2023
@codenamev codenamev marked this pull request as ready for review November 16, 2023 16:52
@codenamev
Copy link
Contributor Author

@alexrudall I don't really know how to fix the VCR issues 🆘

@client.multipart_post(
path: "/files",
parameters: parameters.merge(
file: File.open(parameters[:file]),

Choose a reason for hiding this comment

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

I think we should require file be an IO object instead of an actual file - thoughts?

Copy link
Owner

@alexrudall alexrudall Dec 5, 2023

Choose a reason for hiding this comment

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

I think I agree, can you say more about this though @allcentury ? What's the reasoning?

Copy link

@allcentury allcentury Dec 9, 2023

Choose a reason for hiding this comment

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

As an example, I am generating a "File" from a database query. With this current approach, I have to actually write to a file, then pass it here only to be read again. That said, in ruby File#open and other File commands returns an IO object which is what Net::HTTP and other adapters want when sending over HTTP.

@client.upload(file:  File.read("my_file"))

# OR

io = IO.new
output = SomeDatabaseQuery.extract
io.puts output
io.rewind

@client.upload(file: io)

In this case, it works for all use cases and users don't need to write temporary files to disk if they won't want to.

Copy link
Owner

Choose a reason for hiding this comment

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

@allcentury thanks for the suggestion - this has now been added in #420 💨

@alexrudall
Copy link
Owner

Thanks for your work on this @codenamev - closing as OpenAI have deprecated AssistantFiles for v2 of the beta

@alexrudall alexrudall closed this Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants