Skip to content

Commit

Permalink
cr
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryjliu committed May 14, 2024
1 parent 694bba3 commit ee54738
Showing 1 changed file with 33 additions and 72 deletions.
105 changes: 33 additions & 72 deletions examples/test_tesla_impact_report/test_gpt4o.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,21 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"id": "86b173ac-9fce-4813-bdf1-6dd7d93a491d",
"metadata": {
"tags": []
},
"metadata": {},
"outputs": [],
"source": [
"import nest_asyncio\n",
"\n",
"nest_asyncio.apply()"
]
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"id": "ecc5eba5-96ce-4db7-bba1-f9ece33e681c",
"metadata": {
"tags": []
},
"metadata": {},
"outputs": [],
"source": [
"import os"
Expand Down Expand Up @@ -68,18 +65,16 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": null,
"id": "f46991c1-031b-461f-b9a6-9237a821f4c8",
"metadata": {
"tags": []
},
"metadata": {},
"outputs": [],
"source": [
"from llama_parse import LlamaParse\n",
"\n",
"parser_gpt4o = LlamaParse(\n",
" result_type=\"markdown\",\n",
" base_url=\"https://api.staging.llamaindex.ai\",\n",
" # base_url=\"https://api.staging.llamaindex.ai\",\n",
" api_key=api_key,\n",
" gpt4o_mode=True,\n",
" # gpt4o_api_key=\"<gpt4o_api_key>\"\n",
Expand All @@ -88,32 +83,19 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": null,
"id": "1136ba82-074b-489d-9b0a-d609ccbf02b6",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Started parsing the file under job_id 03b089a3-0f1b-40e9-ab73-67fa430fb329\n",
"."
]
}
],
"metadata": {},
"outputs": [],
"source": [
"documents_gpt4o = parser_gpt4o.load_data('./2019-tesla-impact-report-short.pdf')"
"documents_gpt4o = parser_gpt4o.load_data(\"./2019-tesla-impact-report-short.pdf\")"
]
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": null,
"id": "9e65c54f-3e4c-4c78-b1e8-a55ebeba1f24",
"metadata": {
"tags": []
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -222,11 +204,9 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": null,
"id": "f624e243-1878-4d87-841d-69e57360a7d9",
"metadata": {
"tags": []
},
"metadata": {},
"outputs": [],
"source": [
"from llama_index.core import VectorStoreIndex\n",
Expand All @@ -239,47 +219,41 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": null,
"id": "d8b7c3ad-2147-448c-bcbe-3e6fcd8d5361",
"metadata": {
"tags": []
},
"metadata": {},
"outputs": [],
"source": [
"vector_index = VectorStoreIndex(nodes)"
]
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": null,
"id": "8013351a-180d-4947-9f81-513042175c19",
"metadata": {
"tags": []
},
"metadata": {},
"outputs": [],
"source": [
"query_engine = vector_index.as_query_engine()"
]
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": null,
"id": "795dc5c4-e122-4ff3-94d2-747fa51d5add",
"metadata": {
"tags": []
},
"metadata": {},
"outputs": [],
"source": [
"response = query_engine.query(\"What are the greenhouse emissions for agriculture and transportation?\") "
"response = query_engine.query(\n",
" \"What are the greenhouse emissions for agriculture and transportation?\"\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": null,
"id": "39d2e6bd-3316-49b5-9a5d-5b4b95343e5a",
"metadata": {
"tags": []
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -303,23 +277,19 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": null,
"id": "543c8b63-5cd1-47a1-a8a1-81abbfd3e52b",
"metadata": {
"tags": []
},
"metadata": {},
"outputs": [],
"source": [
"response = query_engine.query(\"What does Tesla aim to do?\") "
"response = query_engine.query(\"What does Tesla aim to do?\")"
]
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": null,
"id": "e739eabf-732b-4f59-9628-972c4bf6c857",
"metadata": {
"tags": []
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -332,14 +302,6 @@
"source": [
"print(str(response))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f6801177-8c23-423f-b02c-4b52a484cf70",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -357,8 +319,7 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
Expand Down

0 comments on commit ee54738

Please sign in to comment.