Sha256: e1aaa55c50d96bf59aa2815c85fb289e4a8925686c7226e94cd09228e7a83f4e
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true require 'ruby/openai_pinecone' # Configure the gem with your credentials Ruby::OpenaiPinecone.configure do |config| config.openai_api_key = "" config.pinecone_api_key = "" config.pinecone_upsert_endpoint = "" config.pinecone_query_endpoint = "" end # Generate a vector for the input text text = "Uber Eats is an American online food ordering and delivery platform launched by Uber in 2014 and based in San Francisco, California. Users can read menus, reviews and ratings, order food from participating restaurants, and pay for their orders with Uber Eats." vector = Ruby::OpenaiPinecone::Embeddings.generate(text) puts "Generated vector: #{vector}" # Upsert the vector to Pinecone # id = "7" # success = Ruby::OpenaiPinecone::Client.upsert(id, vector) # puts "Upsert successful" if success # Query the existing vectors query_result = Ruby::OpenaiPinecone::Client.query(text) ids_and_scores = query_result["matches"].map { |match| { id: match["id"], score: match["score"] } } puts "Query result: #{ids_and_scores}"
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby-openai-pinecone-0.1.1 | examples/test.rb |