Find answers from the community

Updated 3 months ago

Hi everyone I m deputing the code below

Hi everyone, I'm deputing the code below and I get an error message:
"ImportError
cannot import name 'FunctionMessage' from 'langchain.schema' (/Users/janiobonfim/Projetos-VSCode/env/lib/python3.11/site-packages/langchain/schema.py)
File "/Users/janiobonfim/Projetos-VSCode/main.py", line 9, in <module>
from llama_index import GPTVectorStoreIndex, download_loader, MockLLMPredictor, ServiceContext"

I already updated the versions of Llama-index and Langchain, but the error persists...
The following code aims to fetch a text from google docs and index it with llama-index and submit it to OpenAI's ChatGPT.
Can anyone help me identify where I'm going wrong? Thank you.
Jan


import os
import pickle

from google.auth.transport.requests import Request

from google_auth_oauthlib.flow import InstalledAppFlow
line 9 from llama_index import GPTVectorStoreIndex, download_loader, MockLLMPredictor, ServiceContext

os.environ['OPENAI_API_KEY'] = '...'
llm_predictor = MockLLMPredictor(max_tokens=256)
service_context = ServiceContext.from_defaults(llm_predictor=llm_predictor)

def authorize_gdocs():
cred = None
if os.path.exists("token.pickle"):
with open("token.pickle", 'rb') as token:
cred = pickle.load(token)
if not cred or not cred.valid:
if cred and cred.expired and cred.refresh_token:
cred.refresh(Request())
else:
print(os.getcwd())
creds_file_path = os.path.abspath('credentials.json')
google_oauth2_scopes = [
"https://www.googleapis.com/auth/documents.readonly"
]
flow = InstalledAppFlow.from_client_secrets_file(creds_file_path, google_oauth2_scopes)
cred = flow.run_local_server(port=0)
with open("token.pickle", 'wb') as token:
pickle.dump(cred, token)
[...]
L
J
5 comments
Are you sure you updated langchain?

pip install --upgrade langchain

Maybe start with a fresh venv to be sure
Hi Logan, thanks for your feedback.

Current version of Langchain is 0.0.198

But for guarantee I will run the update again, creating new virtual environment.
the latest version of langchain is actually 0.0.217 πŸ‘€
Hi Logan, that was it, update!

Now it's over, thank you very much.
perfect! πŸŽ‰
Add a reply
Sign up and join the conversation on Discord