Llama2App.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. from typing import Optional
  2. from embedchain.apps.CustomApp import CustomApp
  3. from embedchain.config import CustomAppConfig
  4. from embedchain.embedder.openai_embedder import OpenAiEmbedder
  5. from embedchain.helper_classes.json_serializable import register_deserializable
  6. from embedchain.llm.llama2_llm import Llama2Llm
  7. from embedchain.vectordb.chroma_db import ChromaDB
  8. @register_deserializable
  9. class Llama2App(CustomApp):
  10. """
  11. The EmbedChain Llama2App class.
  12. Has two functions: add and query.
  13. adds(data_type, url): adds the data from the given URL to the vector db.
  14. query(query): finds answer to the given query using vector database and LLM.
  15. """
  16. def __init__(self, config: CustomAppConfig = None, system_prompt: Optional[str] = None):
  17. """
  18. :param config: CustomAppConfig instance to load as configuration. Optional.
  19. :param system_prompt: System prompt string. Optional.
  20. """
  21. if config is None:
  22. config = CustomAppConfig()
  23. super().__init__(
  24. config=config, llm=Llama2Llm(), db=ChromaDB(), embedder=OpenAiEmbedder(), system_prompt=system_prompt
  25. )