Azure / AI-in-a-Box

AI-in-a-Box leverages the expertise of Microsoft across the globe to develop and provide AI and ML solutions to the technical community. Our intent is to present a curated collection of solution accelerators that can help engineers establish their AI/ML environments and solutions rapidly and with minimal friction.
MIT License
529 stars 180 forks source link

[BUG] Issue with ... gen-ai/Assistants/api-in-a-box/failed_banks/example #46

Closed bhasampa closed 8 months ago

bhasampa commented 8 months ago

Getting following error when I try to run in my machine.

File ~/anaconda3/envs/py310/lib/python3.10/site-packages/openai/_base_client.py:898, in SyncAPIClient._request(self, cast_to, options, remaining_retries, stream, stream_cls) 895 if not err.response.is_closed: 896 err.response.read() --> 898 raise self._make_status_error_from_response(err.response) from None 899 except httpx.TimeoutException as err: 900 if response is not None:

BadRequestError: Error code: 400 - {'error': {'code': 'invalidPayload', 'message': 'Invalid value for purpose.'}}

Kee2u commented 8 months ago

Where do you get this error?

roel4ez commented 8 months ago

I'm having exactly the same issue - it's happening on the upload call:

def upload_file(client: AzureOpenAI, path: str) -> FileObject:
    with Path(path).open("rb") as f:
        return client.files.create(file=f, purpose="assistants")

I tried using the OpenAI client instead, and the same issue happens. I also checked, when changing the purpose to fine-tune, it returns 'fileName contains an invalid filename: wrong suffix.', which is expected since I'm using a PDF, and the fine-tune expects only jsonl.

I'm using the 2024-02-15-preview version, and the latest version of the openai library.

Update: tested directly with API via REST, and I'm getting the same error. Observations:

Tested against Azure OpenAI in region US East.

bhasampa commented 8 months ago

Dear All,

I had updated the file name in path as variable

def upload_file(client: AzureOpenAI, path: str) -> FileObject: with Path('data_0212.csv').open("rb") as f: print(f) return client.files.create(file=f, purpose="assistants")

Code started working..

Thanks, Bhaskar

danny-avila commented 7 months ago

@bhasampa I'm facing this issue now. Are you able to reproduce a working REST method?

danny-avila commented 7 months ago

Figured it out, for anyone that finds this. For me it was a region issue. I manage several different regions in my application so the region must be Assistants compatible: https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#assistants-preview

arunganesh36 commented 2 months ago

Hey @danny-avila, I'm facing the same issue today with Rest API and my current region (eastUs) supports Assistants. Can you share which region you tried with?