Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Vector Store, Vector Store Files and Vector Store Batch Files APIs #463

Open
alexrudall opened this issue Apr 27, 2024 · 7 comments

Comments

@alexrudall
Copy link
Owner

  • New API files need, VectorStores, VectorStoreFiles and VectorStoreBatchFiles
  • Docs start here
@MarcoBgn
Copy link

Thanks for that, a side note:

At the moment is not possible to use the Assistant V2, as they renamed 'retrieval' to 'file_search':

OpenAI HTTP Error (spotted in ruby-openai 6.3.1): {"error"=>{"message"=>"Invalid value: 'file_search'. Supported values are: 'code_interpreter', 'function', and 'retrieval'.", "type"=>"invalid_request_error", "param"=>"tools[1].type", "code"=>"invalid_value"}}

@alexrudall
Copy link
Owner Author

alexrudall commented Apr 29, 2024

Thanks for that, a side note:

At the moment is not possible to use the Assistant V2, as they renamed 'retrieval' to 'file_search':

OpenAI HTTP Error (spotted in ruby-openai 6.3.1): {"error"=>{"message"=>"Invalid value: 'file_search'. Supported values are: 'code_interpreter', 'function', and 'retrieval'.", "type"=>"invalid_request_error", "param"=>"tools[1].type", "code"=>"invalid_value"}}

Thanks @MarcoBgn , can you try with version 7? EDIT: I can see this is in the README example. I'll fix this I've updated the README so the code_interpreter example works - like you said, file_search won't work until we add Vector Store.

@willywg
Copy link

willywg commented Apr 29, 2024

Thanks for that, a side note:

At the moment is not possible to use the Assistant V2, as they renamed 'retrieval' to 'file_search':

OpenAI HTTP Error (spotted in ruby-openai 6.3.1): {"error"=>{"message"=>"Invalid value: 'file_search'. Supported values are: 'code_interpreter', 'function', and 'retrieval'.", "type"=>"invalid_request_error", "param"=>"tools[1].type", "code"=>"invalid_value"}}

@MarcoBgn I faced the same issue, but since I only needed to send attachments via messages, with this monkey patch, I was able to use the messages API with attachments in the parameters.

# OpenAI Patch to use beta API v2
module OpenAIPatch
  def beta(apis)
    dup.tap do |client|
      client.add_headers("OpenAI-Beta": apis.map { |k, v| "#{k}=v2" }.join(";"))
    end  
  end
end
OpenAI::Client.prepend(OpenAIPatch)

client = OpenAI::Client.new(...)

@alexrudall
Copy link
Owner Author

Thanks for that, a side note:
At the moment is not possible to use the Assistant V2, as they renamed 'retrieval' to 'file_search':

OpenAI HTTP Error (spotted in ruby-openai 6.3.1): {"error"=>{"message"=>"Invalid value: 'file_search'. Supported values are: 'code_interpreter', 'function', and 'retrieval'.", "type"=>"invalid_request_error", "param"=>"tools[1].type", "code"=>"invalid_value"}}

@MarcoBgn I faced the same issue, but since I only needed to send attachments via messages, with this monkey patch, I was able to use the messages API with attachments in the parameters.

# OpenAI Patch to use beta API v2
module OpenAIPatch
  def beta(apis)
    dup.tap do |client|
      client.add_headers("OpenAI-Beta": apis.map { |k, v| "#{k}=v2" }.join(";"))
    end  
  end
end
OpenAI::Client.prepend(OpenAIPatch)

client = OpenAI::Client.new(...)

I released ruby-openai 7 this weekend which uses v2 so you don't need to do this any more if you upgrade :)

@willywg
Copy link

willywg commented Apr 29, 2024

@alexrudall thanks for amazing gem, but this don't work for me because you haven't updated the version on Message endpoint. I get this error:

I, [2024-04-29T17:22:33.757198 #9315]  INFO -- request: POST https://api.openai.com/v1/threads/thread_IOAErVqNdHKxUtBhwbczpKqL/messages
I, [2024-04-29T17:22:33.757366 #9315]  INFO -- request: Content-Type: "application/json"
Authorization: "Bearer sk-XXX"
OpenAI-Organization: "org-XXX"
OpenAI-Beta: "assistants=v1"
I, [2024-04-29T17:22:33.757408 #9315]  INFO -- request: {"role":"user","content":"De que trata este file?","attachments":[{"file_id":"file-LubipmNsgV4tVJ6hUeXXXyEo","tools":[{"type":"file_search"}]}]}
I, [2024-04-29T17:22:34.384360 #9315]  INFO -- response: Status 400
I, [2024-04-29T17:22:34.384946 #9315]  INFO -- response: date: "Mon, 29 Apr 2024 22:22:34 GMT"
content-type: "application/json"
content-length: "169"
connection: "keep-alive"
openai-version: "2020-10-01"
openai-organization: "gojom-1"
x-request-id: "req_2f94e391deeccbcb5e44fadac7401986"
openai-processing-ms: "84"
strict-transport-security: "max-age=15724800; includeSubDomains"
cf-cache-status: "DYNAMIC"
set-cookie: "__cf_bm=XXX-1714429354-1.0.1.1-XXX; path=/; expires=Mon, 29-Apr-24 22:52:34 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None, _cfuvid=XXX-1714429354452-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None"
server: "cloudflare"
cf-ray: "87c2b1077ed6a175-GRU"
alt-svc: "h3=\":443\"; ma=86400"
I, [2024-04-29T17:22:34.385060 #9315]  INFO -- response: {
  "error": {
    "message": "Unknown parameter: 'attachments'.",
    "type": "invalid_request_error",
    "param": "attachments",
    "code": "unknown_parameter"
  }
}

Check the OpenAI-Beta: "assistants=v1" header.

@alexrudall
Copy link
Owner Author

@willywg man you're right. Thanks a lot for pointing this out - fix released as 7.0.1

@willywg
Copy link

willywg commented Apr 30, 2024

Thank you @alexrudall. I’m sending you a PR #472 regarding this issue. I hope it helps :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants