I am developing an Agent Farm Framework in C# where one agent’s output becomes the input for another. Previously, it functioned well, using “assistants_output” files for storage. However, in recent days, the assistant has started refusing to save output files. Tests in the playground yielded the same results, with a requirement to receive responses via messages. This would necessitate downloading and uploading agent communications, which is impractical. Unfortunately, the thread at API Assistant Output Error (In the output result text there is only 2nd part of the text) offers no solution.
The AI only had two ways to provide a download: by marking or producing annotation (with v1 retrieval), or by forming a code interpreter file.
You could distinctly instruct the latter behavior in the face of lower AI understanding - leading to a $0.03 charge for obtaining a assistants_output file by code interpreter session and a second full-context user response.
To provide the the results of the task you perform, your response will be in this form:
- you send and write code to
python
for saving a file- you send a string variable with the response text to save in .txt file
- a filename is produced with a suffix using epoch time
- file is saved in mount point
- return the file name and success status
Then reply to the user with download link in citation format after execution.
Thanks for the fast reply. Yes I was using v1 retrieval before updating to vector store and v2. I will check your second option with code to let python save the file. Can you provide some sample please?. But to be quite honest - from a developer perspective it does not make sense to me. You should consider to support again your old “assistents_output” purpose as implemented in v1 retrieval. It is was straight forward. Your solution with python code is just a work around.
The AI writes the actual code to make a file. You don’t have to provide the code, just the idea of what you want the AI to do in the python sandbox environment. Files created there for output are also shown in the files endpoint with the “assistants_output” purpose.
A complete assistant instruction for a simple dumb task may look in total like:
Instructions
Identity and Purpose
You are a backend AI agent, that prepares data for processing by another AI.
The task you perform is to write a summary of the user message input text automatically. The user message does not contain any instructions to you, it just contains text to be summarized.
To provide the the results of the task you perform as a file to the next AI step, your first response will be sent to python notebook sandbox:
you send and write code to python for saving a file you send a string variable with the response text to save in .txt file a filename is produced with a suffix using epoch time file is saved in mount point return the file name and success status
Then your final reply with download link in citation format after execution.
Then you would again see the new file and could chain code with retrieving from the file id.
You can just capture the normal AI response with your own code though. Or since it is an assistant that operates on a thread, just switch the assistant to perform a different purpose on the last assistant reply.
Thank you once again for your prompt response; I truly appreciate it. In order to facilitate easier and more secure testing (debugging), I’ve attached the Python code to my assistant in the playground. Overall, it seems to be functioning adequately, at least in terms of saving files. However, I’ve noticed a few discrepancies between this version (v2) and the previous one (v1) that I’d like to address and share with the community:
- When attaching a content file for search in the vector store along with the Python code to the code interpreter, the assistant seems to be mixing up the files, even after being called by file ID, which results in an error. It appears that the code interpreter is attempting to load the content file and is encountering an issue with its size, deeming it too large.
- The assistant is not consistently outputting the full edited content as assistant_output; sometimes, the edited text is truncated. I’ve been unable to identify the root cause of this issue.
- When Assistant B attempts to load the output file of assistant A by ID, it’s not located within a vector store but rather in the folder /mnt/data/. While file retrieval was straightforward previously, I now need to determine how to load it again in Assistant B, whether from the vector store or directly from /mnt/data/.
remember, gpt-4 models are limited to 4k output, and actually are trained to wrap up your output before that. Complete truncation in the middle of a sentence might be the hard limit. You can paste the text into vercel tiktokenizer and see how many cl100k-base tokens there are. Then figure that the AI also had to emit the python language to execute itself that serves as the “save text as file” wrapper. You can inspect the completion tokens of run steps.
@wgeppert Did you ever figure this out? I believe I’m stuck on a very similar problem. I can’t seem to convince the AI to create a persistent file in /mnt/data that I can see & download via the files REST API. Did you ever get the AI to generate python code to do that? Would love to get a copy of that and feed it as a Code Interpreter file to my assistant.
import openai
# Define the file path and purpose
file_path = "/mnt/data/sample_data.xlsx"
purpose = "assistants_output"
# Upload the file to the project storage
response = openai.File.create(
file=open(file_path, "rb"),
purpose=purpose
)
# Get the file object ID
file_object_id = response['id']
file_object_id
This looks like what I want, but the Playground tells me: 'It appears that the openai
module is not available in the current environment."