{"cells": [{"cell_type": "markdown", "id": "b890c854", "metadata": {}, "source": ["\"在\n"]}, {"attachments": {}, "cell_type": "markdown", "id": "7fc13177-7d9d-4959-bbe9-fa26d60ea786", "metadata": {}, "source": ["# 创建阅读器\n", "\n", "我们将展示LlamaIndex如何与您的Make.com工作流程相匹配,通过将GPT索引响应发送到一个场景Webhook。\n"]}, {"cell_type": "markdown", "id": "06a9c62f", "metadata": {}, "source": ["如果您在colab上打开这个笔记本,您可能需要安装LlamaIndex 🦙。\n"]}, {"cell_type": "code", "execution_count": null, "id": "5325ab6b", "metadata": {}, "outputs": [], "source": ["%pip install llama-index-readers-make-com"]}, {"cell_type": "code", "execution_count": null, "id": "3212ef72", "metadata": {}, "outputs": [], "source": ["!pip install llama-index"]}, {"cell_type": "code", "execution_count": null, "id": "d2289d27", "metadata": {}, "outputs": [], "source": ["import logging\n", "import sys\n", "\n", "logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n", "logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))"]}, {"cell_type": "code", "execution_count": null, "id": "f90c60a6-50b3-4b66-abf3-9723dac8a045", "metadata": {}, "outputs": [], "source": ["from llama_index.core import VectorStoreIndex, SimpleDirectoryReader\n", "from llama_index.readers.make_com import MakeWrapper"]}, {"attachments": {}, "cell_type": "markdown", "id": "4fbe9406", "metadata": {}, "source": ["下载数据\n"]}, {"cell_type": "code", "execution_count": null, "id": "2751b35f", "metadata": {}, "outputs": [], "source": ["!mkdir -p 'data/paul_graham/'\n", "!wget 'https://raw.githubusercontent.com/run-llama/llama_index/main/docs/docs/examples/data/paul_graham/paul_graham_essay.txt' -O 'data/paul_graham/paul_graham_essay.txt'"]}, {"cell_type": "code", "execution_count": null, "id": "dd8885c5-39e2-444b-9666-5032ab4cb50d", "metadata": {}, "outputs": [], "source": ["documents = SimpleDirectoryReader(\"./data/paul_graham/\").load_data()\n", "index = VectorStoreIndex.from_documents(documents=documents)"]}, {"cell_type": "code", "execution_count": null, "id": "e5f7d888-01ed-40f7-9216-6c7340b229bf", "metadata": {}, "outputs": [], "source": ["# 将日志级别设置为DEBUG,以获得更详细的输出", "# 查询索引", "query_str = \"作者在成长过程中做了什么?\"", "query_engine = index.as_query_engine()", "response = query_engine.query(query_str)"]}, {"cell_type": "code", "execution_count": null, "id": "eaf06ad9-ba04-42fb-a7c8-daf7a5320b53", "metadata": {}, "outputs": [], "source": ["# 将响应发送到Make.com的webhook", "wrapper = MakeWrapper()", "wrapper.pass_response_to_webhook(\"\", response, query_str)"]}], "metadata": {"kernelspec": {"display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3"}, "language_info": {"codemirror_mode": {"name": "ipython", "version": 3}, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3"}}, "nbformat": 4, "nbformat_minor": 5}