patterns-ai-core / langchainrb

Build LLM-powered applications in Ruby

Home Page:https://rubydoc.info/gems/langchainrb

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Langchainrb Vectorsearch Pinecone ask method returns error "unknown keyword: :prompt"

sbraford opened this issue · comments

Hello. I've been working on a Langchain/Pinecone integration for a bit here, and this code was previously working for me. It seems to have broke sometime in the past month or so. Here's a stripped down version that I can run via rails runner:

begin
  llm_options = { completion_model_name: "gpt-4-1106-preview", chat_completion_model_name: "gpt-4-1106-preview" }
  llm = Langchain::LLM::OpenAI.new(api_key: ENV["OPENAI_ACCESS_TOKEN"], default_options: llm_options)

  client = Langchain::Vectorsearch::Pinecone.new(api_key: ENV["PINECONE_API_KEY"],
                                                 index_name: "development-topic-test",
                                                 environment: "us-east-1-aws",
                                                 llm: llm)

  result = client.ask(question: "how do you reverse an array in ruby?", namespace: "topic-markets")
  puts result.inspect

rescue => e
  puts "RESCUED: #{e}"
end

This results in the output:

RESCUED: unknown keyword: :prompt

Things I've checked:

  • Environment variables are correct
  • The environment is correct and the index name exists in my Pinecone environment
  • The namespace exists in that Pinecone index
  • Also tried GPT model "gpt-4-turbo-preview" -- yielded the same result
  • Tried running the same code in a staging environment with different configuration values -- yielded the same result

Any ideas?

If I had to guess, an API method got changed somewhere, and some code has not been updated yet. Just surprised no one else has reported this yet (or have they?). I'm happy to dive in and work on a PR too if someone could point me in the right direction.

@sbraford Which version of the gem are you using?

Oh, great question:

langchainrb (0.9.0)
pinecone (0.1.71)

Oh, great question:

langchainrb (0.9.0) pinecone (0.1.71)

Could you please try bumping it up to 0.9.2 and try running your code again?

@andreibondarev - Thank you for the recommendation! Not sure why I didn't think of that.

That did the trick!

I'll close this ticket.