Skip to content

Commit

Permalink
wp
Browse files Browse the repository at this point in the history
  • Loading branch information
Disiok committed Jul 25, 2024
1 parent 7fa93af commit a89b584
Showing 1 changed file with 30 additions and 24 deletions.
54 changes: 30 additions & 24 deletions examples/demo_manual.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Apply `nest_asyncio` and bring your own LlamaCloud API key:"
"Follow [instruction](https://docs.cloud.llamaindex.ai/llamacloud/getting_started/api_key) to get an API key from https://cloud.llamaindex.ai/"
]
},
{
Expand All @@ -51,14 +51,11 @@
"metadata": {},
"outputs": [],
"source": [
"# llama-extract is async-first, running the sync code in a notebook requires the use of nest_asyncio\n",
"import nest_asyncio\n",
"\n",
"nest_asyncio.apply()\n",
"\n",
"import os\n",
"\n",
"os.environ[\"LLAMA_CLOUD_API_KEY\"] = \"llx-...\""
"os.environ[\n",
" \"LLAMA_CLOUD_API_KEY\"\n",
"] = \"llx-7PV0mlZKNetJn5hG5UwEucDdhiHXLu4fXo4tgOusoPWVwzMJ\""
]
},
{
Expand Down Expand Up @@ -88,7 +85,7 @@
" },\n",
"}\n",
"\n",
"extraction_schema = extractor.create_schema(\"Test Schema\", data_schema)"
"extraction_schema = await extractor.acreate_schema(\"Test Schema\", data_schema)"
]
},
{
Expand All @@ -104,15 +101,21 @@
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"id='88ea0633-937b-42f1-a35d-7da19c2db74e' created_at=datetime.datetime(2024, 7, 24, 19, 48, 49, 968786, tzinfo=datetime.timezone.utc) updated_at=datetime.datetime(2024, 7, 24, 19, 48, 49, 968786, tzinfo=datetime.timezone.utc) name='Test Schema' project_id='b1be5ffd-3f90-4fd1-9742-ca7c0a30f6f7' data_schema={'type': 'object', 'properties': {'date': {'type': 'string'}, 'amount': {'type': 'number'}, 'number': {'type': 'string'}}}\n"
]
"data": {
"text/plain": [
"{'type': 'object',\n",
" 'properties': {'date': {'type': 'string'},\n",
" 'amount': {'type': 'number'},\n",
" 'number': {'type': 'string'}}}"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print(extraction_schema)"
"extraction_schema.data_schema"
]
},
{
Expand All @@ -132,12 +135,12 @@
"name": "stderr",
"output_type": "stream",
"text": [
"Extracting files: 100%|██████████| 2/2 [00:06<00:00, 3.31s/it]\n"
"Extracting files: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:04<00:00, 2.06s/it]\n"
]
}
],
"source": [
"extractions = extractor.extract(\n",
"extractions = await extractor.aextract(\n",
" extraction_schema.id,\n",
" [\"./data/noisebridge_receipt.pdf\", \"./data/parallels_invoice.pdf\"],\n",
")"
Expand All @@ -156,21 +159,24 @@
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'date': 'Jul 23, 2024', 'amount': '119.99', 'number': 'BKD-73649835575'}\n"
]
"data": {
"text/plain": [
"{'date': 'July 19, 2024', 'amount': '10.0', 'number': '2721 5058'}"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print(extractions[0].data)"
"extractions[0].data"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "llama-extract-tm5usU00-py3.11",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -187,5 +193,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

0 comments on commit a89b584

Please sign in to comment.