code: import os
  
  import weaviate
  from llama_index.storage.storage_context import StorageContext
  from llama_index.vector_stores import WeaviateVectorStore
  
  from llama_index.query_engine.retriever_query_engine import RetrieverQueryEngine
  from llama_index.callbacks.base import CallbackManager
  from llama_index import (
      LLMPredictor,
      ServiceContext,
      StorageContext,
      VectorStoreIndex,
  )
  import chainlit as cl
  
  from llama_index.llms import LocalAI
  from llama_index.embeddings import HuggingFaceEmbedding
  import yaml
  
  # Load the configuration file
  with open("config.yaml", "r") as ymlfile:
      cfg = yaml.safe_load(ymlfile)
  
  # Get the values from the configuration file or set the default values
  temperature = cfg['localAI'].get('temperature', 0)
  model_name = cfg['localAI'].get('modelName', "gpt-3.5-turbo")
  api_base = cfg['localAI'].get('apiBase', "http://local-ai.default")
  api_key = cfg['localAI'].get('apiKey', "stub")
  streaming = cfg['localAI'].get('streaming', True)
  weaviate_url = cfg['weviate'].get('url', "http://weviate.default")
  index_name = cfg['weviate'].get('index', "AIChroma")
  query_mode = cfg['query'].get('mode', "hybrid")
  topK = cfg['query'].get('topK', 1)
  alpha = cfg['query'].get('alpha', 0.0)
  embed_model_name = cfg['embedding'].get('model', "BAAI/bge-small-en-v1.5")
  chunk_size = cfg['query'].get('chunkSize', 1024)
  
  
  embed_model = HuggingFaceEmbedding(model_name=embed_model_name)
  
  
  llm = LocalAI(temperature=temperature, model_name=model_name, api_base=api_base, api_key=api_key, streaming=streaming)
  llm.globally_use_chat_completions = True;
  client = weaviate.Client(weaviate_url)
  vector_store = WeaviateVectorStore(weaviate_client=client, index_name=index_name)
  storage_context = StorageContext.from_defaults(vector_store=vector_store)
  
  @cl.on_chat_start
  async def factory():
  
      llm_predictor = LLMPredictor(
          llm=llm
      )
      
      service_context = ServiceContext.from_defaults(embed_model=embed_model, callback_manager=CallbackManager([cl.LlamaIndexCallbackHandler()]), llm_predictor=llm_predictor, chunk_size=chunk_size)
  
      index = VectorStoreIndex.from_vector_store(
          vector_store,
          storage_context=storage_context,
          service_context=service_context
      )
  
      query_engine = index.as_query_engine(vector_store_query_mode=query_mode, similarity_top_k=topK, alpha=alpha, streaming=True)
  
      cl.user_session.set("query_engine", query_engine)
  
  
  @cl.on_message
  async def main(message: cl.Message):
      query_engine = cl.user_session.get("query_engine")
      response = await cl.make_async(query_engine.query)(message.content)
  
      response_message = cl.Message(content="")
  
      for token in response.response_gen:
          await response_message.stream_token(token=token)
  
      if response.response_txt:
          response_message.content = response.response_txt
  
      await response_message.send()
  
apis: llama_index.llms.LocalAI llama_index.LLMPredictor llama_index.StorageContext.from_defaults llama_index.VectorStoreIndex.from_vector_store llama_index.embeddings.HuggingFaceEmbedding llama_index.vector_stores.WeaviateVectorStore
extract_api: [((1360, 1409), 'llama_index.embeddings.HuggingFaceEmbedding', 'HuggingFaceEmbedding', ([], {'model_name': 'embed_model_name'}), '(model_name=embed_model_name)\n', (1380, 1409), False, 'from llama_index.embeddings import HuggingFaceEmbedding\n'), ((1418, 1534), 'llama_index.llms.LocalAI', 'LocalAI', ([], {'temperature': 'temperature', 'model_name': 'model_name', 'api_base': 'api_base', 'api_key': 'api_key', 'streaming': 'streaming'}), '(temperature=temperature, model_name=model_name, api_base=api_base,\n    api_key=api_key, streaming=streaming)\n', (1425, 1534), False, 'from llama_index.llms import LocalAI\n'), ((1582, 1611), 'weaviate.Client', 'weaviate.Client', (['weaviate_url'], {}), '(weaviate_url)\n', (1597, 1611), False, 'import weaviate\n'), ((1627, 1693), 'llama_index.vector_stores.WeaviateVectorStore', 'WeaviateVectorStore', ([], {'weaviate_client': 'client', 'index_name': 'index_name'}), '(weaviate_client=client, index_name=index_name)\n', (1646, 1693), False, 'from llama_index.vector_stores import WeaviateVectorStore\n'), ((1712, 1767), 'llama_index.StorageContext.from_defaults', 'StorageContext.from_defaults', ([], {'vector_store': 'vector_store'}), '(vector_store=vector_store)\n', (1740, 1767), False, 'from llama_index import LLMPredictor, ServiceContext, StorageContext, VectorStoreIndex\n'), ((604, 627), 'yaml.safe_load', 'yaml.safe_load', (['ymlfile'], {}), '(ymlfile)\n', (618, 627), False, 'import yaml\n'), ((1829, 1850), 'llama_index.LLMPredictor', 'LLMPredictor', ([], {'llm': 'llm'}), '(llm=llm)\n', (1841, 1850), False, 'from llama_index import LLMPredictor, ServiceContext, StorageContext, VectorStoreIndex\n'), ((2079, 2198), 'llama_index.VectorStoreIndex.from_vector_store', 'VectorStoreIndex.from_vector_store', (['vector_store'], {'storage_context': 'storage_context', 'service_context': 'service_context'}), '(vector_store, storage_context=\n    storage_context, service_context=service_context)\n', (2113, 2198), False, 'from llama_index import LLMPredictor, ServiceContext, StorageContext, VectorStoreIndex\n'), ((2359, 2408), 'chainlit.user_session.set', 'cl.user_session.set', (['"""query_engine"""', 'query_engine'], {}), "('query_engine', query_engine)\n", (2378, 2408), True, 'import chainlit as cl\n'), ((2482, 2517), 'chainlit.user_session.get', 'cl.user_session.get', (['"""query_engine"""'], {}), "('query_engine')\n", (2501, 2517), True, 'import chainlit as cl\n'), ((2614, 2636), 'chainlit.Message', 'cl.Message', ([], {'content': '""""""'}), "(content='')\n", (2624, 2636), True, 'import chainlit as cl\n'), ((2539, 2572), 'chainlit.make_async', 'cl.make_async', (['query_engine.query'], {}), '(query_engine.query)\n', (2552, 2572), True, 'import chainlit as cl\n'), ((1980, 2010), 'chainlit.LlamaIndexCallbackHandler', 'cl.LlamaIndexCallbackHandler', ([], {}), '()\n', (2008, 2010), True, 'import chainlit as cl\n')]