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 | from typing import Any |
| #2 | |
| #3 | from embedchain import App |
| #4 | from embedchain.config import AddConfig, AppConfig, BaseLlmConfig |
| #5 | from embedchain.embedder.openai import OpenAIEmbedder |
| #6 | from embedchain.helpers.json_serializable import ( |
| #7 | JSONSerializable, |
| #8 | register_deserializable, |
| #9 | ) |
| #10 | from embedchain.llm.openai import OpenAILlm |
| #11 | from embedchain.vectordb.chroma import ChromaDB |
| #12 | |
| #13 | |
| #14 | @register_deserializable |
| #15 | class BaseBot(JSONSerializable): |
| #16 | def __init__(self): |
| #17 | self.app = App(config=AppConfig(), llm=OpenAILlm(), db=ChromaDB(), embedding_model=OpenAIEmbedder()) |
| #18 | |
| #19 | def add(self, data: Any, config: AddConfig = None): |
| #20 | """ |
| #21 | Add data to the bot (to the vector database). |
| #22 | Auto-dectects type only, so some data types might not be usable. |
| #23 | |
| #24 | :param data: data to embed |
| #25 | :type data: Any |
| #26 | :param config: configuration class instance, defaults to None |
| #27 | :type config: AddConfig, optional |
| #28 | """ |
| #29 | config = config if config else AddConfig() |
| #30 | self.app.add(data, config=config) |
| #31 | |
| #32 | def query(self, query: str, config: BaseLlmConfig = None) -> str: |
| #33 | """ |
| #34 | Query the bot |
| #35 | |
| #36 | :param query: the user query |
| #37 | :type query: str |
| #38 | :param config: configuration class instance, defaults to None |
| #39 | :type config: BaseLlmConfig, optional |
| #40 | :return: Answer |
| #41 | :rtype: str |
| #42 | """ |
| #43 | config = config |
| #44 | return self.app.query(query, config=config) |
| #45 | |
| #46 | def start(self): |
| #47 | """Start the bot's functionality.""" |
| #48 | raise NotImplementedError("Subclasses must implement the start method.") |
| #49 |