Llama2App.py 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. from typing import Optional
  2. from embedchain.apps.CustomApp import CustomApp
  3. from embedchain.config import CustomAppConfig
  4. from embedchain.embedder.openai import OpenAiEmbedder
  5. from embedchain.helper.json_serializable import register_deserializable
  6. from embedchain.llm.llama2 import Llama2Llm
  7. from embedchain.vectordb.chroma import ChromaDB
  8. @register_deserializable
  9. class Llama2App(CustomApp):
  10. """
  11. The EmbedChain Llama2App class.
  12. Methods:
  13. add(source, data_type): 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. chat(query): finds answer to the given query using vector database and LLM, with conversation history.
  16. """
  17. def __init__(self, config: CustomAppConfig = None, system_prompt: Optional[str] = None):
  18. """
  19. :param config: CustomAppConfig instance to load as configuration. Optional.
  20. :param system_prompt: System prompt string. Optional.
  21. """
  22. if config is None:
  23. config = CustomAppConfig()
  24. super().__init__(
  25. config=config, llm=Llama2Llm(), db=ChromaDB(), embedder=OpenAiEmbedder(), system_prompt=system_prompt
  26. )