Langchain Crash Course - "ValueError" Feedback Request

I am a self-paced learner working on building out specific skills and do not work as a full-time developer. I’m working on creating an AI assistant following along with the " Learn LangChain for LLM Development" from FreeCodeCamp.

I’ve done my best to make sure my code follows the same syntax and format as the video, but keep getting a ValueError that I can’t seem to unpack.

Here is the code for the “langchain_helper” file.

from langchain.document_loaders import YoutubeLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.llms import OpenAI
from langchain.embeddings import OpenAIEmbeddings
from langchain import PromptTemplate
from langchain.chains import LLMChain
from langchain.vectorstores import FAISS
from dotenv import load_dotenv


embeddings = OpenAIEmbeddings()

def create_vector_db_from_youtube_url(video_url: str) -> FAISS:
    loader = YoutubeLoader.from_youtube_url(video_url)
    transcript = loader.load()

    text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
    docs = text_splitter.split_documents(transcript)
    db = FAISS.from_documents(docs, embeddings)
    return db

def get_response_from_query(db, query, k=4):
    # text-davinci can handle 4097 tokens

    docs = db.similarity_search(query, k=k)
    docs_page_conetnt = " ".join([d.page_content for d in docs])

    llm = OpenAI(model="text-davinci-003")

    prompt = PromptTemplate(
        input_variables=["question", "docs"],
        You are a helpful YouTube assistant that can answer questions about videos based on the video's transcript.

        Anaswer the following question: {question}
        By searching the following transcript: {docs}

        Only use the factual information from the transcript to answer the question.    

        If you feel like you don't have enough information to answer the question, say "I don't know"

        Your answers should be detailed.

    chain = LLMChain(llm=llm, prompt=prompt)

    response =, docs=docs_page_conetnt)
    response = response.replace("\n", "")
    return response

And here is the code for the main file.

import streamlit as st
import langchain_helper as lch
import textwrap

st.title("Youtube Assistant")

with st.sidebar:
    with st.form(key="my_form"):
        youtube_url = st.sidebar.text_area(
            label="What is the YouTube video URL?",
        query = st.sidebar.text_area(
            label="what is your question?",

        submit_button = st.form_submit_button(label="Submit")

if query and youtube_url:
    db = lch.create_vector_db_from_youtube_url(youtube_url)
    response, docs = lch.get_response_from_query(db, query)
    st.text(textwrap.fill(response, width=80))

When I run the main file, I keep receiving the following error:

Traceback (most recent call last):
  File "C:\Path\.venv\lib\site-packages\streamlit\runtime\scriptrunner\", line 541, in _run_script
    exec(code, module.__dict__)
  File "C:\Path\", line 23, in <module>
    response, docs = lch.get_response_from_query(db, query)
ValueError: too many values to unpack (expected 2)

My hunch is that the db variable from “get_response_from_query” is creating multiple vectors instead of one, creating too many values to unpack, but I’m not exactly sure how to confirm or deny this. I tried looking at the Youtube video for similar challenges but have been unable to make any progress on this.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.