Я получаю предупреждение ниже уровня, и я могу переустановить pip, но он все равно выдает предупреждение ниже.
Ошибка:
.localpython/lib/python3.12/site-packages/langchain/document_loaders/ init.py:36: LangChainDeprecationWarning: импорт загрузчиков документов из langchain устарел. Импорт из langchain больше не будет поддерживаться начиная с langchain==0.2.0. Вместо этого импортируйте из langchain-community:
`from langchain_community.document_loaders import DirectoryLoader`.
To install langchain-community run `pip install -U langchain-community`.
warnings.warn(
/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain/document_loaders/__init__.py:36: LangChainDeprecationWarning: Importing document loaders from langchain is deprecated. Importing from langchain will no longer be supported as of langchain==0.2.0. Please import from langchain-community instead:
`from langchain_community.document_loaders import TextLoader`.
To install langchain-community run `pip install -U langchain-community`.
warnings.warn(
/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain/embeddings/__init__.py:29: LangChainDeprecationWarning: Importing embeddings from langchain is deprecated. Importing from langchain will no longer be supported as of langchain==0.2.0. Please import from langchain-community instead:
`from langchain_community.embeddings import OpenAIEmbeddings`.
To install langchain-community run `pip install -U langchain-community`.
warnings.warn(
/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain/llms/__init__.py:548: LangChainDeprecationWarning: Importing LLMs from langchain is deprecated. Importing from langchain will no longer be supported as of langchain==0.2.0. Please import from langchain-community instead:
`from langchain_community.llms import OpenAI`.
To install langchain-community run `pip install -U langchain-community`.
warnings.warn(
/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain/vectorstores/__init__.py:35: LangChainDeprecationWarning: Importing vector stores from langchain is deprecated. Importing from langchain will no longer be supported as of langchain==0.2.0. Please import from langchain-community instead:
`from langchain_community.vectorstores import Chroma`.
To install langchain-community run `pip install -U langchain-community`.
warnings.warn(
Traceback (most recent call last):
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain_community/vectorstores/chroma.py", line 81, in __init__
import chromadb
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/chromadb/__init__.py", line 2, in
import chromadb.config
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/chromadb/config.py", line 1, in
from pydantic import BaseSettings
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/pydantic/__init__.py", line 374, in __getattr__
return _getattr_migration(attr_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/pydantic/_migration.py", line 296, in wrapper
raise PydanticImportError(
pydantic.errors.PydanticImportError: `BaseSettings` has been moved to the `pydantic-settings` package. See https://docs.pydantic.dev/2.6/migration ... c-settings for more details.
For further information visit https://errors.pydantic.dev/2.6/u/import-error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/bata/balm1fxr/OpenAI/chatgpt-retrieval-main/chatgpt.py", line 35, in
index = VectorstoreIndexCreator().from_loaders([loader])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain/indexes/vectorstore.py", line 84, in from_loaders
return self.from_documents(docs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain/indexes/vectorstore.py", line 89, in from_documents
vectorstore = self.vectorstore_cls.from_documents(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain_community/vectorstores/chroma.py", line 778, in from_documents
return cls.from_texts(
^^^^^^^^^^^^^^^
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain_community/vectorstores/chroma.py", line 714, in from_texts
chroma_collection = cls(
^^^^
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain_community/vectorstores/chroma.py", line 84, in __init__
raise ImportError(
**ImportError: Could not import chromadb python package. Please install it with `pip install chromadb`**
**Chatgp.py code**
import os
import sys
import openai
from langchain.chains import ConversationalRetrievalChain, RetrievalQA
from langchain.chat_models import ChatOpenAI
from langchain.document_loaders import DirectoryLoader, TextLoader
from langchain.embeddings import OpenAIEmbeddings
from langchain.indexes import VectorstoreIndexCreator
from langchain.indexes.vectorstore import VectorStoreIndexWrapper
from langchain.llms import OpenAI
from langchain.vectorstores import Chroma
import constants
os.environ["OPENAI_API_KEY"] = constants.APIKEY
PERSIST = False
query = None
if len(sys.argv) > 1:
query = sys.argv[1]
if PERSIST and os.path.exists("persist"):
print("Reusing index...\n")
vectorstore = Chroma(persist_directory="persist", embedding_function=OpenAIEmbeddings())
index = VectorStoreIndexWrapper(vectorstore=vectorstore)
else:
#loader = TextLoader("data/data.txt") # Use this line if you only need data.txt
loader = DirectoryLoader("data/")
if PERSIST:
index = VectorstoreIndexCreator(vectorstore_kwargs={"persist_directory":"persist"}).from_loaders([loader])
else:
index = VectorstoreIndexCreator().from_loaders([loader])
chain = ConversationalRetrievalChain.from_llm(
llm=ChatOpenAI(model="gpt-3.5-turbo"),
retriever=index.vectorstore.as_retriever(search_kwargs={"k": 1}),
)
chat_history = []
while True:
if not query:
query = input("Prompt: ")
if query in ['quit', 'q', 'exit']:
sys.exit()
result = chain({"question": query, "chat_history": chat_history})
print(result['answer'])
chat_history.append((query, result['answer']))
query = None
Подробнее здесь: https://stackoverflow.com/questions/779 ... -is-deprec
LangChainDeprecationWarning: импорт загрузчиков документов из langchain устарел. Импорт из langchain больше не будет под ⇐ Python
Программы на Python
1727557450
Anonymous
Я получаю предупреждение ниже уровня, и я могу переустановить pip, но он все равно выдает предупреждение ниже.
Ошибка:
.localpython/lib/python3.12/site-packages/langchain/document_loaders/[b] init[/b].py:36: LangChainDeprecationWarning: импорт загрузчиков документов из langchain устарел. Импорт из langchain больше не будет поддерживаться начиная с langchain==0.2.0. Вместо этого импортируйте из langchain-community:
`from langchain_community.document_loaders import DirectoryLoader`.
To install langchain-community run `pip install -U langchain-community`.
warnings.warn(
/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain/document_loaders/__init__.py:36: LangChainDeprecationWarning: Importing document loaders from langchain is deprecated. Importing from langchain will no longer be supported as of langchain==0.2.0. Please import from langchain-community instead:
`from langchain_community.document_loaders import TextLoader`.
To install langchain-community run `pip install -U langchain-community`.
warnings.warn(
/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain/embeddings/__init__.py:29: LangChainDeprecationWarning: Importing embeddings from langchain is deprecated. Importing from langchain will no longer be supported as of langchain==0.2.0. Please import from langchain-community instead:
`from langchain_community.embeddings import OpenAIEmbeddings`.
To install langchain-community run `pip install -U langchain-community`.
warnings.warn(
/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain/llms/__init__.py:548: LangChainDeprecationWarning: Importing LLMs from langchain is deprecated. Importing from langchain will no longer be supported as of langchain==0.2.0. Please import from langchain-community instead:
`from langchain_community.llms import OpenAI`.
To install langchain-community run `pip install -U langchain-community`.
warnings.warn(
/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain/vectorstores/__init__.py:35: LangChainDeprecationWarning: Importing vector stores from langchain is deprecated. Importing from langchain will no longer be supported as of langchain==0.2.0. Please import from langchain-community instead:
`from langchain_community.vectorstores import Chroma`.
To install langchain-community run `pip install -U langchain-community`.
warnings.warn(
Traceback (most recent call last):
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain_community/vectorstores/chroma.py", line 81, in __init__
import chromadb
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/chromadb/__init__.py", line 2, in
import chromadb.config
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/chromadb/config.py", line 1, in
from pydantic import BaseSettings
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/pydantic/__init__.py", line 374, in __getattr__
return _getattr_migration(attr_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/pydantic/_migration.py", line 296, in wrapper
raise PydanticImportError(
pydantic.errors.PydanticImportError: `BaseSettings` has been moved to the `pydantic-settings` package. See https://docs.pydantic.dev/2.6/migration/#basesettings-has-moved-to-pydantic-settings for more details.
For further information visit https://errors.pydantic.dev/2.6/u/import-error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/bata/balm1fxr/OpenAI/chatgpt-retrieval-main/chatgpt.py", line 35, in
index = VectorstoreIndexCreator().from_loaders([loader])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain/indexes/vectorstore.py", line 84, in from_loaders
return self.from_documents(docs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain/indexes/vectorstore.py", line 89, in from_documents
vectorstore = self.vectorstore_cls.from_documents(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain_community/vectorstores/chroma.py", line 778, in from_documents
return cls.from_texts(
^^^^^^^^^^^^^^^
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain_community/vectorstores/chroma.py", line 714, in from_texts
chroma_collection = cls(
^^^^
File "/home/balm1fxr/.localpython/lib/python3.12/site-packages/langchain_community/vectorstores/chroma.py", line 84, in __init__
raise ImportError(
**ImportError: Could not import chromadb python package. Please install it with `pip install chromadb`**
**Chatgp.py code**
import os
import sys
import openai
from langchain.chains import ConversationalRetrievalChain, RetrievalQA
from langchain.chat_models import ChatOpenAI
from langchain.document_loaders import DirectoryLoader, TextLoader
from langchain.embeddings import OpenAIEmbeddings
from langchain.indexes import VectorstoreIndexCreator
from langchain.indexes.vectorstore import VectorStoreIndexWrapper
from langchain.llms import OpenAI
from langchain.vectorstores import Chroma
import constants
os.environ["OPENAI_API_KEY"] = constants.APIKEY
PERSIST = False
query = None
if len(sys.argv) > 1:
query = sys.argv[1]
if PERSIST and os.path.exists("persist"):
print("Reusing index...\n")
vectorstore = Chroma(persist_directory="persist", embedding_function=OpenAIEmbeddings())
index = VectorStoreIndexWrapper(vectorstore=vectorstore)
else:
#loader = TextLoader("data/data.txt") # Use this line if you only need data.txt
loader = DirectoryLoader("data/")
if PERSIST:
index = VectorstoreIndexCreator(vectorstore_kwargs={"persist_directory":"persist"}).from_loaders([loader])
else:
index = VectorstoreIndexCreator().from_loaders([loader])
chain = ConversationalRetrievalChain.from_llm(
llm=ChatOpenAI(model="gpt-3.5-turbo"),
retriever=index.vectorstore.as_retriever(search_kwargs={"k": 1}),
)
chat_history = []
while True:
if not query:
query = input("Prompt: ")
if query in ['quit', 'q', 'exit']:
sys.exit()
result = chain({"question": query, "chat_history": chat_history})
print(result['answer'])
chat_history.append((query, result['answer']))
query = None
Подробнее здесь: [url]https://stackoverflow.com/questions/77945088/langchaindeprecationwarning-importing-document-loaders-from-langchain-is-deprec[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия