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

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

Open
anu43 opened this issue Jan 16, 2025 · 2 comments
Open
Assignees
Labels
agents python Pull requests for the Python Semantic Kernel

Comments

@anu43
Copy link

anu43 commented Jan 16, 2025

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.'}}
@markwallace-microsoft markwallace-microsoft added python Pull requests for the Python Semantic Kernel triage labels Jan 16, 2025
@github-actions github-actions bot changed the title Error when running step8_assistant_vision.py: Invalid value for purpose Python: Error when running step8_assistant_vision.py: Invalid value for purpose Jan 16, 2025
@moonbox3 moonbox3 self-assigned this Jan 16, 2025
@moonbox3 moonbox3 added agents and removed triage labels Jan 16, 2025
@moonbox3
Copy link
Contributor

Hi @anu43, are you running the sample out of the box, without modifications? Please let me know what OpenAI model you're using. I am able to run it with gpt-4o, as an example.

# AuthorRole.USER: 'Describe this image.'
# AuthorRole.ASSISTANT: The image depicts the bustling atmosphere of Times Square in New York City. It's a vibrant scene filled with bright lights and large digital billboards advertising various brands and shows. The scene is crowded with people walking and taking photos, and there are numerous taxis and vehicles on the streets. Visible logos and advertisements include well-known brands such as McDonald's, Samsung, and various Broadway shows. The architecture is tall and modern, with a towering skyline. Signs and billboards contribute to the lively, energetic feel characteristic of Times Square, a major commercial and tourist hub.
# AuthorRole.USER: 'What is the main color in this image?'
# AuthorRole.ASSISTANT: The main color in this image is blue. This is evident from the vast expanse of water surrounding the great white shark and the school of fish. The shades of blue range from light to dark, dominating the image and contributing to the underwater environment's overall appearance.
# AuthorRole.USER: 'Is there an animal in this image?'
# AuthorRole.ASSISTANT: Yes, there is an animal in this image. It features a cat sitting gracefully in a lush, colorful garden. The garden is filled with a variety of flowers and greenery, creating a serene and picturesque setting.

@anu43
Copy link
Author

anu43 commented Jan 18, 2025

I ran this by Azure OpenAI's gpt-4o 2024-02-15-preview. What Azure OpenAI model would you suggest?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agents python Pull requests for the Python Semantic Kernel
Projects
Status: No status
Development

No branches or pull requests

3 participants