repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | import importlib |
| #2 | |
| #3 | |
| #4 | def load_class(class_type): |
| #5 | module_path, class_name = class_type.rsplit(".", 1) |
| #6 | module = importlib.import_module(module_path) |
| #7 | return getattr(module, class_name) |
| #8 | |
| #9 | |
| #10 | class LlmFactory: |
| #11 | provider_to_class = { |
| #12 | "anthropic": "embedchain.llm.anthropic.AnthropicLlm", |
| #13 | "azure_openai": "embedchain.llm.azure_openai.AzureOpenAILlm", |
| #14 | "cohere": "embedchain.llm.cohere.CohereLlm", |
| #15 | "together": "embedchain.llm.together.TogetherLlm", |
| #16 | "gpt4all": "embedchain.llm.gpt4all.GPT4ALLLlm", |
| #17 | "ollama": "embedchain.llm.ollama.OllamaLlm", |
| #18 | "huggingface": "embedchain.llm.huggingface.HuggingFaceLlm", |
| #19 | "jina": "embedchain.llm.jina.JinaLlm", |
| #20 | "llama2": "embedchain.llm.llama2.Llama2Llm", |
| #21 | "openai": "embedchain.llm.openai.OpenAILlm", |
| #22 | "vertexai": "embedchain.llm.vertex_ai.VertexAILlm", |
| #23 | "google": "embedchain.llm.google.GoogleLlm", |
| #24 | "aws_bedrock": "embedchain.llm.aws_bedrock.AWSBedrockLlm", |
| #25 | "mistralai": "embedchain.llm.mistralai.MistralAILlm", |
| #26 | "clarifai": "embedchain.llm.clarifai.ClarifaiLlm", |
| #27 | "groq": "embedchain.llm.groq.GroqLlm", |
| #28 | "nvidia": "embedchain.llm.nvidia.NvidiaLlm", |
| #29 | "vllm": "embedchain.llm.vllm.VLLM", |
| #30 | } |
| #31 | provider_to_config_class = { |
| #32 | "embedchain": "embedchain.config.llm.base.BaseLlmConfig", |
| #33 | "openai": "embedchain.config.llm.base.BaseLlmConfig", |
| #34 | "anthropic": "embedchain.config.llm.base.BaseLlmConfig", |
| #35 | } |
| #36 | |
| #37 | @classmethod |
| #38 | def create(cls, provider_name, config_data): |
| #39 | class_type = cls.provider_to_class.get(provider_name) |
| #40 | # Default to embedchain base config if the provider is not in the config map |
| #41 | config_name = "embedchain" if provider_name not in cls.provider_to_config_class else provider_name |
| #42 | config_class_type = cls.provider_to_config_class.get(config_name) |
| #43 | if class_type: |
| #44 | llm_class = load_class(class_type) |
| #45 | llm_config_class = load_class(config_class_type) |
| #46 | return llm_class(config=llm_config_class(**config_data)) |
| #47 | else: |
| #48 | raise ValueError(f"Unsupported Llm provider: {provider_name}") |
| #49 | |
| #50 | |
| #51 | class EmbedderFactory: |
| #52 | provider_to_class = { |
| #53 | "azure_openai": "embedchain.embedder.azure_openai.AzureOpenAIEmbedder", |
| #54 | "gpt4all": "embedchain.embedder.gpt4all.GPT4AllEmbedder", |
| #55 | "huggingface": "embedchain.embedder.huggingface.HuggingFaceEmbedder", |
| #56 | "openai": "embedchain.embedder.openai.OpenAIEmbedder", |
| #57 | "vertexai": "embedchain.embedder.vertexai.VertexAIEmbedder", |
| #58 | "google": "embedchain.embedder.google.GoogleAIEmbedder", |
| #59 | "mistralai": "embedchain.embedder.mistralai.MistralAIEmbedder", |
| #60 | "clarifai": "embedchain.embedder.clarifai.ClarifaiEmbedder", |
| #61 | "nvidia": "embedchain.embedder.nvidia.NvidiaEmbedder", |
| #62 | "cohere": "embedchain.embedder.cohere.CohereEmbedder", |
| #63 | "ollama": "embedchain.embedder.ollama.OllamaEmbedder", |
| #64 | "aws_bedrock": "embedchain.embedder.aws_bedrock.AWSBedrockEmbedder", |
| #65 | } |
| #66 | provider_to_config_class = { |
| #67 | "azure_openai": "embedchain.config.embedder.base.BaseEmbedderConfig", |
| #68 | "google": "embedchain.config.embedder.google.GoogleAIEmbedderConfig", |
| #69 | "gpt4all": "embedchain.config.embedder.base.BaseEmbedderConfig", |
| #70 | "huggingface": "embedchain.config.embedder.base.BaseEmbedderConfig", |
| #71 | "clarifai": "embedchain.config.embedder.base.BaseEmbedderConfig", |
| #72 | "openai": "embedchain.config.embedder.base.BaseEmbedderConfig", |
| #73 | "ollama": "embedchain.config.embedder.ollama.OllamaEmbedderConfig", |
| #74 | "aws_bedrock": "embedchain.config.embedder.aws_bedrock.AWSBedrockEmbedderConfig", |
| #75 | } |
| #76 | |
| #77 | @classmethod |
| #78 | def create(cls, provider_name, config_data): |
| #79 | class_type = cls.provider_to_class.get(provider_name) |
| #80 | # Default to openai config if the provider is not in the config map |
| #81 | config_name = "openai" if provider_name not in cls.provider_to_config_class else provider_name |
| #82 | config_class_type = cls.provider_to_config_class.get(config_name) |
| #83 | if class_type: |
| #84 | embedder_class = load_class(class_type) |
| #85 | embedder_config_class = load_class(config_class_type) |
| #86 | return embedder_class(config=embedder_config_class(**config_data)) |
| #87 | else: |
| #88 | raise ValueError(f"Unsupported Embedder provider: {provider_name}") |
| #89 | |
| #90 | |
| #91 | class VectorDBFactory: |
| #92 | provider_to_class = { |
| #93 | "chroma": "embedchain.vectordb.chroma.ChromaDB", |
| #94 | "elasticsearch": "embedchain.vectordb.elasticsearch.ElasticsearchDB", |
| #95 | "opensearch": "embedchain.vectordb.opensearch.OpenSearchDB", |
| #96 | "lancedb": "embedchain.vectordb.lancedb.LanceDB", |
| #97 | "pinecone": "embedchain.vectordb.pinecone.PineconeDB", |
| #98 | "qdrant": "embedchain.vectordb.qdrant.QdrantDB", |
| #99 | "weaviate": "embedchain.vectordb.weaviate.WeaviateDB", |
| #100 | "zilliz": "embedchain.vectordb.zilliz.ZillizVectorDB", |
| #101 | } |
| #102 | provider_to_config_class = { |
| #103 | "chroma": "embedchain.config.vector_db.chroma.ChromaDbConfig", |
| #104 | "elasticsearch": "embedchain.config.vector_db.elasticsearch.ElasticsearchDBConfig", |
| #105 | "opensearch": "embedchain.config.vector_db.opensearch.OpenSearchDBConfig", |
| #106 | "lancedb": "embedchain.config.vector_db.lancedb.LanceDBConfig", |
| #107 | "pinecone": "embedchain.config.vector_db.pinecone.PineconeDBConfig", |
| #108 | "qdrant": "embedchain.config.vector_db.qdrant.QdrantDBConfig", |
| #109 | "weaviate": "embedchain.config.vector_db.weaviate.WeaviateDBConfig", |
| #110 | "zilliz": "embedchain.config.vector_db.zilliz.ZillizDBConfig", |
| #111 | } |
| #112 | |
| #113 | @classmethod |
| #114 | def create(cls, provider_name, config_data): |
| #115 | class_type = cls.provider_to_class.get(provider_name) |
| #116 | config_class_type = cls.provider_to_config_class.get(provider_name) |
| #117 | if class_type: |
| #118 | embedder_class = load_class(class_type) |
| #119 | embedder_config_class = load_class(config_class_type) |
| #120 | return embedder_class(config=embedder_config_class(**config_data)) |
| #121 | else: |
| #122 | raise ValueError(f"Unsupported Embedder provider: {provider_name}") |
| #123 |