#template to maximize behavior and constraints for an assistant api based agent
1 messages · Page 1 of 1 (latest)
Hi @stoic sigil. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
To create an Assistant API based agent, you need to specify the model to use. However, you can further customize the behavior of the Assistant using the following parameters:
-
instructions: This parameter guides the personality of the Assistant and defines its goals. Instructions are similar to system messages in the Chat Completions API. -
tools: This parameter gives the Assistant access to up to 128 tools. You can give it access to OpenAI-hosted tools likecode_interpreterandfile_search, or call a third-party tools via afunctioncalling. -
tool_resources: This parameter gives the tools likecode_interpreterandfile_searchaccess to files. Files are uploaded using theFileupload endpoint and must have thepurposeset toassistantsto be used with this API.
Here is an example of how to create an Assistant that can create data visualizations based on a .csv file:
# First, upload a file
file = client.files.create(
file=open("revenue-forecast.csv", "rb"),
purpose='assistants'
)
# Then, create the Assistant with the `code_interpreter` tool enabled and provide the file as a resource to the tool
assistant = client.beta.assistants.create(
name="Data visualizer",
description="You are great at creating beautiful data visualizations. You analyze data present in .csv files, understand trends, and come up with data visualizations relevant to those trends. You also share a brief text summary of the trends observed.",
model="gpt-4o",
tools=[{"type": "code_interpreter"}],
tool_resources={
"code_interpreter": {
"file_ids": [file.id]
}
}
)
For files that are created by AI, they will have a purpose: assistants_output that can be a criteria when you list files. You can receive the created file in the tool attachment type of response or as an annotation, and then can download from storage, offer a download link, replace the source text in AI responses, etc.
For more details, please refer to the OpenAI API documentation (https://platform.openai.com/docs/assistants/deep-dive/creating-assistants) and this OpenAI Community post (https://community.openai.com/t/746574).
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@stoic sigil kapa.ai is still learning and improving, please let us know how it did by reacting below
@proud escarp can you provide the instructions to guide the model through a conversation with a customer
Let me check the knowledge base for you. One moment! :books:
Sure, guiding a model through a conversation involves providing clear instructions or system messages. Here's an example of how you might guide a model to handle a customer service inquiry in a technical support context:
{
"messages": [
{"role": "system", "content": "You will be provided with customer service inquiries that require troubleshooting in a technical support context. Help the user by: \n- Asking them to check that all cables to/from the router are connected. Note that it is common for cables to come loose over time. \n- If all cables are connected and the issue persists, ask them which router model they are using \n- Now you will advise them how to restart their device: \n -- If the model number is MTD-327J, advise them to push the red button and hold it for 5 seconds, then wait 5 minutes before testing the connection. \n -- If the model number is MTD-327S, advise them to unplug and replug it, then wait 5 minutes before testing the connection. \n- If the customer's issue persists after restarting the device and waiting 5 minutes, connect them to IT support by outputting {'IT support requested'}. \n- If the user starts asking questions that are unrelated to this topic then confirm if they would like to end the current chat about troubleshooting and classify their request according to the following scheme: \n<insert primary/secondary classification scheme from above here>"},
{"role": "user", "content": "I need to get my internet working again."}
]
}
In this example, the system message provides a detailed set of instructions for the model to follow when interacting with the user. The user message then initiates the conversation.
Remember, the system message is used to instruct the model how to behave in a conversation, such as adopting a specific tone or following particular guidelines. It's a way to fine-tune the interaction without needing to modify the underlying code or model.
For more details, please refer to the OpenAI API documentation (https://help.openai.com/en/articles/8234522-chat-completions-api-system-message-vs-custom-instructions-in-ui).
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@stone creek kapa.ai is still learning and improving, please let us know how it did by reacting below
@proud escarp and same use case with assistants api?
Let me check the knowledge base for you. One moment! :books:
Sure, with the Assistants API, you can create an assistant with specific instructions to guide it through a conversation. Here's an example of how you might create an assistant for a customer service inquiry in a technical support context:
assistant = client.beta.assistants.create(
name="Technical Support Assistant",
instructions="You will be provided with customer service inquiries that require troubleshooting in a technical support context. Help the user by: \n- Asking them to check that all cables to/from the router are connected. Note that it is common for cables to come loose over time. \n- If all cables are connected and the issue persists, ask them which router model they are using \n- Now you will advise them how to restart their device: \n -- If the model number is MTD-327J, advise them to push the red button and hold it for 5 seconds, then wait 5 minutes before testing the connection. \n -- If the model number is MTD-327S, advise them to unplug and replug it, then wait 5 minutes before testing the connection. \n- If the customer's issue persists after restarting the device and waiting 5 minutes, connect them to IT support by outputting 'IT support requested'. \n- If the user starts asking questions that are unrelated to this topic then confirm if they would like to end the current chat about troubleshooting and classify their request according to the following scheme: \n<insert primary/secondary classification scheme from above here>",
model="gpt-4-1106-preview",
)
In this example, the instructions parameter provides a detailed set of instructions for the assistant to follow when interacting with the user.
Remember, the instructions parameter is used to instruct the assistant how to behave in a conversation, such as adopting a specific tone or following particular guidelines. It's a way to fine-tune the interaction without needing to modify the underlying code or model.