from llama_index.core import Settings llm = Anthropic instance Settings.llm = llm # your defined llm
from llama_index.core.settings import Settings from llama_index.core.chat_engine import CondenseQuestionChatEngine from llama_index.core.memory import ChatMemoryBuffer from llama_index.core.query_engine import BaseQueryEngine from llama_index.core import VectorStoreIndex, get_response_synthesizer from llama_index.core.retrievers import VectorIndexRetriever from llama_index.core.query_engine import RetrieverQueryEngine from app.engine.templates.system_prompt import get_system_prompt_template from app.engine.settings import init_settings from app.engine.memory.multi_chat_memory import MultiChatMemoryBuffer from app.core.config import settings as app_settings from app.engine.multi_chat_engine import MultiChatEngine # build index index = VectorStoreIndex.from_documents([]) # configure retriever retriever = VectorIndexRetriever( index=index, similarity_top_k=2, ) # configure response synthesizer response_synthesizer = get_response_synthesizer( response_mode="tree_summarize", ) # assemble query engine query_engine = RetrieverQueryEngine( retriever=retriever, response_synthesizer=response_synthesizer, ) def create_chat_engine(chat_store): init_settings() memory = MultiChatMemoryBuffer( chat_store=chat_store, token_limit=app_settings.MAX_TOKEN, ) return CondenseQuestionChatEngine.from_defaults( query_engine=query_engine, memory=memory, llm=Settings.llm, system_prompt=get_system_prompt_template().format(), )
resp = llm.chat("hey")
chat_engine = index.as_chat_engine(pass all the fields and chat mode too )