base.py 963 B

12345678910111213141516171819202122232425
  1. from embedchain import CustomApp
  2. from embedchain.config import AddConfig, CustomAppConfig, QueryConfig
  3. from embedchain.models import EmbeddingFunctions, Providers
  4. class BaseBot:
  5. def __init__(self, app_config=None):
  6. if app_config is None:
  7. app_config = CustomAppConfig(embedding_fn=EmbeddingFunctions.OPENAI, provider=Providers.OPENAI)
  8. self.app_config = app_config
  9. self.app = CustomApp(config=self.app_config)
  10. def add(self, data, config: AddConfig = None):
  11. """Add data to the bot"""
  12. config = config if config else AddConfig()
  13. self.app.add(data, config=config)
  14. def query(self, query, config: QueryConfig = None):
  15. """Query bot"""
  16. config = config if config else QueryConfig()
  17. return self.app.query(query, config=config)
  18. def start(self):
  19. """Start the bot's functionality."""
  20. raise NotImplementedError("Subclasses must implement the start method.")