浏览代码

[Bug fix] Fix issue of missing user directory (#975)

Deshraj Yadav 1 年之前
父节点
当前提交
1df46b2bb3
共有 6 个文件被更改,包括 14 次插入19 次删除
  1. 3 0
      embedchain/__init__.py
  2. 1 9
      embedchain/apps/app.py
  3. 1 2
      embedchain/embedchain.py
  4. 4 6
      embedchain/pipeline.py
  5. 4 1
      embedchain/store/assistants.py
  6. 1 1
      pyproject.toml

+ 3 - 0
embedchain/__init__.py

@@ -6,3 +6,6 @@ from embedchain.apps.app import App  # noqa: F401
 from embedchain.client import Client  # noqa: F401
 from embedchain.client import Client  # noqa: F401
 from embedchain.pipeline import Pipeline  # noqa: F401
 from embedchain.pipeline import Pipeline  # noqa: F401
 from embedchain.vectordb.chroma import ChromaDB  # noqa: F401
 from embedchain.vectordb.chroma import ChromaDB  # noqa: F401
+
+# Setup the user directory if doesn't exist already
+Client.setup_dir()

+ 1 - 9
embedchain/apps/app.py

@@ -2,9 +2,7 @@ from typing import Optional
 
 
 import yaml
 import yaml
 
 
-from embedchain.client import Client
-from embedchain.config import (AppConfig, BaseEmbedderConfig, BaseLlmConfig,
-                               ChunkerConfig)
+from embedchain.config import AppConfig, BaseEmbedderConfig, BaseLlmConfig, ChunkerConfig
 from embedchain.config.vectordb.base import BaseVectorDbConfig
 from embedchain.config.vectordb.base import BaseVectorDbConfig
 from embedchain.embedchain import EmbedChain
 from embedchain.embedchain import EmbedChain
 from embedchain.embedder.base import BaseEmbedder
 from embedchain.embedder.base import BaseEmbedder
@@ -68,9 +66,6 @@ class App(EmbedChain):
         :type system_prompt: Optional[str], optional
         :type system_prompt: Optional[str], optional
         :raises TypeError: LLM, database or embedder or their config is not a valid class instance.
         :raises TypeError: LLM, database or embedder or their config is not a valid class instance.
         """
         """
-        # Setup user directory if it doesn't exist already
-        Client.setup_dir()
-
         # Type check configs
         # Type check configs
         if config and not isinstance(config, AppConfig):
         if config and not isinstance(config, AppConfig):
             raise TypeError(
             raise TypeError(
@@ -134,9 +129,6 @@ class App(EmbedChain):
         :return: An instance of the App class.
         :return: An instance of the App class.
         :rtype: App
         :rtype: App
         """
         """
-        # Setup user directory if it doesn't exist already
-        Client.setup_dir()
-
         with open(yaml_path, "r") as file:
         with open(yaml_path, "r") as file:
             config_data = yaml.safe_load(file)
             config_data = yaml.safe_load(file)
 
 

+ 1 - 2
embedchain/embedchain.py

@@ -16,8 +16,7 @@ from embedchain.embedder.base import BaseEmbedder
 from embedchain.helpers.json_serializable import JSONSerializable
 from embedchain.helpers.json_serializable import JSONSerializable
 from embedchain.llm.base import BaseLlm
 from embedchain.llm.base import BaseLlm
 from embedchain.loaders.base_loader import BaseLoader
 from embedchain.loaders.base_loader import BaseLoader
-from embedchain.models.data_type import (DataType, DirectDataType,
-                                         IndirectDataType, SpecialDataType)
+from embedchain.models.data_type import DataType, DirectDataType, IndirectDataType, SpecialDataType
 from embedchain.telemetry.posthog import AnonymousTelemetry
 from embedchain.telemetry.posthog import AnonymousTelemetry
 from embedchain.utils import detect_datatype, is_valid_json_string
 from embedchain.utils import detect_datatype, is_valid_json_string
 from embedchain.vectordb.base import BaseVectorDB
 from embedchain.vectordb.base import BaseVectorDB

+ 4 - 6
embedchain/pipeline.py

@@ -24,6 +24,10 @@ from embedchain.vectordb.base import BaseVectorDB
 from embedchain.vectordb.chroma import ChromaDB
 from embedchain.vectordb.chroma import ChromaDB
 
 
 
 
+# Setup the user directory if doesn't exist already
+Client.setup_dir()
+
+
 @register_deserializable
 @register_deserializable
 class Pipeline(EmbedChain):
 class Pipeline(EmbedChain):
     """
     """
@@ -64,9 +68,6 @@ class Pipeline(EmbedChain):
         :type auto_deploy: bool, optional
         :type auto_deploy: bool, optional
         :raises Exception: If an error occurs while creating the pipeline
         :raises Exception: If an error occurs while creating the pipeline
         """
         """
-        # Setup user directory if it doesn't exist already
-        Client.setup_dir()
-
         if id and yaml_path:
         if id and yaml_path:
             raise Exception("Cannot provide both id and config. Please provide only one of them.")
             raise Exception("Cannot provide both id and config. Please provide only one of them.")
 
 
@@ -357,9 +358,6 @@ class Pipeline(EmbedChain):
         :return: An instance of the Pipeline class.
         :return: An instance of the Pipeline class.
         :rtype: Pipeline
         :rtype: Pipeline
         """
         """
-        # Setup user directory if it doesn't exist already
-        Client.setup_dir()
-
         with open(yaml_path, "r") as file:
         with open(yaml_path, "r") as file:
             config_data = yaml.safe_load(file)
             config_data = yaml.safe_load(file)
 
 

+ 4 - 1
embedchain/store/assistants.py

@@ -10,7 +10,7 @@ from typing import cast
 from openai import OpenAI
 from openai import OpenAI
 from openai.types.beta.threads import MessageContentText, ThreadMessage
 from openai.types.beta.threads import MessageContentText, ThreadMessage
 
 
-from embedchain import Pipeline
+from embedchain import Client, Pipeline
 from embedchain.config import AddConfig
 from embedchain.config import AddConfig
 from embedchain.data_formatter import DataFormatter
 from embedchain.data_formatter import DataFormatter
 from embedchain.models.data_type import DataType
 from embedchain.models.data_type import DataType
@@ -19,6 +19,9 @@ from embedchain.utils import detect_datatype
 
 
 logging.basicConfig(level=logging.WARN)
 logging.basicConfig(level=logging.WARN)
 
 
+# Setup the user directory if doesn't exist already
+Client.setup_dir()
+
 
 
 class OpenAIAssistant:
 class OpenAIAssistant:
     def __init__(
     def __init__(

+ 1 - 1
pyproject.toml

@@ -1,6 +1,6 @@
 [tool.poetry]
 [tool.poetry]
 name = "embedchain"
 name = "embedchain"
-version = "0.1.20"
+version = "0.1.21"
 description = "Data platform for LLMs - Load, index, retrieve and sync any unstructured data"
 description = "Data platform for LLMs - Load, index, retrieve and sync any unstructured data"
 authors = [
 authors = [
     "Taranjeet Singh <taranjeet@embedchain.ai>",
     "Taranjeet Singh <taranjeet@embedchain.ai>",