Skip to content

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

Closed
@jayman-dalal

Description

@jayman-dalal

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?

Metadata

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