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

Can't send files - missing purpose #65

Closed
not4fame opened this issue Jan 18, 2022 · 2 comments
Closed

Can't send files - missing purpose #65

not4fame opened this issue Jan 18, 2022 · 2 comments

Comments

@not4fame
Copy link

Hi I am trying to send files for finetuning from my api service (not command line)
I tried:
return json.loads(requests.post( 'https://api.openai.com/v1/files', headers={'Authorization': 'Bearer '+ os.getenv("OPENAI_API_KEY")}, json={"purpose":"fine-tune"}, files={'file': "\n".join(data)} ).text)
and
return json.loads(requests.post( 'https://api.openai.com/v1/files', headers={'Authorization': 'Bearer '+ os.getenv("OPENAI_API_KEY")}, params={"purpose":"fine-tune"}, files={'file': "\n".join(data)} ).text)

but I got "'purpose' is a required property" error

and when I try:
return json.loads(requests.post( 'https://api.openai.com/v1/files', headers={'Authorization': 'Bearer '+ os.getenv("OPENAI_API_KEY")}, files={"purpose":"fine-tune", 'file': "\n".join(data)} ).text)

I got "'' is not one of ['fine-tune', 'answers', 'search', 'classifications'] - 'purpose'" error

What am I missing?

@hallacy
Copy link
Collaborator

hallacy commented Jan 19, 2022

I think you might you might not need the json param and might just need to another tuple on the files param. Here's how we do it in this repo: https://github.com/openai/openai-python/blob/main/openai/api_resources/file.py#L36

@hallacy hallacy closed this as completed Jan 19, 2022
@not4fame
Copy link
Author

Perfect. Worked like a charm.

baseprime pushed a commit to breezerfp/breeze-openai that referenced this issue Mar 20, 2024
* Add support for search_indices (openai#64)

* Add support for search_indices

* Updated with Schnurr's comments

* Add version to search (openai#65)

* Make search query required (openai#67)
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

2 participants