#Assistants API Playground

1 messages · Page 1 of 1 (latest)

young hawk
#

Why am i not able to see the threads made in my Assistant in Assistants API Playground?

nocturne creekBOT
#

Hi @young hawk. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the information provided in the extracts, it seems that there was an issue with viewing threads in the Assistants API Playground, but this has been addressed by the OpenAI team. The threads page is now back with the ability to disable it or limit access to organization owners.

A thread represents a conversation and you can create one per user as soon as the user initiates the conversation. You can add as many messages as you want to a thread and the Assistant will ensure that requests to the model fit within the maximum context window.

If you're still unable to see the threads, it could be due to your organization settings. Organizations that have enabled the Threads page can view Threads created through the Assistants API and Assistants playground. Threads page permissions can be managed in Organization settings.

Here is how you can create a thread:

thread = client.beta.threads.create()

And here is how you can list the messages added to the thread by the Assistant:

messages = client.beta.threads.messages.list(
 thread_id=thread.id
)

For more information, you can refer to the OpenAI documentation (https://platform.openai.com/docs/assistants/overview/step-2-create-a-thread) and the OpenAI community forum (https://community.openai.com/t/482691).

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@young hawk kapa.ai is still learning and improving, please let us know how it did by reacting below

young hawk
#

@nocturne creek how can i use and add retrieval in the code for Assistant to use?

nocturne creekBOT
#

Let me check the knowledge base for you. One moment! :books:

#

Based on the information provided in the extracts, to use retrieval in your Assistant, you need to add files to your Assistant. These files can be used by the Assistant to retrieve information when answering queries. Here's how you can add a file to your Assistant:

client.assistants.files.create(
  assistant_id="asst_1234567890",
  file=open("path_to_your_file.txt", "rb")
)

The Assistant can then use the information in these files to answer queries. For example, if a user asks a question that's answered in one of the files, the Assistant can retrieve that information and provide it as the answer.

However, please note that as per the extracts, the new Assistants API is limited to 20 files per assistant. If you need to use more than 20 documents, you might need to wait for OpenAI to change this limitation or find a workaround.

For more information, you can refer to the OpenAI documentation (https://platform.openai.com/docs/assistants/overview/step-3-add-files-to-your-assistant) and the OpenAI community forum (https://community.openai.com/t/484098).

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@young hawk kapa.ai is still learning and improving, please let us know how it did by reacting below

young hawk
#

@nocturne creek can i add the file manually via Playground to the Assistant without having to upload via code? but then i do wanna use that file for retrieval.. please let me know what i'll have to add in the code accordingly, even if i upload the file manually?

nocturne creekBOT
#

Let me check the knowledge base for you. One moment! :books:

#

Yes, you can manually upload files to your Assistant via the OpenAI Playground. However, to use these files for retrieval, you need to enable the retrieval tool in your code. Here's how you can do it:

assistant = client.beta.assistants.create(
 instructions="You are a customer support chatbot. Use your knowledge base to best respond to customer queries.",
 model="gpt-4-turbo-preview",
 tools=[{"type": "retrieval"}]
)

This code creates an Assistant and enables the retrieval tool. The instructions parameter is used to guide the Assistant's behavior. The model parameter specifies the model to use, and the tools parameter enables the retrieval tool.

If you've already created an Assistant and want to enable the retrieval tool, you can use the update method:

assistant = client.beta.assistants.update(
 MATH_ASSISTANT_ID,
 tools=[{"type": "code_interpreter"}, {"type": "retrieval"}],
)

This code updates an existing Assistant (specified by MATH_ASSISTANT_ID) and enables the retrieval tool.

Once the retrieval tool is enabled, the Assistant will automatically use the files you've uploaded to answer queries.

For more information, you can refer to the OpenAI documentation (https://platform.openai.com/docs/assistants/tools) and the OpenAI community forum (https://community.openai.com/t/493105).

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@young hawk kapa.ai is still learning and improving, please let us know how it did by reacting below

young hawk
#

@nocturne creek does that mean if i send a message to the assistant via code once after enabling retrieval, the assistant will automatically search for the answer in the file uploaded without needing me to specify waht while to look into?

nocturne creekBOT
#

Let me check the knowledge base for you. One moment! :books:

#

Yes, that's correct. Once you've enabled the retrieval tool and uploaded files to your Assistant, it will automatically use these files to answer queries. You don't need to specify which file to look into. The Assistant will search all the files you've uploaded to find the most relevant information to answer the query.

Here's an example of how you can send a message to the Assistant:

message = "Who is [name of person]?"

openai_client.beta.threads.messages.create(thread_id, role="user", content=message)

In this code, thread_id is the ID of the thread you're sending the message to, role is set to "user" to indicate that the message is from the user, and content is the content of the message.

The Assistant will then use the retrieval tool to search the files you've uploaded and provide the best answer based on the information in these files.

For more information, you can refer to the OpenAI documentation (https://platform.openai.com/docs/assistants/tools) and the OpenAI community forum (https://community.openai.com/t/504127).

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@young hawk kapa.ai is still learning and improving, please let us know how it did by reacting below

young hawk
#

@nocturne creek but in API reference i can see that there is a parameter named 'file_ids' in creating message endpoint. what is that for?

nocturne creekBOT
#

Let me check the knowledge base for you. One moment! :books:

#

The 'file_ids' parameter in the createMessage endpoint is used to specify a list of file IDs that the assistant should use. This can be useful for tools like retrieval and code_interpreter that can access files. A maximum of 10 files can be attached to a message.

Here's an example of how you can use the 'file_ids' parameter:

message = client.beta.threads.messages.create(
  thread_id="thread_abc123",
  role="user",
  content="Who is [name of person]?",
  file_ids=["file_abc123", "file_def456"]
)

In this code, 'file_ids' is a list of file IDs. The Assistant will use these files when answering the query.

Please note that the 'file_ids' parameter is optional. If you don't specify 'file_ids', the Assistant will use all the files you've uploaded.

For more information, you can refer to the OpenAI API documentation (https://platform.openai.com/docs/api-reference).

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: