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

How to set FileName when creating Files? #150

Open
jlewi opened this issue Jan 2, 2025 · 4 comments
Open

How to set FileName when creating Files? #150

jlewi opened this issue Jan 2, 2025 · 4 comments

Comments

@jlewi
Copy link

jlewi commented Jan 2, 2025

@jacobzim-stl
Copy link
Collaborator

jacobzim-stl commented Jan 9, 2025

I believe #91 should help

(Edited to fix link)

@ThadeuMelo
Copy link

I believe [https://github.com/openai/openai-go/issues/91#issuecomment-2451824003](https://github.com/openai/openai-%5Bgo/issues/91#issuecomment-2451824003%5D(https://www.golinks.io/issues/91#issuecomment-2451824003?trackSource=github)) should help

I can't open these links.

Also I think this might be the reason my my current issue:

"{\n \"error\": {\n \"message\": \"Files with extensions [none] are not supported for retrieval. See https://platform.openai.com/docs/assistants/tools/file-search/supported-files\",\n \"type\": \"invalid_request_error\",\n \"param\": \"file_ids\",\n \"code\": \"unsupported_file\"\n }\n}"

I'm uploading .txt files that should be supported.

@jacobzim-stl
Copy link
Collaborator

Sorry about that bad link, does the solution in #91 work?

@vkuptcov
Copy link

vkuptcov commented Jan 14, 2025

@jlewi @jacobzim-stl there is openai.FileParam parameter that might be used in such a case:

func FileParam(reader io.Reader, filename string, contentType string) param.Field[io.Reader] {

// FileParam is a param field helper which helps files with a mime content-type.
func FileParam(reader io.Reader, filename string, contentType string) param.Field[io.Reader] {
	return F[io.Reader](&file{reader, filename, contentType})
}

type file struct {
	io.Reader
	name        string
	contentType string
}

func (f *file) Name() string        { return f.name }
func (f *file) ContentType() string { return f.contentType }

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

No branches or pull requests

4 participants