![[llm-agent.drawio.svg]]
The diagram depicts a high-level architecture of a system designed to answer business questions using a semantic layer and a consumption layer.
**Tools:** Cube Cloud, Langchain, FAISS, Streamlit, and OpenAI
Here's a step-by-step explanation of the process:
1. **User Interaction:**
- A business user interacts with the system by asking a question, such as "How many orders were processed last year?"
2. **Frontend UI (Streamlit):**
- The question is received by the front-end user interface built with Streamlit.
3. **Semantic Layer(Cube Cloud) and Langchain:**
- The semantic layer contains dimensions and measures relevant to the business data.
- Langchain is responsible for loading the semantic data through a semantic loader, which acts as a document loader.
4. **FAISS (Vector Store):**
- The semantic data is processed and stored as OpenAI embeddings in FAISS, which is a vector store optimized for fast similarity search.
5. **LLM (Large Language Model - OpenAI):**
- When the question is received, the system utilizes FAISS to search for the relevant tables and columns in the vector store.
- The results from FAISS are used to generate an appropriate SQL query using the LLM.
6. **Query Execution and Result Retrieval:**
- The generated SQL query is executed on the underlying data source to retrieve the results.
- The results are then passed back through the semantic layer, possibly involving further processing and aggregation according to the defined dimensions and measures.
7. **Display to User:**
- Finally, the retrieved results are displayed to the business user through the Streamlit front-end interface, answering their initial question.
In summary, the system leverages advanced AI and machine learning technologies to understand and process natural language queries, searches relevant semantic data, generates and executes SQL queries, and provides the results to the user in a seamless and efficient manner.