|
| 1 | +# LangChain |
| 2 | + |
| 3 | +[LangChain][langchain] is a framework designed to simplify the creation of |
| 4 | +applications using large language models. |
| 5 | + |
| 6 | +To get started with LangChain, follow the [instructions][langchain-docs-getting-started]. |
| 7 | + |
| 8 | +## Document loader |
| 9 | + |
| 10 | +Cube's integration with LangChain comes as the [document loader][langchain-docs-cube] |
| 11 | +that is intended to be used to populate a vector database with embeddings derived |
| 12 | +from the data model. Later, this vector database can be queried to find best-matching |
| 13 | +entities of the semantic layer. This is useful to match free-form input, e.g., queries |
| 14 | +in a natural language, with the views and their members in the data model. |
| 15 | + |
| 16 | +<Diagram src="https://ucarecdn.com/32e98c8b-a920-4620-a8d2-05d57618db8e/" /> |
| 17 | + |
| 18 | +We're also providing an chat-based demo application (see source code on GitHub) with example OpenAI prompts for constructing queries to Cube's SQL API. If you wish to create an AI-powered conversational interface for the semantic layer, functioning similar to Delphi, these prompts can be a good starting point. |
| 19 | + |
| 20 | +## Configuring the connection to Cube |
| 21 | + |
| 22 | +The document loader connects to Cube using the [REST API][ref-rest-api], and will need a |
| 23 | +[JWT][ref-jwt] to authenticate. |
| 24 | + |
| 25 | +If you're using Cube Cloud, you can retrieve these details from a deployment's |
| 26 | +<Btn>Overview</Btn> page. |
| 27 | + |
| 28 | +## Querying Cube |
| 29 | + |
| 30 | +Please refer to the [blog post](https://cube-blog-preview.vercel.app/blog/introducing-the-langchain-integration) |
| 31 | +for details on querying Cube and building a complete AI-based application. |
| 32 | + |
| 33 | +Also, please feel free to review a chat-based demo application [source code](https://github.com/cube-js/cube/tree/master/examples/langchain) |
| 34 | +on GitHub. |
| 35 | + |
| 36 | +[langchain]: https://python.langchain.com/ |
| 37 | +[langchain-docs-getting-started]: |
| 38 | + https://python.langchain.com/docs/get_started/installation.html |
| 39 | +[langchain-docs-cube]: |
| 40 | + https://python.langchain.com/docs/integrations/document_loaders/cube_semantic#example |
| 41 | +[ref-rest-api]: /product/apis-integrations/rest-api |
| 42 | +[ref-jwt]: /product/auth#generating-json-web-tokens-jwt |
0 commit comments