Bird
0
0

Examine the code below:

medium📝 Debug Q7 of 15
LangChain - Embeddings and Vector Stores
Examine the code below:
store = Chroma()
store.add_texts(["doc1", "doc2"])

Why does this code raise an error?
ANo embedding function was provided during Chroma initialization
BThe add_texts method requires a list of embeddings, not strings
CChroma does not support adding multiple texts at once
DThe collection name parameter is missing
Step-by-Step Solution
Solution:
  1. Step 1: Check Chroma initialization

    The code initializes Chroma without an embedding function.
  2. Step 2: Understand add_texts requirements

    add_texts expects to convert texts to embeddings using the embedding function.
  3. Step 3: Identify cause of error

    Without an embedding function, Chroma cannot process the texts, causing an error.
  4. Final Answer:

    No embedding function was provided during Chroma initialization -> Option A
  5. Quick Check:

    Embedding function is mandatory before adding texts. [OK]
Quick Trick: Always provide embedding_function before adding texts [OK]
Common Mistakes:
  • Assuming add_texts accepts raw strings without embeddings
  • Forgetting to initialize with embedding_function

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes