Skip to content

Python: [Agents] Unable to run learn_resources\assistant_code.py sample #11861

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

Closed
jayman-dalal opened this issue May 2, 2025 · 3 comments
Closed
Assignees
Labels
agents python Pull requests for the Python Semantic Kernel

Comments

@jayman-dalal
Copy link

It seems that the files in the resources folder being uploaded are binary files. However, when you prompt (how many countries have population more than usa) the llm to answer question for it, it is expecting a text file.

Output from LLM:
# AuthorRole.ASSISTANT: I am currently unable to access the content of the uploaded files due to an unexpected issue. Please try re-uploading the files or converting them to a different format, such as Excel or CSV, to see if that resolves the issue.

If I change the file open call from 'rb' to 'r', i get this error:

with open(path, "r") as file:
    file = await client.files.create(file=file, purpose="assistants")

Error:

  File "C:\r\learn\semantic-kernel\.venv\Lib\site-packages\httpx\_multipart.py", line 163, in __init__
    raise TypeError(
        "Multipart file uploads must be opened in binary mode, not text mode."
    )
TypeError: Multipart file uploads must be opened in binary mode, not text mode.

Am I missing something?

@markwallace-microsoft markwallace-microsoft added python Pull requests for the Python Semantic Kernel triage labels May 2, 2025
@sophialagerkranspandey sophialagerkranspandey removed python Pull requests for the Python Semantic Kernel triage labels May 5, 2025
@moonbox3
Copy link
Contributor

moonbox3 commented May 8, 2025

Hello @jayman-dalal, what version of SK Python are you using? What is your Azure OpenAI api version?

I am not able to repro this issue - the only issue I am hitting is that I can upload the first file, but then the AsyncAzureOpenAI client hangs (for a long time) while uploading the second file. I don't see this directly hitting OpenAI. Will need to raise the issue with the Azure OpenAI Assistants team.

@moonbox3 moonbox3 added python Pull requests for the Python Semantic Kernel agents labels May 8, 2025
@moonbox3
Copy link
Contributor

moonbox3 commented May 8, 2025

@jayman-dalal, note: when I upgraded the openai package to 1.77.0, that fixed the hang I saw while uploading files. As I said in my previous response, I am able to run the sample without errors. My Azure OpenAI api version is 2025-02-01-preview.

@moonbox3
Copy link
Contributor

Hi @jayman-dalal, we haven't heard from you in a bit. Please ping back on the issue if you need further help, or open a new issue. Thanks.

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

4 participants