mirror of
https://github.com/run-llama/llama_cloud_services.git
synced 2026-07-19 16:43:32 -04:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a73516665e | |||
| 6c95690b12 | |||
| 6c490ab781 | |||
| 737884d297 | |||
| 00c63b046d | |||
| d04bf78335 | |||
| 7dbe12b893 | |||
| 4caa9cbc02 | |||
| af1f61186a | |||
| 13dea6ae1a | |||
| fa9698a681 | |||
| 4bed7c7895 |
@@ -1,4 +1,4 @@
|
||||
# LlamaParse (Preview)
|
||||
# LlamaParse
|
||||
|
||||
LlamaParse is an API created by LlamaIndex to efficiently parse and represent files for efficient retrieval and context augmentation using LlamaIndex frameworks.
|
||||
|
||||
@@ -12,11 +12,20 @@ Currently available in preview mode for **free**. Try it out today!
|
||||
|
||||
First, login and get an api-key from `https://cloud.llamaindex.ai`.
|
||||
|
||||
Install the package:
|
||||
Then, make sure you have the latest LlamaIndex version installed.
|
||||
|
||||
**NOTE:** If you are upgrading from v0.9.X, we recommend following our [migration guide](https://pretty-sodium-5e0.notion.site/v0-10-0-Migration-Guide-6ede431dcb8841b09ea171e7f133bd77), as well as uninstalling your previous version first.
|
||||
|
||||
```
|
||||
pip uninstall llama-index # run this if upgrading from v0.9.x or older
|
||||
pip install -U llama-index --upgrade --no-cache-dir --force-reinstall
|
||||
```
|
||||
|
||||
Lastly, install the package:
|
||||
|
||||
`pip install llama-parse`
|
||||
|
||||
Then, you can run the following to parse your first PDF file:
|
||||
Now you can run the following to parse your first PDF file:
|
||||
|
||||
```python
|
||||
import nest_asyncio
|
||||
@@ -28,7 +37,8 @@ parser = LlamaParse(
|
||||
api_key="llx-...", # can also be set in your env as LLAMA_CLOUD_API_KEY
|
||||
result_type="markdown", # "markdown" and "text" are available
|
||||
num_workers=4, # if multiple files passed, split in `num_workers` API calls
|
||||
verbose=True
|
||||
verbose=True,
|
||||
language="en" # Optionaly you can define a language, default=en
|
||||
)
|
||||
|
||||
# sync
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install llama-index\n",
|
||||
"!pip install llama-index-core==0.10.6.post1\n",
|
||||
"!pip install llama-index-core\n",
|
||||
"!pip install llama-index-embeddings-openai\n",
|
||||
"!pip install llama-index-postprocessor-flag-embedding-reranker\n",
|
||||
"!pip install git+https://github.com/FlagOpen/FlagEmbedding.git\n",
|
||||
@@ -489,7 +489,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "llama-parse-aNC435Vv-py3.11",
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -503,10 +503,9 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.4"
|
||||
},
|
||||
"orig_nbformat": 4
|
||||
"version": "3.10.10"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
"nbformat_minor": 4
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,296 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Using llama-parse with AstraDB"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"In this notebook, we show a basic RAG-style example that uses `llama-parse` to parse a PDF document, store the corresponding document into a vector store (`AstraDB`) and finally, perform some basic queries against that store. The notebook is modeled after the quick start notebooks and hence is meant as a way of getting started with `llama-parse`, backed by a vector database."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Requirements"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# First, install the required dependencies\n",
|
||||
"!pip install --quiet llama-index llama-parse llama-index-vector-stores-astra llama-index-llms-openai astrapy"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Configuration"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"import openai\n",
|
||||
"\n",
|
||||
"from getpass import getpass\n",
|
||||
"\n",
|
||||
"# Get all required API keys and parameters\n",
|
||||
"llama_cloud_api_key = getpass(\"Enter your Llama Index Cloud API Key: \")\n",
|
||||
"api_endpoint = input(\"Enter your Astra DB API Endpoint: \")\n",
|
||||
"token = getpass(\"Enter your Astra DB Token: \")\n",
|
||||
"namespace = input(\"Enter your Astra DB namespace (optional, must exist on Astra): \") or None\n",
|
||||
"openai_api_key = getpass(\"Enter your OpenAI API Key: \")\n",
|
||||
"\n",
|
||||
"os.environ[\"LLAMA_CLOUD_API_KEY\"] = llama_cloud_api_key\n",
|
||||
"openai.api_key = openai_api_key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# llama-parse 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()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Using llama-parse to parse a PDF"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Download complete.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Grab a PDF from Arxiv for indexing\n",
|
||||
"import requests \n",
|
||||
"\n",
|
||||
"# The URL of the file you want to download\n",
|
||||
"url = \"https://arxiv.org/pdf/1706.03762.pdf\"\n",
|
||||
"# The local path where you want to save the file\n",
|
||||
"file_path = \"./attention.pdf\"\n",
|
||||
"\n",
|
||||
"# Perform the HTTP request\n",
|
||||
"response = requests.get(url)\n",
|
||||
"\n",
|
||||
"# Check if the request was successful\n",
|
||||
"if response.status_code == 200:\n",
|
||||
" # Open the file in binary write mode and save the content\n",
|
||||
" with open(file_path, \"wb\") as file:\n",
|
||||
" file.write(response.content)\n",
|
||||
" print(\"Download complete.\")\n",
|
||||
"else:\n",
|
||||
" print(\"Error downloading the file.\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Started parsing the file under job_id ce3909a7-54cf-438b-849a-fe9a903b0c71\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from llama_parse import LlamaParse\n",
|
||||
"\n",
|
||||
"documents = LlamaParse(result_type=\"text\").load_data(file_path)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'rmer - model architecture.\\nThe Transformer follows this overall architecture using stacked self-attention and point-wise, fully\\nconnected layers for both the encoder and decoder, shown in the left and right halves of Figure 1,\\nrespectively.\\n3.1 Encoder and Decoder Stacks\\nEncoder: The encoder is composed of a stack of N = 6 identical layers. Each layer has two\\nsub-layers. The first is a multi-head self-attention mechanism, and the second is a simple, position-\\nwise fully connected feed-forward network. We employ a residual connection [11] around each of\\nthe two sub-layers, followed by layer normalization [1]. That is, the output of each sub-layer is\\nLayerNorm(x + Sublayer(x)), where Sublayer(x) is the function implemented by the sub-layer\\nitself. To facilitate these residual connections, all sub-layers in the model, as well as the embedding\\nlayers, produce outputs of dimension dmodel = 512.\\nDecoder: The decoder is also composed of a stack of N = 6 identical layers. In addition '"
|
||||
]
|
||||
},
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Take a quick look at some of the parsed text from the document:\n",
|
||||
"documents[0].get_content()[10000:11000]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Storing into Astra DB"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from llama_index.vector_stores.astra import AstraDBVectorStore\n",
|
||||
"\n",
|
||||
"astra_db_store = AstraDBVectorStore(\n",
|
||||
" token=token,\n",
|
||||
" api_endpoint=api_endpoint,\n",
|
||||
" namespace=namespace,\n",
|
||||
" collection_name=\"astra_v_table_llamaparse\",\n",
|
||||
" embedding_dimension=1536\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from llama_index.core.node_parser import SimpleNodeParser\n",
|
||||
"\n",
|
||||
"node_parser = SimpleNodeParser()\n",
|
||||
"\n",
|
||||
"nodes = node_parser.get_nodes_from_documents(documents)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from llama_index.embeddings.openai import OpenAIEmbedding\n",
|
||||
"from llama_index.core import VectorStoreIndex, StorageContext\n",
|
||||
"\n",
|
||||
"storage_context = StorageContext.from_defaults(vector_store=astra_db_store)\n",
|
||||
"\n",
|
||||
"index = VectorStoreIndex(\n",
|
||||
" nodes=nodes,\n",
|
||||
" storage_context=storage_context,\n",
|
||||
" embed_model=OpenAIEmbedding(api_key=openai_api_key),\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Simple RAG Example"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"query_engine = index.as_query_engine(similarity_top_k=15)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\n",
|
||||
"***********New LlamaParse+ Basic Query Engine***********\n",
|
||||
"Multi-Head Attention is also known as multi-headed self-attention.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"query = \"What is Multi-Head Attention also known as?\"\n",
|
||||
"\n",
|
||||
"response_1 = query_engine.query(query)\n",
|
||||
"print(\"\\n***********New LlamaParse+ Basic Query Engine***********\")\n",
|
||||
"print(response_1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'We used beam search as described in the previous section, but no\\ncheckpoint averaging. We present these results in Table 3.\\nIn Table 3 rows (A), we vary the number of attention heads and the attention key and value dimensions,\\nkeeping the amount of computation constant, as described in Section 3.2.2. While single-head\\nattention is 0.9 BLEU worse than the best setting, quality also drops off with too many heads.\\nIn Table 3 rows (B), we observe that reducing the attention key size dk hurts model quality. This\\nsuggests that determining compatibility is not easy and that a more sophisticated compatibility\\nfunction than dot product may be beneficial. We further observe in rows (C) and (D) that, as expected,\\nbigger models are better, and dropout is very helpful in avoiding over-fitting. In row (E) we replace our\\nsinusoidal positional encoding with learned positional embeddings [9], and observe nearly identical\\nresults to the base model.\\n6.3 English Constituency Parsing\\nTo evaluate if the Transformer can generalize to other tasks we performed experiments on English\\nconstituency parsing. This task presents specific challenges: the output is subject to strong structural\\nconstraints and is significantly longer than the input. Furthermore, RNN sequence-to-sequence\\nmodels have not been able to attain state-of-the-art results in small-data regimes [37].\\nWe trained a 4-layer transformer with dmodel = 1024 on the Wall Street Journal (WSJ) portion of the\\nPenn Treebank [25], about 40K training sentences. We also trained it in a semi-supervised setting,\\nusing the larger high-confidence and BerkleyParser corpora from with approximately 17M sentences\\n[37]. We used a vocabulary of 16K tokens for the WSJ only setting and a vocabulary of 32K tokens\\nfor the semi-supervised setting.\\nWe performed only a small number of experiments to select the dropout, both attention and residual\\n(section 5.4), learning rates and beam size on the Section 22 development set, all other parameters\\nremained unchanged from the English-to-German base translation model. During inference, we\\n 9\\n---\\nTable 4: The Transformer generalizes well to English constituency parsing (Results are on Section 23\\nof WSJ)\\n Parser Training WSJ 23 F1\\n Vinyals & Kaiser el al. (2014) [37] WSJ only, discriminative 88.3\\n Petrov et al. (2006) [29] WSJ only, discriminative 90.4\\n Zhu et al. (2013) [40] WSJ only, discriminative 90.4\\n Dyer et al. (2016) [8] WSJ only, discriminative 91.7\\n Transformer (4 layers) WSJ only, discriminative 91.3\\n Zhu et al. (2013) [40] semi-supervised 91.3\\n Huang & Harper (2009) [14] semi-supervised 91.3\\n McClosky et al. (2006) [26] semi-supervised 92.1\\n Vinyals & Kaiser el al. (2014) [37] semi-supervised 92.1\\n Transformer (4 layers) semi-supervised 92.7\\n Luong et al. (2015) [23] multi-task 93.0\\n Dyer et al. (2016) [8] generative 93.3\\nincreased the maximum output length to input length + 300. We used a beam size of 21 and α = 0.3\\nfor both WSJ only and the semi-supervised setting.\\nOur results in Table 4 show that despite the lack of task-specific tuning our model performs sur-\\nprisingly well, yielding better results than all previously reported models with the exception of the\\nRecurrent Neural Network Grammar [8].\\nIn contrast to RNN sequence-to-sequence models [37], the Transformer outperforms the Berkeley-\\nParser [29] even when training only on the WSJ training set of 40K sentences.\\n7 Conclusion\\nIn this work, we presented the Transformer, the first sequence transduction model based entirely on\\nattention, replacing the recurrent layers most commonly used in encoder-decoder architectures with\\nmulti-headed self-attention.\\nFor translation tasks, the Transformer can be trained significantly faster than architectures based\\non recurrent or convolutional layers.'"
|
||||
]
|
||||
},
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Take a look at one of the source nodes from the response\n",
|
||||
"response_1.source_nodes[0].get_content()"
|
||||
]
|
||||
}
|
||||
],
|
||||
"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",
|
||||
"version": "3.11.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
||||
@@ -168,7 +168,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "llama-parse-aNC435Vv-py3.11",
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -182,10 +182,9 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.5"
|
||||
},
|
||||
"orig_nbformat": 4
|
||||
"version": "3.10.10"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
"nbformat_minor": 4
|
||||
}
|
||||
|
||||
@@ -0,0 +1,481 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "28d15ea5-a3eb-4ee5-9d91-8dbd95e53129",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Multi-Language Support in LlamaParse\n",
|
||||
"\n",
|
||||
"LlamaParse supports users to specify a `language` parameter before uploading documents, giving users better OCR capabilities over non-English PDFs, parsing images into more accurate representations.\n",
|
||||
"\n",
|
||||
"You can specify 80+ different languages: see this file for a full list of supported languages: https://github.com/run-llama/llama_parse/blob/main/llama_parse/base.py.\n",
|
||||
"\n",
|
||||
"This notebook shows a demo of this in action. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "15539193-2f5c-4ecf-9ca4-9aee6f888468",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install llama-index llama-parse"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "87322210-c21c-43d6-b459-2e8a828ac576",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# llama-parse 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",
|
||||
"# os.environ[\"LLAMA_CLOUD_API_KEY\"] = \"llx-...\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "2b5cabdf-342a-42d2-8ad4-0ba7c46cdfb9",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Load in a French PDF\n",
|
||||
"\n",
|
||||
"We load in the 2022 annual report from Agence France Tresor."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "e81e0a08-3a99-42e6-adcc-00bb4ce1c3d4",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!wget \"https://www.dropbox.com/scl/fi/fxg17log5ydwoflhxmgrb/treasury_report.pdf?rlkey=mdintk0o2uuzkple26vc4v6fd&dl=1\" -O treasury_report.pdf"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "ecfc578c-3c7f-4ec1-aa06-51565c28632b",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Started parsing the file under job_id 476966e1-9e04-49e7-a5dc-952b053b8b94\n",
|
||||
"......"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from llama_parse import LlamaParse\n",
|
||||
"\n",
|
||||
"parser = LlamaParse(\n",
|
||||
" result_type=\"text\",\n",
|
||||
" language=\"fr\"\n",
|
||||
")\n",
|
||||
"documents = parser.load_data(\"./treasury_report.pdf\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "0c37db27-3496-4a59-918b-701c9ad7706d",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" ET GESTION DE LA DETTE DE L’ÉTAT\n",
|
||||
" P.56 FOCUS OAT VERTES\n",
|
||||
" P.60 CONTRÔLE DES RISQUES & POST-MARCHÉ\n",
|
||||
" Chiffres de l’exercice 2022 P.64 À 105\n",
|
||||
" P.65 ACTIVITÉ DE L’AFT\n",
|
||||
" P.84 RAPPORT STATISTIQUE\n",
|
||||
" FICHES TECHNIQUES GLOSSAIRES LISTE DES ABRÉVIATIONS\n",
|
||||
" P.106 P.118 P.122\n",
|
||||
" AGENCE FRANCE TRÉSOR - RAPPORT D’ACTIVITÉ 2022 3\n",
|
||||
"---\n",
|
||||
" Édito\n",
|
||||
" 111 Avec une croissance\n",
|
||||
" de +2,5 %, la France a illustré\n",
|
||||
" une nouvelle fois sa résilience\n",
|
||||
" économique face aux chocs.\n",
|
||||
"4 AGENCE FRANCE TRÉSOR - RAPPORT D’ACTIVITÉ 2022\n",
|
||||
"---\n",
|
||||
" L’économie française en 2022 :\n",
|
||||
" résilience face aux chocs géopolitiques\n",
|
||||
" et économiques\n",
|
||||
" sa résilience économique face aux lors du dernier trimestre de 2022.\n",
|
||||
"LE DÉBUT DE chocs. Cette croissance a été permise Malgré un climat des affaires impacté\n",
|
||||
"L’ANNÉE 2022 grâce à une forte demande intérieure par l’inflation, le soutien apporté\n",
|
||||
" alimentée par le dynamisme de aux TPE/PME leur a permis de faire\n",
|
||||
"SEMBLAIT l’investissement et, en dépit de face aux défis énergétiques tout en\n",
|
||||
" l’inflation, d’une résilience de la préservant l’emploi.\n",
|
||||
"ENGAGÉ DANS consommation des ménages sur une\n",
|
||||
" grande partie de l’année. Afin de combattre l’inflation qui a\n",
|
||||
"UNE DYNAMIQUE largement dépassé la cible de 2 %,\n",
|
||||
" Le taux d’inflation des prix à la la BCE, de concert avec les banques\n",
|
||||
"EFFICACE DE consommation français est resté l’un centrales des principales économies\n",
|
||||
"SORTIE DE CRISE des plus bas d’Europe avec +6,0 % développées, a adapté sa fonction de\n",
|
||||
" en 2022, s’appuyant, d’une part, sur réaction en mettant fin aux politiques\n",
|
||||
"PORTÉE PAR l’atout structurel que représente un d’assouplissement monétaire qu’elle\n",
|
||||
" mix énergétique parmi les moins menait depuis la crise financière de\n",
|
||||
"UNE REPRISE exposés à la Russie et, d’autre part, 2008. Ainsi, dès juillet 2022, et pour\n",
|
||||
" sur les politiques proactives du la première fois en 10 ans, la BCE a\n",
|
||||
"ÉCONOMIQUE gouvernement avec la mise en place augmenté ses taux directeurs. Les\n",
|
||||
" du bouclier tarifaire, de la remise taux d’emprunts de l’État à 10 ans se\n",
|
||||
"INÉDITE carburant et du chèque énergie. sont ainsi progressivement éloignés\n",
|
||||
"AMORCÉE Ces dispositifs, temporaires, ont de leur territoire négatif pour\n",
|
||||
" été progressivement supprimés : la atteindre 3,10 % en fin d’année.\n",
|
||||
"EN 2021. remise carburant, d’abord prolongée\n",
|
||||
" jusqu’à mi-novembre a pris fin Cette décision s’est également\n",
|
||||
"Le déclenchement de la guerre en en décembre 2022, tandis que le accompagnée de la fin du\n",
|
||||
"Ukraine par la Russie dès février a chèque énergie exceptionnel a pris programme d’achat d’urgence (PEPP)\n",
|
||||
"rebattu les cartes de cet équilibre, fin en mars 2023. mis en place pendant la pandémie,\n",
|
||||
"provoquant des bouleversements suivi de la réduction progressive de\n",
|
||||
"majeurs sur les plans géopolitiques et Le marché du travail français a par son bilan, à un rythme mensuel de 15\n",
|
||||
"économiques, avec le déploiement ailleurs montré toute sa robustesse, milliards d’euros par mois.\n",
|
||||
"de sanctions à l’encontre de la Russie la dynamique de reprise initiée en\n",
|
||||
"et une forte poussée inflationniste. 2021 ainsi que l’effet des réformes L’Agence France Trésor a fait face à ce\n",
|
||||
"Face à cette situation, les principales structurelles engagées les années contexte de grands bouleversements\n",
|
||||
"banques centrales mondiales, dont précédentes permettant au taux géopolitiques, économiques et\n",
|
||||
"la Banque centrale européenne d’emploi des Français âgés de 15 à 64 financiers en s’appuyant sur ses\n",
|
||||
"(BCE), ont engagé une politique de ans d’atteindre fin 2022 un niveau principes de régularité, de prévisibilité\n",
|
||||
"normalisation monétaire rapide de 68,1 %, un record depuis 1975. et de transparence. Cette stratégie\n",
|
||||
"pour lutter contre l’inflation. La reprise économique de début s’est de nouveau révélée robuste et,\n",
|
||||
"Parallèlement, le gouvernement d’année et les effets positifs du plan alliée à l’engagement et à l’efficacité\n",
|
||||
"français a mis en place des mesures France Relance ont permis la création de ses équipes, ainsi qu’à la qualité\n",
|
||||
"(à hauteur de 43,6 milliards d’euros de 337 100 emplois, essentiellement de crédit de la signature de la France,\n",
|
||||
"sur l’année 2022) pour protéger les dans le secteur salarié marchand. Ce lui a permis d’accomplir sa mission\n",
|
||||
"entreprises et les ménages. dynamisme a aussi conduit à la chute de financement de l’action publique\n",
|
||||
" du taux de chômage, atteignant son au bénéfice de tous.\n",
|
||||
"Avec une croissance de +2,5 %, la niveau le plus bas depuis mars 2008\n",
|
||||
"France a illustré une nouvelle fois avec 7,2 % de demandeurs d’emploi\n",
|
||||
" Emmanuel Moulin\n",
|
||||
" DIRECTEUR GÉNÉRAL DU TRÉSOR\n",
|
||||
" ET PRÉSIDENT DE L’AFT\n",
|
||||
" AGENCE FRANCE TRÉSOR - RAPPORT D’ACTIVITÉ 2022 5\n",
|
||||
"---\n",
|
||||
" du directeur général Le mot\n",
|
||||
" 011 En 2022, le choc d’inflation\n",
|
||||
" et la normalisation\n",
|
||||
" de la politique monétaire\n",
|
||||
" ont mis fin à une décennie\n",
|
||||
" de taux historiquement bas.\n",
|
||||
"6 AGENCE FRANCE TRÉSOR - RAPPORT D’ACTIVITÉ 2022\n",
|
||||
"---\n",
|
||||
" MALGRÉ UN CONTEXTE DE MARCHÉ MOUVEMENTÉ ET LES MESURES D’AMPLEUR\n",
|
||||
" PRISES POUR LIMITER L’IMPACT DE L’INFLATION SUR LES MÉNAGES ET\n",
|
||||
" LES ENTREPRISES, LE PROGRAMME DE FINANCEMENT À MOYEN ET LONG TERME\n",
|
||||
" EST DEMEURÉ INCHANGÉ À 260 MILLIARDS D’EUROS, STABLE PAR RAPPORT\n",
|
||||
" À 2021, ET LA DETTE DE COURT TERME A ÉTÉ RÉDUITE DE 7 MILLIARDS D’EUROS.\n",
|
||||
"En janvier 2022, la normalisation de d’obligations indexées sur l’inflation, la dette de court terme a été réduite\n",
|
||||
"la politique monétaire en zone euro sur lequel a été enregistré un de 7 milliards d’euros. En effet, le\n",
|
||||
"était une perspective de moyen supplément d’indexation supérieur dynamisme des recettes fiscales et\n",
|
||||
"terme. Quelques semaines plus tard, de 17 milliards d’euros à celui de la trésorerie levée lors de la crise\n",
|
||||
"l’invasion de l’Ukraine par la Russie l’année 2021. Il s’est également sanit\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(documents[0].get_content()[1000:10000])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "be161577-7b1e-4710-b721-f549feb8e6d0",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Download Chinese PDF"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"id": "ac332ea3-cfff-4216-b292-62410a26c336",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"--2024-02-28 16:41:26-- https://www.dropbox.com/scl/fi/g5ojyzk4m44hl7neut6vc/chinese_pdf.pdf?rlkey=45reu51kjvdvic6zucr8v9sh3&dl=1\n",
|
||||
"Resolving www.dropbox.com (www.dropbox.com)... 162.125.13.18\n",
|
||||
"Connecting to www.dropbox.com (www.dropbox.com)|162.125.13.18|:443... connected.\n",
|
||||
"HTTP request sent, awaiting response... 302 Found\n",
|
||||
"Location: https://uc7a03fdb7d960dbedb23e9298ab.dl.dropboxusercontent.com/cd/0/inline/COJ69Wg2e7wH9S0ELzl4j4znoonRSQS-JJrH6mxy_vcrvY-KV7f10kMyQH6IYmtfMh_9xcDNOYnLkWkwMTYItwE1XQB5nqXbjmLJ4jLbDrMeu7-b49m796ctxevwnp7k1_U/file?dl=1# [following]\n",
|
||||
"--2024-02-28 16:41:27-- https://uc7a03fdb7d960dbedb23e9298ab.dl.dropboxusercontent.com/cd/0/inline/COJ69Wg2e7wH9S0ELzl4j4znoonRSQS-JJrH6mxy_vcrvY-KV7f10kMyQH6IYmtfMh_9xcDNOYnLkWkwMTYItwE1XQB5nqXbjmLJ4jLbDrMeu7-b49m796ctxevwnp7k1_U/file?dl=1\n",
|
||||
"Resolving uc7a03fdb7d960dbedb23e9298ab.dl.dropboxusercontent.com (uc7a03fdb7d960dbedb23e9298ab.dl.dropboxusercontent.com)... 162.125.13.15\n",
|
||||
"Connecting to uc7a03fdb7d960dbedb23e9298ab.dl.dropboxusercontent.com (uc7a03fdb7d960dbedb23e9298ab.dl.dropboxusercontent.com)|162.125.13.15|:443... connected.\n",
|
||||
"HTTP request sent, awaiting response... 302 Found\n",
|
||||
"Location: /cd/0/inline2/COKEp-d6ZqzrIIaPRlanov72wwnd7GX5eNSPnsxug0A8pOpek8hO6eFxp84cY3_NMBRsAqtX-IIVPpcfYHNoV__mpu1SsOV8wV8a68DwVKaVJRJriY_KV8lEFocvLgf7c7mhrREbIJ1UBN2fx6S_qWegwVIen1z1-pw-K7icMnA3EKJNqM9DFtqx9ct0FI4vdYGsv8ckLF26WgAhs96k1cHn-VRJle4SKstdYs8EmBxiuFLXZRCL3gljwAsLu3J6WRvis9v7VJ2zNhgrcT-ZnVujlpQGoGWLLPmREKffK608Xfz1XE35DzO28e_mm4SUPRfsP2mvIUrJUtUrhobR4siqQRGojxi0S7-da4Y7fpB4Tw/file?dl=1 [following]\n",
|
||||
"--2024-02-28 16:41:27-- https://uc7a03fdb7d960dbedb23e9298ab.dl.dropboxusercontent.com/cd/0/inline2/COKEp-d6ZqzrIIaPRlanov72wwnd7GX5eNSPnsxug0A8pOpek8hO6eFxp84cY3_NMBRsAqtX-IIVPpcfYHNoV__mpu1SsOV8wV8a68DwVKaVJRJriY_KV8lEFocvLgf7c7mhrREbIJ1UBN2fx6S_qWegwVIen1z1-pw-K7icMnA3EKJNqM9DFtqx9ct0FI4vdYGsv8ckLF26WgAhs96k1cHn-VRJle4SKstdYs8EmBxiuFLXZRCL3gljwAsLu3J6WRvis9v7VJ2zNhgrcT-ZnVujlpQGoGWLLPmREKffK608Xfz1XE35DzO28e_mm4SUPRfsP2mvIUrJUtUrhobR4siqQRGojxi0S7-da4Y7fpB4Tw/file?dl=1\n",
|
||||
"Reusing existing connection to uc7a03fdb7d960dbedb23e9298ab.dl.dropboxusercontent.com:443.\n",
|
||||
"HTTP request sent, awaiting response... 200 OK\n",
|
||||
"Length: 8074860 (7.7M) [application/binary]\n",
|
||||
"Saving to: ‘chinese_pdf.pdf’\n",
|
||||
"\n",
|
||||
"chinese_pdf.pdf 100%[===================>] 7.70M 37.9MB/s in 0.2s \n",
|
||||
"\n",
|
||||
"2024-02-28 16:41:28 (37.9 MB/s) - ‘chinese_pdf.pdf’ saved [8074860/8074860]\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"!wget \"https://www.dropbox.com/scl/fi/g5ojyzk4m44hl7neut6vc/chinese_pdf.pdf?rlkey=45reu51kjvdvic6zucr8v9sh3&dl=1\" -O chinese_pdf.pdf"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"id": "45235b17-08f0-48f1-92aa-06711225860b",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Started parsing the file under job_id 0089f0b6-29ee-4e94-a8bf-49a137666f15\n",
|
||||
".........."
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from llama_parse import LlamaParse\n",
|
||||
"\n",
|
||||
"parser = LlamaParse(\n",
|
||||
" result_type=\"text\",\n",
|
||||
" language=\"ch_sim\"\n",
|
||||
")\n",
|
||||
"documents = parser.load_data(\"./chinese_pdf.pdf\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 28,
|
||||
"id": "f0d546cc-6549-4cf5-8b37-0896f4e8d43d",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"中国投资有限责任公司2022年度报告 5\n",
|
||||
"---\n",
|
||||
"企业文化与核心价值观\n",
|
||||
"使命 核心价值观\n",
|
||||
" 致力于实现国家外汇资金多元化投资,在可接受风险范围内 责任 合力\n",
|
||||
" 实现股东权益最大化,以服务于国家经济发展和深化金融体\n",
|
||||
" 制改革的需要 忠于使命、勤勉尽责 立足大局、有效协同\n",
|
||||
" 是公司遵奉的核心价值取向 是实现公司可持续发展的关键\n",
|
||||
" 愿景 专业 进取\n",
|
||||
" 成为受人尊重的国际一流主权财富基金 坚持良好的专业精神和职业操守 求知进取、追求卓越\n",
|
||||
" 是公司成功的基石 是公司成功和发展壮大的内驱力\n",
|
||||
"---\n",
|
||||
"01 我们将一以贯之地践行全球发展倡议,充分维护投资东道国利益,\n",
|
||||
" 积极投身可持续投资,助力世界经济实现更高质量、更有韧性的发展。\n",
|
||||
" 致 辞\n",
|
||||
" 3 中国投资有限责任公司2022年度报告 中国投资有限责任公司2022年度报告 4\n",
|
||||
"---\n",
|
||||
" “行之力则知愈进,知之深则行愈达。”站在新的历史起点上,中投公司\n",
|
||||
" 将继续秉承精益求精、追求卓越的专业精神,与国内外合作伙伴一起深化\n",
|
||||
" 合作,共聚力量、共迎挑战、共享成果,开启打造世界一流主权财富基金\n",
|
||||
" 的新篇章,为助力全球经济发展作出新贡献! #Ave彭纯\n",
|
||||
" 董事长\n",
|
||||
" 2022年,是中投公司成立十五周年。\n",
|
||||
"董事长致辞 自2007年成立以来,中投公司坚守长期机构投资者定位,坚持国际化、市场化、专业化、负责任原则,搭\n",
|
||||
" 建起符合大型国际投资机构特点的治理架构,形成了系统完备的投资管理体系,经受住了国际金融危机、世纪\n",
|
||||
" 疫情等多个历史罕见的风险与挑战。如今,公司对外投资业务覆盖国际市场主要资产类别以及全球110多个国家\n",
|
||||
" 和地区,培养了一支高素质专业化的投资管理人才队伍,搭建了互利共赢的投资合作“朋友圈”,长期投资收\n",
|
||||
" 益超越董事会制定的考核目标,为促进国家外汇资产保值增值、服务国内国际双循环作出了积极贡献,在推动\n",
|
||||
" 全球投资合作、助力世界经济增长中贡献了中投力量,书写了中国主权财富基金不平凡的创业发展史。\n",
|
||||
"5 中国投资有限责任公司2022年度报告 中国投资有限责任公司2022年度报告 6\n",
|
||||
"---\n",
|
||||
" 2022年以来,全球地缘政治风险显著攀升,产业链供应链持续调整重构,美欧央行大幅加息,国际资本 我们守正创新,坚决践行双碳与可持续发展理念。更加包容、更加普惠、更有韧性的发展是全球\n",
|
||||
"市场剧烈震荡,MSCI全球股票指数、彭博全球债券指数一度自高点下跌超过22%、13%。面对风高浪急的国 可持续发展的关键。我们积极履行负责任投资者理念,制定《关于践行双碳目标和可持续投资行动的意见》,\n",
|
||||
"际环境和前所未有的巨大挑战,公司保持战略定力,发挥长期机构投资者优势,不断优化资产配置和投资策 积极开展气候变化、能源转型等主题投资。我们发布《运营碳中和行动计划》,明确时间表和路线图,全力实\n",
|
||||
"略,着力提升总组合韧性,加强重点领域风险防控,年度投资收益跑赢大市;截至2022年底,过去十年对外 现节能减排目标。我们探索以绿色资源引领乡村发展的新方法,在四个定点帮扶县持续推进巩固脱贫成果与乡\n",
|
||||
"投资年化净收益率按美元计算为6.43%,超出十年业绩目标26个基点;自成立以来累计年化国有资本增值率达 村振兴的有效衔接,助力民生保障与产业扶持,积极履行企业社会责任。\n",
|
||||
"到12.67%,圆满完成五年战略规划主要目标任务。 面向未来,我们坚信,发展与合作是破解全球性问题的“钥匙”。中投公司将一以贯之地践行全球发展倡\n",
|
||||
" 我们矢志不渝,积极打造世界一流主权财富基金。长期资本对于促进世界经济持续发展有着不 议,秉持互利共赢理念,以资本为纽带,促进国际产业交流合作,推动世界互联互通;充分维护投资东道国利\n",
|
||||
"可替代的作用。我们坚持国际化、市场化、专业化、负责任原则,快速恢复常态化对外交流交往,按照互利共 益,与东道国共创价值、共享价值;积极投身可持续投资,推动被投企业履行社会责任,助力世界经济实现更\n",
|
||||
"赢原则深化与国内外各类机构合作,持续为世界经济发展提供长期资本支持。我们积极创新对外投资方式,稳 高质量、更有韧性的发展。\n",
|
||||
"健运行多支新型双边基金,新设相关投资合作平台,深入推进中国市场价值创造,促进被投资公司拓展市场空\n",
|
||||
"间,助推国际投资与产业合作高质量发展。 经济全球化的潮流不可阻挡。我们呼吁各国携起手来,做多边主义的坚定维护者,打造更加开放有序的投\n",
|
||||
" 资环境,便利资本和资源要素在全球顺畅流动。我们尊重各方的利益关切,在开放中捕捉投资机遇,以务实合\n",
|
||||
" 我们直面挑战,着力加强自主投资能力建设。面对持续动荡的国际金融市场,我们锚定配置方 作应对共同挑战,并肩前进分享发展红利,推动世界经济平稳运行和持续增长。\n",
|
||||
"向,强化研究驱动,有序实施组合调整、策略优化,及时调整公开市场投资布局,质量并重推进非公开市场投\n",
|
||||
"资,完成另类资产投资占比50%的资产配置目标,对外投资总组合的韧性和质量不断提高。我们持续深化投资 “行之力则知愈进,知之深则行愈达。”过去的十五年,是中投人不惧挑战、接续奋斗的十五\n",
|
||||
"管理体制机制改革,统一非公开市场投资决策制度流程,配强投资决策专职委员并设立支持团队,投资管理科 年。 2023年是中投人落实新一轮战略规划的开局之年。上半年,在风高浪急的国际环境下,中投公司锚定战略目\n",
|
||||
"学化、专业化水平得到进一步提升。 标,统筹好发展和安全,取得了良好业绩,实现了良好开局。近期,公司部分董事更换,我们对离任董事在指导和支\n",
|
||||
" 持公司完善公司治理、深化投资管理体制机制改革、应对国际市场风险挑战等方面所作的贡献表示衷心感谢,对新\n",
|
||||
" 我们勇担使命,坚定走好中国特色金融发展之路。面对新征程新要求,我们坚持发挥“积极股 任董事表示热烈欢迎。站在新的历史起点上,中投公司将完整、准确、全面贯彻新发展理念,积极助力构建新发展格\n",
|
||||
"东”作用,督促控参股金融企业优化产品服务、加大资源倾斜力度,全力支持稳经济稳增长。我们积极创新完 局,牢牢把握高质量发展首要任务,继续秉承精益求精、追求卓越的专业精神,与国内外合作伙伴一起深化合作,共\n",
|
||||
"善“汇金模式”,推动优化国有金融资本布局,以市场化方式参与问题金融机构救助,助力金融市场稳定健康 聚力量、共迎挑战、共享成果,开启打造世界一流主权财富基金的新篇章,为助力全球经济发展作出新贡献!\n",
|
||||
"发展。我们主动适应新形势新要求,围绕国有金融资本管理体系建设等重大课题深入研究,压实派出董事自主\n",
|
||||
"履职责任,不断提升机构化履职能力。\n",
|
||||
" 我们坚守底线,持续夯实全面风险管理体系。面对风高浪急的国际环境,我们优化风险管理委员\n",
|
||||
"会设置,修订全面风险管理基本制度,增加风险类别的覆盖度,全面提升风险预见、应对、处置水平。在对外投\n",
|
||||
"资方面,我们严守法律合规底线,健全地缘政治、气候变化等非传统风险防控机制,突出抓好流动性管理,对外\n",
|
||||
"投资总组合风险保持在董事会规定的容忍度内。在国有金融资本受托管理方面,我们建立健全控参股金融企业风\n",
|
||||
"险监测体系,全面开展多维度风险画像,推动控参股金融企业风险减存量、控增量、防变量取得积极成效。\n",
|
||||
"7 中国投资有限责任公司2022年度报告 中国投资有限责任公司2022年度报告 8\n",
|
||||
"---\n",
|
||||
"02 中投公司的组建宗旨是实现国家外汇资金多元化投资,在可接受风\n",
|
||||
" 险范围内实现股东权益最大化,以服务于国家宏观经济发展和深化\n",
|
||||
" 公 司 介 绍 金融体制改革的需要。\n",
|
||||
" 9 中国投资有限责任公司2022年度报告 中国投资有限责任公司2022年度报告 10\n",
|
||||
"---\n",
|
||||
"公司概况中国投资有限责任公司(以下简称“中投公司”)依照《中华人民共和国公司法》(以下简称“《公司 公司治理 中投公司按照《公司法》及《中国投资有限责任公司章程》(以下简称“《中投公司章程》”)中的有关规\n",
|
||||
"法》”)于2007年9月成立,总部设在北京。中投公司的初始资本金为2000亿美元,由中国财政部发行1.55万 定,设立了董事会、监事会和执行委员会(以下简称“执委会”),三者之间权责明确、独立履职、有效制衡。\n",
|
||||
"亿元人民币特别国债募集。截至2022年底,公司总资产达1.24万亿美元。 2022年,中投公司健全完善董事会、监事会运行机制,强化下设专门委员会的职能发挥,持续提升公司治\n",
|
||||
" 中投公司的组建宗旨是实现国家外汇资金多元化投资,在可接受风险范围内实现股东权益最大化,以服务于 理效能。公司根据业务发展需要,优化调整投资管理架构,完善投资决策和投后管理制度机制,深化全面风险管\n",
|
||||
"国家宏观经济发展和深化金融体制改革的需要。 理体系建设,全面提升机构化投资能力。\n",
|
||||
" 中投公司开展境外投资业务与境内金融机构股权管理工作。其中,境外投资业务由下设子公司⸺中投国际\n",
|
||||
"有限责任公司(以下简称“中投国际”)和中投海外直接投资有限责任公司(以下简称“中投海外”)承担,业\n",
|
||||
"务范围包括公开市场股票和债券投资,对冲基金和多资产,泛行业私募股权和私募信用投资,房地产、基础设\n",
|
||||
"施、资源商品、农业等领域的基金投资与直接投资,以及多双边基金管理等。 组织架构图\n",
|
||||
" 中央汇金投资有限责任公司(以下简称“中央汇金”)作为中投公司的子公司,根据国务院授权,对国有重\n",
|
||||
"点金融企业进行股权投资,以出资额为限代表国家依法对国有重点金融企业行使出资人权利和履行出资人义务。 董事会 监事会\n",
|
||||
"中央汇金不开展商业性经营活动,不干预其控股的国有重点金融企业的日常经营活动。 提名与\n",
|
||||
" 薪酬委员会\n",
|
||||
" 中投国际和中投海外开展的境外业务与中央汇金开展的境内业务之间实行严格的“防火墙”政策和措施。\n",
|
||||
" 战略与\n",
|
||||
" 社会责任\n",
|
||||
" 委员会\n",
|
||||
" 风险管理 执行 国际咨询 监督 审计\n",
|
||||
" 委员会 委员会 委员会 委员会 委员会\n",
|
||||
" 境外投资 管理与支持 境内股权\n",
|
||||
" 业务部门 部门 管理部门\n",
|
||||
"11 中国投资有限责任公司2022年度报告 中国投资有限责任公司2022年度报告 12\n",
|
||||
"---\n",
|
||||
"董事会 沈如军\n",
|
||||
" 党委委员、执行董事、副总经理\n",
|
||||
" 中投公司董事会行使《公司法》和《中投公司章程》中规定的有限责任公司董事会的职权,主要包括:审核 1964年出生,管理学博士,高级会计师。历任中国工商银行计划财务部副总经理、\n",
|
||||
"和批准公司的发展战略、经营方针和投资计划;确定公司需向股东报告的重大事项;制定公司年度预决算方案; 北京市分行副行长、财务会计部总经理、山东省分行行长,交通银行执行董事、副\n",
|
||||
"任免公司高级管理人员;决定或授权批准设立内部管理机构等。 行长。现任本公司党委委员、执行董事、副总经理。\n",
|
||||
" 董事会由执行董事、非执行董事、独立董事以及职工董事构成。 丛亮\n",
|
||||
" 2022年,面对复杂严峻的国际经济形势,董事会加强对公司重大经营管理事项的指导和督促,及时听取投 非执行董事\n",
|
||||
"资形势、经营管理、风险防控等汇报,认真审议经营计划、财务预算和决算、业绩考核等重要议题,深入谋划中 1971年出生,经济学博士。历任国家发展和改革委员会国民经济综合司副司长、司\n",
|
||||
"投公司新一轮战略规划,明确发展目标、基本原则和重点举措,为公司下一阶段改革发展描绘新的蓝图。董事会 长,国家发展和改革委员会秘书长、新闻发言人,国家发展和改革委员会副主任,\n",
|
||||
"专门委员会根据授权,重点关注关系企业长远发展的重大事项,为董事会出谋划策,推动公司高质量发展迈上新 国家粮食和物资储备局局长。现任国家发展和改革委员会副主任,并兼任本公司非\n",
|
||||
"台阶。 执行董事。\n",
|
||||
" 许宏才\n",
|
||||
" 非执行董事\n",
|
||||
"董事会成员 1963年出生,经济学学士。历任财政部预算司副司长、司长,财政部部长助理,财\n",
|
||||
" 政部副部长。现任全国人大财政经济委员会副主任委员、全国人大常委会预算工作\n",
|
||||
" 彭 纯 \n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(documents[0].get_content()[1000:10000])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "640f0679-7f7e-4b0a-a46d-b099ae382fe2",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# download another copy with a different name to avoid hitting pdf cache\n",
|
||||
"!wget \"https://www.dropbox.com/scl/fi/g5ojyzk4m44hl7neut6vc/chinese_pdf.pdf?rlkey=45reu51kjvdvic6zucr8v9sh3&dl=1\" -O chinese_pdf2.pdf"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 31,
|
||||
"id": "bfcacf90-ca67-4bfd-b023-be0af2cb18c5",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Started parsing the file under job_id 99538f59-24f7-4f1e-ab27-4081933fa5ee\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from llama_parse import LlamaParse\n",
|
||||
"\n",
|
||||
"base_parser = LlamaParse(\n",
|
||||
" result_type=\"text\",\n",
|
||||
" language=\"en\"\n",
|
||||
")\n",
|
||||
"base_documents = parser.load_data(\"./chinese_pdf2.pdf\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "b264ed4e-647a-4f51-9f79-fdf82b76762a",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"print(base_documents[0].get_content()[1000:10000])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d9f02762-bb97-4e0e-8268-ccc00612a974",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "llama_parse",
|
||||
"language": "python",
|
||||
"name": "llama_parse"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.8"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
+92
-3
@@ -4,6 +4,7 @@ import httpx
|
||||
import mimetypes
|
||||
import time
|
||||
from enum import Enum
|
||||
from pathlib import Path
|
||||
from typing import List, Optional, Union
|
||||
|
||||
from llama_index.core.async_utils import run_jobs
|
||||
@@ -21,6 +22,91 @@ class ResultType(str, Enum):
|
||||
TXT = "text"
|
||||
MD = "markdown"
|
||||
|
||||
class Language(str, Enum):
|
||||
BAZA = "abq"
|
||||
ADYGHE = "ady"
|
||||
AFRIKAANS = "af"
|
||||
ANGIKA = "ang"
|
||||
ARABIC = "ar"
|
||||
ASSAMESE = "as"
|
||||
AVAR = "ava"
|
||||
AZERBAIJANI = "az"
|
||||
BELARUSIAN = "be"
|
||||
BULGARIAN = "bg"
|
||||
BIHARI = "bh"
|
||||
BHOJPURI = "bho"
|
||||
BENGALI = "bn"
|
||||
BOSNIAN = "bs"
|
||||
SIMPLIFIED_CHINESE = "ch_sim"
|
||||
TRADITIONAL_CHINESE = "ch_tra"
|
||||
CHECHEN = "che"
|
||||
CZECH = "cs"
|
||||
WELSH = "cy"
|
||||
DANISH = "da"
|
||||
DARGWA = "dar"
|
||||
GERMAN = "de"
|
||||
ENGLISH = "en"
|
||||
SPANISH = "es"
|
||||
ESTONIAN = "et"
|
||||
PERSIAN_FARSI = "fa"
|
||||
FRENCH = "fr"
|
||||
IRISH = "ga"
|
||||
GOAN_KONKANI = "gom"
|
||||
HINDI = "hi"
|
||||
CROATIAN = "hr"
|
||||
HUNGARIAN = "hu"
|
||||
INDONESIAN = "id"
|
||||
INGUSH = "inh"
|
||||
ICELANDIC = "is"
|
||||
ITALIAN = "it"
|
||||
JAPANESE = "ja"
|
||||
KABARDIAN = "kbd"
|
||||
KANNADA = "kn"
|
||||
KOREAN = "ko"
|
||||
KURDISH = "ku"
|
||||
LATIN = "la"
|
||||
LAK = "lbe"
|
||||
LEZGHIAN = "lez"
|
||||
LITHUANIAN = "lt"
|
||||
LATVIAN = "lv"
|
||||
MAGAHI = "mah"
|
||||
MAITHILI = "mai"
|
||||
MAORI = "mi"
|
||||
MONGOLIAN = "mn"
|
||||
MARATHI = "mr"
|
||||
MALAY = "ms"
|
||||
MALTESE = "mt"
|
||||
NEPALI = "ne"
|
||||
NEWARI = "new"
|
||||
DUTCH = "nl"
|
||||
NORWEGIAN = "no"
|
||||
OCCITAN = "oc"
|
||||
PALI = "pi"
|
||||
POLISH = "pl"
|
||||
PORTUGUESE = "pt"
|
||||
ROMANIAN = "ro"
|
||||
RUSSIAN = "ru"
|
||||
SERBIAN_CYRILLIC = "rs_cyrillic"
|
||||
SERBIAN_LATIN = "rs_latin"
|
||||
NAGPURI = "sck"
|
||||
SLOVAK = "sk"
|
||||
SLOVENIAN = "sl"
|
||||
ALBANIAN = "sq"
|
||||
SWEDISH = "sv"
|
||||
SWAHILI = "sw"
|
||||
TAMIL = "ta"
|
||||
TABASSARAN = "tab"
|
||||
TELUGU = "te"
|
||||
THAI = "th"
|
||||
TAJIK = "tjk"
|
||||
TAGALOG = "tl"
|
||||
TURKISH = "tr"
|
||||
UYGHUR = "ug"
|
||||
UKRANIAN = "uk"
|
||||
URDU = "ur"
|
||||
UZBEK = "uz"
|
||||
VIETNAMESE = "vi"
|
||||
|
||||
|
||||
class LlamaParse(BasePydanticReader):
|
||||
"""A smart-parser for files."""
|
||||
@@ -50,6 +136,9 @@ class LlamaParse(BasePydanticReader):
|
||||
verbose: bool = Field(
|
||||
default=True, description="Whether to print the progress of the parsing."
|
||||
)
|
||||
language: Optional[str] = Field(
|
||||
default=Language.ENGLISH, description="The language of the text to parse."
|
||||
)
|
||||
|
||||
@validator("api_key", pre=True, always=True)
|
||||
def validate_api_key(cls, v: str) -> str:
|
||||
@@ -89,7 +178,7 @@ class LlamaParse(BasePydanticReader):
|
||||
# send the request, start job
|
||||
url = f"{self.base_url}/api/parsing/upload"
|
||||
async with httpx.AsyncClient(timeout=self.max_timeout) as client:
|
||||
response = await client.post(url, files=files, headers=headers)
|
||||
response = await client.post(url, files=files, headers=headers, data={"language": self.language})
|
||||
if not response.is_success:
|
||||
raise Exception(f"Failed to parse the PDF file: {response.text}")
|
||||
|
||||
@@ -135,7 +224,7 @@ class LlamaParse(BasePydanticReader):
|
||||
|
||||
async def aload_data(self, file_path: Union[List[str], str], extra_info: Optional[dict] = None) -> List[Document]:
|
||||
"""Load data from the input path."""
|
||||
if isinstance(file_path, str):
|
||||
if isinstance(file_path, (str, Path)):
|
||||
return await self._aload_data(file_path, extra_info=extra_info)
|
||||
elif isinstance(file_path, list):
|
||||
jobs = [self._aload_data(f, extra_info=extra_info) for f in file_path]
|
||||
@@ -160,4 +249,4 @@ class LlamaParse(BasePydanticReader):
|
||||
if nest_asyncio_err in str(e):
|
||||
raise RuntimeError(nest_asyncio_msg)
|
||||
else:
|
||||
raise e
|
||||
raise e
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "llama-parse"
|
||||
version = "0.3.3"
|
||||
version = "0.3.4"
|
||||
description = "Parse files into RAG-Optimized formats."
|
||||
authors = ["Logan Markewich <logan@llamaindex.ai>"]
|
||||
license = "MIT"
|
||||
|
||||
Reference in New Issue
Block a user