OpenAI Assistants API and Retrieval Tool : Complete Guide

Поділитися
Вставка
  • Опубліковано 12 вер 2024
  • The Assistants API provides developers with the capability to construct artificial intelligence assistants within their respective applications. An assistant possesses explicit directives and has the ability to utilize various models, tools, and information in order to provide responses to user inquiries. The Assistants API presently offers support for three distinct categories of tools, including Code Interpreter, Retrieval, and Function Calling. In subsequent periods, there is a strategic intention to introduce a greater number of tools developed by OpenAI while concurrently facilitating the inclusion of user-provided tools within the platform itself.
    The assistant's knowledge base is enhanced by retrieval, which involves incorporating external information into its model. This can include private product details or documents shared by users. After a file has been uploaded and received by the assistant, OpenAI will proceed to divide the documents into smaller segments, create an index, and store the embeddings. This will enable the implementation of vector search, which may be utilized to extract pertinent information in order to respond to user inquiries.

КОМЕНТАРІ • 7

  • @A_M_R_
    @A_M_R_ 8 місяців тому +1

    hey, can you share the boilerplate code please? it could be really helpful. thanks

    • @scholarly360
      @scholarly360  8 місяців тому +1

      You can get colab link from here medium.com/@scholarly360/open-ai-assistants-api-and-retrieval-tool-a-complete-guide-2b3ee9c407ec

    • @InnocenceVVX
      @InnocenceVVX 8 місяців тому

      @@scholarly360 @A_M_R_ thanks!

  • @Ajdin87
    @Ajdin87 8 місяців тому

    Great video/article. I have one question. if I want to send further messsage(s) to assistant, what is the order of function calling?
    - Create message
    - Run assistant (thread_id, assistant_id)
    - Retreive status (thread_id, run_id)
    If I want to add new messages, do I just call create message function, and than call run assistant with same ids, and retreive result?

    • @scholarly360
      @scholarly360  8 місяців тому +1

      Thanks for the kind words.
      You can add multiple messages to the same thread
      From my source code
      # You are adding multiple messages rather single
      client.beta.threads.messages.create(thread_id=thread.id,role="user",content="Tell me who is acquirer")
      client.beta.threads.messages.create(thread_id=thread.id,role="user",content="Tell me date of acquistion")
      # If run is 'completed', you will get both answers together
      while True:
      # Retrieve the run status
      run_status = client.beta.threads.runs.retrieve(thread_id=thread.id,run_id=run.id)
      print(run_status.model_dump_json(indent=4))
      time.sleep(10)
      if run_status.status == 'completed':
      messages = client.beta.threads.messages.list(thread_id=thread.id)
      pprint(messages.data[0].content[0].text.value)
      break
      else:
      ### sleep again
      time.sleep(2)

  • @ahmedimamovic6770
    @ahmedimamovic6770 9 місяців тому

    How do i only get the content from messages?

    • @scholarly360
      @scholarly360  8 місяців тому

      You can traverse e.g. messages.data[0].content[0].text.value . Thanks.