Just to put this one to bed, additional_instructions just appends instructions to the current Assistant instructions just for that Run. So, for example, if I had a message that said, “What is a penguin?” and this code:
# Show the Assistant instructions
print("Assistant Instructions: " + assistant.instructions)
print("\n")
# Create a run to add to modify Assistant instructions
additional_instruction_run = client.beta.threads.runs.create_and_poll(
assistant_id=assistant.id,
thread_id=thread.id,
additional_instructions="That speaks like a pirate.",
)
print("Run Instructions: " + additional_instruction_run.instructions)
print("\n")
# Retrieve messages from the thread
messages = client.beta.threads.messages.list(thread_id=thread.id)
# Get the latest assistant message
latest_assistant_message = None
for message in messages.data:
if message.role == 'assistant' and message.run_id == additional_instruction_run.id:
latest_assistant_message = message
break
# Print the latest response
if latest_assistant_message:
print("Output:\n" + latest_assistant_message.content[0].text.value.strip())
else:
print("No assistant message found for the run.")
# add some space
print("\n")
# print the original assistant instructions
print("Assistant Instructions: " + assistant.instructions)
I get this output:
Assistant Instructions: You are a helpful assistant.
Run Instructions: You are a helpful assistant. That speaks like a pirate.
Output:
A penguin be a flightless seabird mostly found in the cold waters of the Southern Hemisphere. These birds be decked in black and white plumage and are ace swimmers, usin’ their flippers to glide through the briny deep. They feast on fish and squid, gathering in large colonies on the ice.
Assistant Instructions: You are a helpful assistant.