-
Notifications
You must be signed in to change notification settings - Fork 559
feat: support langchain v1 #1472
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
base: chore/remove-deprecated-llm-params
Are you sure you want to change the base?
Changes from all commits
9558458
12a1be1
a9f9e12
89ee95b
11ef083
388a0e4
14357dc
56cf606
e6c9478
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,10 +21,25 @@ | |
| import pandas as pd | ||
| import torch | ||
| from gpt4pandas import GPT4Pandas | ||
| from langchain.chains import RetrievalQA | ||
| from langchain.embeddings import HuggingFaceEmbeddings | ||
| from langchain.text_splitter import CharacterTextSplitter | ||
| from langchain.vectorstores import FAISS | ||
|
|
||
| try: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we have two nested checks for ImportErrors here? Is one enough, at which point we give guidance on what to install? |
||
| from langchain.chains import RetrievalQA | ||
| from langchain.embeddings import HuggingFaceEmbeddings | ||
| from langchain.text_splitter import CharacterTextSplitter | ||
| from langchain.vectorstores import FAISS | ||
| except ImportError: | ||
| try: | ||
| from langchain_classic.chains import RetrievalQA | ||
| from langchain_classic.embeddings import HuggingFaceEmbeddings | ||
| from langchain_classic.text_splitter import CharacterTextSplitter | ||
| from langchain_classic.vectorstores import FAISS | ||
| except ImportError as second_error: | ||
| raise ImportError( | ||
| f"Failed to import required LangChain modules. " | ||
| f"If you're using LangChain >= 1.0.0, ensure langchain-classic and langchain-text-splitters is installed. " | ||
| f"Original error: {second_error}" | ||
| ) from second_error | ||
|
|
||
| from langchain_core.language_models.llms import BaseLLM | ||
| from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,11 +18,24 @@ | |
| from typing import Optional | ||
|
|
||
| import pinecone | ||
| from langchain.chains import RetrievalQA | ||
| from langchain.docstore.document import Document | ||
| from langchain.embeddings.openai import OpenAIEmbeddings | ||
| from langchain.vectorstores import Pinecone | ||
| from langchain_core.language_models.llms import BaseLLM | ||
|
|
||
| try: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, why do two nested checks rather than one and raise the Error with the packages the user's missing? |
||
| from langchain.chains import RetrievalQA | ||
| from langchain.embeddings.openai import OpenAIEmbeddings | ||
| from langchain.vectorstores import Pinecone | ||
| except ImportError: | ||
| try: | ||
| from langchain_classic.chains import RetrievalQA | ||
| from langchain_classic.embeddings.openai import OpenAIEmbeddings | ||
| from langchain_classic.vectorstores import Pinecone | ||
| except ImportError as second_error: | ||
| raise ImportError( | ||
| f"Failed to import required LangChain modules. " | ||
| f"If you're using LangChain >= 1.0.0, ensure langchain-classic is installed. " | ||
| f"Original error: {second_error}" | ||
| ) from second_error | ||
|
|
||
| from langchain_core.language_models import BaseLLM | ||
|
|
||
| from nemoguardrails import LLMRails | ||
| from nemoguardrails.actions import action | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,8 +15,19 @@ | |
|
|
||
| import os | ||
|
|
||
| from langchain.chains import LLMMathChain | ||
| from langchain.prompts import ChatPromptTemplate | ||
| try: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nested import again (see above comments) |
||
| from langchain.chains import LLMMathChain | ||
| except ImportError: | ||
| try: | ||
| from langchain_classic.chains import LLMMathChain | ||
| except ImportError as second_error: | ||
| raise ImportError( | ||
| f"Failed to import required LangChain modules. " | ||
| f"If you're using LangChain >= 1.0.0, ensure langchain-classic is installed. " | ||
| f"Original error: {second_error}" | ||
| ) from second_error | ||
|
|
||
| from langchain_core.prompts import ChatPromptTemplate | ||
| from langchain_core.tools import Tool | ||
| from langchain_openai.chat_models import ChatOpenAI | ||
| from pydantic import BaseModel, Field | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.