from langchain.llms import LlamaCpp
from langchain.embeddings import HuggingFaceEmbeddings
from langchain.callbacks.manager import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler

def hf_embeddings():
    return HuggingFaceEmbeddings(
        model_name = "sentence-transformers/all-mpnet-base-v2",
    )

def code_llama():
    callbackmanager = CallbackManager([StreamingStdOutCallbackHandler()])
    llm = LlamaCpp(
        model_path="./models/codellama-7b.Q4_K_M.gguf",
        n_ctx=2048,
        max_tokens=200,
        n_gpu_layers=1,
        f16_kv=True,
        callback_manager=callbackmanager,
        verbose=True,
        use_mlock=True
    )
    return llm
langchain.callbacks.streaming_stdout.StreamingStdOutCallbackHandler langchain.llms.LlamaCpp langchain.embeddings.HuggingFaceEmbeddings
[((260, 335), 'langchain.embeddings.HuggingFaceEmbeddings', 'HuggingFaceEmbeddings', ([], {'model_name': '"""sentence-transformers/all-mpnet-base-v2"""'}), "(model_name='sentence-transformers/all-mpnet-base-v2')\n", (281, 335), False, 'from langchain.embeddings import HuggingFaceEmbeddings\n'), ((456, 642), 'langchain.llms.LlamaCpp', 'LlamaCpp', ([], {'model_path': '"""./models/codellama-7b.Q4_K_M.gguf"""', 'n_ctx': '(2048)', 'max_tokens': '(200)', 'n_gpu_layers': '(1)', 'f16_kv': '(True)', 'callback_manager': 'callbackmanager', 'verbose': '(True)', 'use_mlock': '(True)'}), "(model_path='./models/codellama-7b.Q4_K_M.gguf', n_ctx=2048,\n    max_tokens=200, n_gpu_layers=1, f16_kv=True, callback_manager=\n    callbackmanager, verbose=True, use_mlock=True)\n", (464, 642), False, 'from langchain.llms import LlamaCpp\n'), ((411, 443), 'langchain.callbacks.streaming_stdout.StreamingStdOutCallbackHandler', 'StreamingStdOutCallbackHandler', ([], {}), '()\n', (441, 443), False, 'from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler\n')]