Skip to content

Python: Error when running step8_assistant_vision.py: Invalid value for purpose #10211

Closed
@anu43

Description

Description

When running step8_assistant_vision.py from the main repository, an error occurs indicating an invalid value for the purpose parameter.

Steps to Reproduce

  1. Clone the semantic-kernel repository
  2. Navigate to python/samples/getting_started_with_agents/
  3. Run python step8_assistant_vision.py

Expected Behavior

The script should run without errors and process the cat image.

Actual Behavior

The script fails with an error: openai.BadRequestError: Error code: 400 - {'error': {'code': 'invalidPayload', 'message': 'Invalid value for purpose.'}}

Environment

  • Operating System: macOS 15.2
  • Python version: Python 3.10.13
  • Semantic Kernel version: semantic-kernel==1.18.2
  • OpenAI library version: openai==1.59.7

Error Message

Traceback (most recent call last):
  File "/Users/nihat/Documents/epam/semantic-kernel/python/samples/getting_started_with_agents/step8_assistant_vision.py", line 137, in <module>
    asyncio.run(main())
  File "/opt/homebrew/anaconda3/envs/sem-kernel/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/opt/homebrew/anaconda3/envs/sem-kernel/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/Users/nihat/Documents/epam/semantic-kernel/python/samples/getting_started_with_agents/step8_assistant_vision.py", line 101, in main
    file_id = await agent.add_file(cat_image_file_path, purpose="vision")
  File "/opt/homebrew/anaconda3/envs/sem-kernel/lib/python3.10/site-packages/semantic_kernel/agents/open_ai/open_ai_assistant_base.py", line 553, in add_file
    file = await self.client.files.create(file=file, purpose=purpose)  # type: ignore
  File "/opt/homebrew/anaconda3/envs/sem-kernel/lib/python3.10/site-packages/openai/resources/files.py", line 443, in create
    return await self._post(
  File "/opt/homebrew/anaconda3/envs/sem-kernel/lib/python3.10/site-packages/openai/_base_client.py", line 1849, in post
    return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
  File "/opt/homebrew/anaconda3/envs/sem-kernel/lib/python3.10/site-packages/openai/_base_client.py", line 1543, in request
    return await self._request(
  File "/opt/homebrew/anaconda3/envs/sem-kernel/lib/python3.10/site-packages/openai/_base_client.py", line 1644, in _request
    raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {'error': {'code': 'invalidPayload', 'message': 'Invalid value for purpose.'}}

Metadata

Assignees

Labels

agentspythonPull requests for the Python Semantic Kernel

Type

No type

Projects

  • Status

    No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions