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

Course material and code don't match up -> gives type error #7

Closed
ptkasper opened this issue Mar 22, 2024 · 5 comments
Closed

Course material and code don't match up -> gives type error #7

ptkasper opened this issue Mar 22, 2024 · 5 comments

Comments

@ptkasper
Copy link

It seems that there's either something missing or wrong in the course material, compared to your code in the /solutions folder. If you follow along the course, you end up with a type error at the end of the following section: https://graphacademy.neo4j.com/courses/llm-chatbot-python/3-tools/1-vector-tool/

Error: "pydantic.v1.error_wrappers.ValidationError: 2 validation errors for AIMessage
content
str type expected (type=type_error.str)
content
value is not a valid list (type=type_error.list)"

In your solutions/tools/vector.py you seem to have the generate_response(prompt) function and tools =[] defined in vectory.py file but nowhere in the course material they were moved there (up until the above section). They were originally put in the agent.py file.

I.e. there seems to be some kind of mismatch between your solutions code and the code outlined in the course material. Here's the code from the vector.py file if you follow along with the course material:

import streamlit as st
from langchain_community.vectorstores.neo4j_vector import Neo4jVector
from llm import llm, embeddings
from langchain.chains import RetrievalQA

neo4jvector = Neo4jVector.from_existing_index(
embeddings, # (1)
url=st.secrets["NEO4J_URI"], # (2)
username=st.secrets["NEO4J_USERNAME"], # (3)
password=st.secrets["NEO4J_PASSWORD"], # (4)
index_name="moviePlots", # (5)
node_label="Movie", # (6)
text_node_property="plot", # (7)
embedding_node_property="plotEmbedding", # (8)
retrieval_query="""
RETURN
node.plot AS text,
score,
{
title: node.title,
directors: [ (person)-[:DIRECTED]->(node) | person.name ],
actors: [ (person)-[r:ACTED_IN]->(node) | [person.name, r.role] ],
tmdbId: node.tmdbId,
source: 'https://www.themoviedb.org/movie/'+ node.tmdbId
} AS metadata
"""
)

retriever = neo4jvector.as_retriever()

kg_qa = RetrievalQA.from_chain_type(
llm,
chain_type="stuff",
retriever=retriever,
)

@ptkasper
Copy link
Author

Furthermore, the solutions folder doesn't seem to include bot.py which is the entrypoint to the app. That file also imports the generate_response function from agent.py file. In the solutions folder that function is also now defined in two places: agent.py and tools/vector.py. In the latter it's never called.

@adkelley
Copy link

adkelley commented Apr 9, 2024

I'm experiencing the same issue. Perhaps the maintainer could bind the dependencies in requirements.txt to specific releases.

@K-Jadeja
Copy link

K-Jadeja commented Apr 9, 2024

@adam-cowley Please help us with this

@michela
Copy link

michela commented May 20, 2024

Solution here

#4 (comment)

@martinohanlon
Copy link
Contributor

Thanks for raising the issue.

The course has been recently updated to reflect changes in Langchain v0.2 and the code to manage agents and tools updated.

Perhaps the maintainer could bind the dependencies in requirements.txt to specific releases.
Thank you, yes I have done that.

Closing as no longer relevant.

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

5 participants