### Install LlamaCloud Services Package Source: https://docs.cloud.llamaindex.ai/llamaparse/getting_started Installs the necessary Python package for interacting with LlamaCloud services, including LlamaParse. ```bash pip install llama-cloud-services ``` -------------------------------- ### Install LlamaIndex Dependencies Source: https://docs.cloud.llamaindex.ai/llamacloud/how_to/getting-started-with-index Installs the required LlamaIndex packages for Llama Cloud integration, Anthropic LLM, and core functionalities. This is the first step to set up the environment for the project. ```bash !pip install llama-index-indices-managed-llama-cloud llama-index-llms-anthropic llama-index-core ``` -------------------------------- ### Parse Documents in Python Source: https://docs.cloud.llamaindex.ai/llamaparse/getting_started Provides examples of using the LlamaParse Python SDK to parse documents. It covers initializing the parser, parsing single and multiple files synchronously and asynchronously, and accessing different types of parsed results. ```python from llama_cloud_services import LlamaParse parser = LlamaParse( api_key="llx-...", ``` ```python num_workers=4,# if multiple files passed, split in `num_workers` API calls verbose=True, language="en",# optionally define a language, default=en ) # sync result = parser.parse("./my_file.pdf") # sync batch results = parser.parse(["./my_file1.pdf","./my_file2.pdf"]) # async result =await parser.aparse("./my_file.pdf") # async batch results =await parser.aparse(["./my_file1.pdf","./my_file2.pdf"]) ``` ```python # get the llama-index markdown documents markdown_documents = result.get_markdown_documents(split_by_page=True) # get the llama-index text documents text_documents = result.get_text_documents(split_by_page=False) # get the image documents image_documents = result.get_image_documents( include_screenshot_images=True, include_object_images=False, # Optional: download the images to a directory # (default is to return the image bytes in ImageDocument objects) image_download_dir="./images", ) # access the raw job result # Items will vary based on the parser configuration for page in result.pages: print(page.text) print(page.md) print(page.images) print(page.layout) print(page.structuredData) ``` -------------------------------- ### Parse Documents via Command Line Source: https://docs.cloud.llamaindex.ai/llamaparse/getting_started Demonstrates how to parse PDF files using the LlamaParse command-line interface. It shows examples for outputting results as text, Markdown, or raw JSON, and setting the API key via an environment variable. ```bash export LLAMA_CLOUD_API_KEY='llx-...' # output as text llama-parse my_file.pdf --result-type text --output-file output.txt # output as markdown llama-parse my_file.pdf --result-type markdown --output-file output.md # output as raw json llama-parse my_file.pdf --output-raw-json --output-file output.json ``` -------------------------------- ### Install LlamaIndex.TS and Dependencies Source: https://docs.cloud.llamaindex.ai/llamaparse/getting_started Installs necessary packages for LlamaIndex.TS, including TypeScript and dotenv for environment variable management. ```Bash npm init npm install -D typescript @types/node npm install llama-cloud-services dotenv ``` -------------------------------- ### Python SDK for LlamaExtract Source: https://docs.cloud.llamaindex.ai/llamaextract/getting_started The recommended way to use LlamaExtract for running extraction jobs at scale is through its Python SDK. This snippet guides users to the Python quick start for integration. ```Python # Example usage of LlamaExtract Python SDK # Refer to the Python quick start for detailed instructions. # from llama_extract import LlamaExtract # # extract_client = LlamaExtract(api_key="YOUR_API_KEY") # result = extract_client.extract( # file_path="./document.pdf", # extraction_schema={"name": "string", "age": "integer"} # ) # print(result) ``` -------------------------------- ### Classify Python SDK Guide Source: https://docs.cloud.llamaindex.ai/llamaclassify/getting_started This section directs users to the Python SDK guide for running their first classification job. It implies the existence of a Python SDK for interacting with the LlamaCloud Classify API. ```Python # Example usage of LlamaCloud Classify SDK (conceptual) from llamacloud import LlamaCloud # Initialize the client with your API key client = LlamaCloud(api_key="YOUR_API_KEY") # Define your classification rules rules = [ {"type": "invoice", "description": "Documents that represent an invoice with line items and total amount."}, {"type": "receipt", "description": "Documents that are receipts, typically showing a list of purchased items and a total."} ] # Upload files and create a classify job file_ids = ["file_id_1", "file_id_2"] job = client.classify.create_job(file_ids=file_ids, rules=rules) # Fetch the results results = client.classify.get_results(job_id=job.id) # Process the results for result in results: print(f"File: {result.file_id}, Type: {result.type}, Confidence: {result.confidence}, Reasoning: {result.reasoning}") ``` -------------------------------- ### Get Started with LlamaCloud Components Source: https://docs.cloud.llamaindex.ai/index LlamaCloud can be accessed via its Web UI, Python SDK, and REST API. Users can sign up for an account or explore the documentation for each component to get started. ```General Get started with Web UI, Python SDK, and REST API. Sign up for an account to get started or explore the documentation for each component. ``` -------------------------------- ### Instantiate FunctionAgent with Tools Source: https://docs.cloud.llamaindex.ai/llamacloud/how_to/getting-started-with-index Initializes a FunctionAgent with a list of tools (the `add` function and the `jpmorgan` QueryEngineTool) and an Anthropic LLM. A system prompt is provided to guide the agent's behavior. ```python from llama_index.core.agent.workflow import FunctionAgent workflow = FunctionAgent( tools=[add,jpmorgan], llm=llm, system_prompt="You are an expert in JP Morgan Chase banking fees and procedures" ) ``` -------------------------------- ### LlamaCloud API and SDK Clients Guide Source: https://docs.cloud.llamaindex.ai/llamacloud/guides A comprehensive guide to using the LlamaCloud REST API and SDK clients for Python and TypeScript. Covers setup, file uploads, data source/sink configuration, and index management. ```python # Example: Uploading a file using LlamaCloud Python SDK from llama_cloud import LlamaCloud client = LlamaCloud(api_key="YOUR_API_KEY") # Assuming you have an index already created or created one index_id = "your_index_id" file_path = "./path/to/your/document.pdf" with open(file_path, "rb") as f: response = client.upload_file(index_id=index_id, file=f) print(f"File uploaded successfully: {response}") # Example: Configuring a data source (conceptual) # client.create_data_source(index_id=index_id, source_type="s3", config={...}) ``` -------------------------------- ### LlamaCloud API and SDK Clients Guide Source: https://docs.cloud.llamaindex.ai/llamacloud/guides A comprehensive guide to using the LlamaCloud REST API and SDK clients for Python and TypeScript. Covers setup, file uploads, data source/sink configuration, and index management. ```typescript // Example: Uploading a file using LlamaCloud TypeScript SDK import { LlamaCloud } from "@llamacloud/llama-cloud"; import * as fs from 'fs'; const client = new LlamaCloud("YOUR_API_KEY"); // Assuming you have an index already created or created one const indexId = "your_index_id"; const filePath = "./path/to/your/document.pdf"; const fileContent = fs.readFileSync(filePath); client.uploadFile({ indexId: indexId, file: fileContent }) .then(response => { console.log("File uploaded successfully:", response); }) .catch(error => { console.error("Error uploading file:", error); }); // Example: Configuring a data source (conceptual) // client.createDataSource({ indexId: indexId, sourceType: "s3", config: {...} }) // .catch(error => console.error("Error creating data source:", error)); ``` -------------------------------- ### Install LlamaIndex Python Package Source: https://docs.cloud.llamaindex.ai/llamacloud/getting_started/quick_start Installs the latest version of the LlamaIndex Python framework, which is necessary for integrating LlamaCloud's retrieval endpoint into your RAG or agent application. ```python pip install llama-index ``` -------------------------------- ### LlamaParse REST API: Retrieve Markdown Results Source: https://docs.cloud.llamaindex.ai/llamaparse/getting_started Uses curl to send a GET request to the LlamaParse API to retrieve the parsed results of a job in Markdown format. Requires the job ID and the Authorization header. ```Shell curl -X 'GET' \ 'https://api.cloud.llamaindex.ai/api/v1/parsing/job//result/markdown' \ -H 'accept: application/json' \ -H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" ``` -------------------------------- ### Execute TypeScript File Source: https://docs.cloud.llamaindex.ai/llamaparse/getting_started Command to run a TypeScript file named 'parse.ts' using tsx, which allows direct execution of TypeScript files. ```Shell npx tsx parse.ts ``` -------------------------------- ### Get Started with Agentic Retrieval Source: https://docs.cloud.llamaindex.ai/cookbooks This guide introduces the agentic retrieval pipeline, explaining how to implement and utilize it for more sophisticated information retrieval tasks. It focuses on the core concepts of agentic workflows. ```python from llama_index.core.agent import ReActAgent from llama_index.core import Settings, VectorStoreIndex, SimpleDirectoryReader from llama_index.llms.openai import OpenAI # Configure LLM Settings.llm = OpenAI(model="gpt-3.5-turbo") # Load documents and build index (example) loader = SimpleDirectoryReader("data") documents = loader.load_data() index = VectorStoreIndex.from_documents(documents) # Create an agent agent = ReActAgent.from_tools(index.as_query_engine().as_tool()) # Query the agent response = agent.chat("What are the main features of LlamaCloud?") print(response) ``` -------------------------------- ### Get File Store Info C# Example Source: https://docs.cloud.llamaindex.ai/API/get-file-store-info-api-v-1-admin-filestores-info-get An example in C# demonstrating how to use HttpClient to fetch file store information from the LlamaIndex Cloud API. It includes setting the URL, headers, and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cloud.llamaindex.ai/api/v1/admin/filestores/info"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Multimodal RAG Quickstart with LlamaCloud Source: https://docs.cloud.llamaindex.ai/cookbooks A quickstart guide for implementing Multimodal Retrieval-Augmented Generation (RAG) using LlamaCloud. This enables processing and querying of data that includes both text and images. ```python from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, StorageContext, load_index_from_storage from llama_index.core.response.notebook_utils import display_response from llama_index.core.tools import QueryEngineTool from llama_index.core.agent import AgentRunner from llama_index.llms.openai import OpenAI from llama_index.core import Settings # Configure LLM Settings.llm = OpenAI(model="gpt-4-vision-preview") # Load documents (including images) documents = SimpleDirectoryReader("./multimodal_data").load_data() # Build index index = VectorStoreIndex.from_documents(documents) # Create query engine query_engine = index.as_query_engine() # Query with multimodal input response = query_engine.query("Summarize the content of the image and the text.", image="./multimodal_data/image.jpg") display_response(response) ``` -------------------------------- ### Setup Environment Variables and Install Dependencies Source: https://docs.cloud.llamaindex.ai/llamaclassify/getting_started/python This snippet shows how to set your LlamaCloud API key in a .env file and install the necessary Python packages using pip or uv. ```shell LLAMA_CLOUD_API_KEY=llx-xxxxxx ``` ```shell pip install llama-cloud-services python-dotenv ``` ```shell uv add llama-cloud-services python-dotenv ``` -------------------------------- ### TypeScript Document Parsing with LlamaParse Source: https://docs.cloud.llamaindex.ai/llamaparse/getting_started Demonstrates how to use the LlamaParseReader from llama-cloud-services in TypeScript to parse a PDF document and log the results. It requires setting up the reader with a result type and providing a file path. ```TypeScript import{ LlamaParseReader, }from"llama-cloud-services"; import'dotenv/config' asyncfunctionmain(){ const path ="./canada.pdf"; const reader =newLlamaParseReader({ resultType:"markdown"}); const documents =await reader.loadData(path); console.log(documents) } main().catch(console.error); ``` -------------------------------- ### Install Python LlamaCloud Client Source: https://docs.cloud.llamaindex.ai/llamacloud/guides/api_sdk Installs the LlamaCloud client package for Python using pip. This is the first step to integrating LlamaCloud into your Python applications. ```bash pip install llama-cloud ``` -------------------------------- ### LlamaParse REST API: Upload File for Parsing Source: https://docs.cloud.llamaindex.ai/llamaparse/getting_started Uses curl to send a POST request to the LlamaParse API to upload a PDF file for parsing. It includes necessary headers for content type and authorization, and specifies the file to be uploaded. ```Shell curl -X 'POST' \ 'https://api.cloud.llamaindex.ai/api/v1/parsing/upload' \ -H 'accept: application/json' \ -H 'Content-Type: multipart/form-data' \ -H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \ -F 'file=@/path/to/your/file.pdf;type=application/pdf' ``` -------------------------------- ### Create Query Engine and Query Source: https://docs.cloud.llamaindex.ai/llamacloud/how_to/getting-started-with-index Creates a query engine from the LlamaCloudIndex, associating it with the instantiated Anthropic LLM. It then uses this engine to query the index and prints the response. ```python engine = index.as_query_engine(llm=llm) response = engine.query(query) print(response) ``` -------------------------------- ### Install TypeScript LlamaCloud Client Source: https://docs.cloud.llamaindex.ai/llamacloud/guides/api_sdk Installs the LlamaCloud client services package for TypeScript using npm. This package enables interaction with the LlamaCloud API from Node.js environments. ```bash npm install llama-cloud-services ``` -------------------------------- ### Stream Agent Workflow Output with LlamaIndex Source: https://docs.cloud.llamaindex.ai/llamacloud/how_to/getting-started-with-index This snippet demonstrates how to run an agent workflow with LlamaIndex and stream the output events. It shows how to process `AgentOutput` events, extract tool calls, and print the tool name and arguments. This is useful for observing the agent's execution flow in real-time. ```Python from llama_index.core.agent.workflow import ( AgentOutput, ToolCallResult, ) handler = workflow.run("""You have a Chase Total Checking account with $25 in your balance on Monday morning. Throughout Monday, you make a $15 grocery purchase (debit card), write a $20 check that gets cashed, and have a $25 automatic utility bill payment (ACH) that processes. On Tuesday, you request a rush replacement for your lost debit card and place a stop payment on another check over the phone with a banker. What is the total amount in fees you would be charged, and when would each fee be assessed?""") # handle streaming output async for event in handler.stream_events(): if isinstance(event, AgentOutput): for tool_call in event.tool_calls: print("-" * 20) print("Tool called: " + tool_call.tool_name) print("Tool arguments:") ``` -------------------------------- ### Print Tool Arguments and Handle Tool Results Source: https://docs.cloud.llamaindex.ai/llamacloud/how_to/getting-started-with-index This snippet demonstrates how to iterate through the key-value pairs in `tool_call.tool_kwargs` to print them, and how to handle `ToolCallResult` events by printing the tool's output. It's useful for debugging and understanding the flow of tool execution. ```Python for key, value in tool_call.tool_kwargs.items(): print(f" {key}: {value}") print("-"*10) elif isinstance(event, ToolCallResult): print("Tool output: ", event.tool_output) ``` -------------------------------- ### Create LlamaCloudIndex Source: https://docs.cloud.llamaindex.ai/llamacloud/how_to/getting-started-with-index Initializes a LlamaCloudIndex with specified index name, project name, organization ID, and the Llama Cloud API key. This index will be used to store and retrieve data from Llama Cloud. ```python from llama_index.indices.managed.llama_cloud import LlamaCloudIndex index = LlamaCloudIndex( name="demo-video-index-1", project_name="Demo Project", organization_id="your-organization-id", api_key=LLAMACLOUD_API_KEY ) ``` -------------------------------- ### List Files API C# Example Source: https://docs.cloud.llamaindex.ai/API/list-files-api-v-1-files-get Provides a C# code example using HttpClient to make a GET request to the LlamaIndex Cloud API for listing files. It includes setting headers for authorization and accepting JSON responses. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cloud.llamaindex.ai/api/v1/files"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Create QueryEngineTool for JPMorgan Chase Source: https://docs.cloud.llamaindex.ai/llamacloud/how_to/getting-started-with-index Creates a QueryEngineTool named 'JPMorganChaseTool' from an existing query engine. This tool is designed to query documents related to JP Morgan Chase bank rates, fees, and procedures. ```python from llama_index.core.tools import QueryEngineTool jpmorgan = QueryEngineTool.from_defaults( query_engine=engine, name="JPMorganChaseTool", description="Query documents about JP Morgan Chase bank rates, fees and procedures", ) ``` -------------------------------- ### Get Current Project C# Example Source: https://docs.cloud.llamaindex.ai/API/get-current-project-api-v-1-projects-current-get An example using C# HttpClient to fetch the current project details. It includes setting the request method, URL, and necessary headers like Accept and Authorization. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cloud.llamaindex.ai/api/v1/projects/current"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Define Simple Add Function Tool Source: https://docs.cloud.llamaindex.ai/llamacloud/how_to/getting-started-with-index Defines a basic Python function `add` that takes two float arguments and returns their sum. This function serves as a simple tool for the agent. ```python def add(a:float, b:float)->float: """Add two numbers and returns the sum""" return a + b ``` -------------------------------- ### LlamaCloud TypeScript Integration Source: https://docs.cloud.llamaindex.ai/llamacloud/getting_started LlamaCloud offers seamless integration with the TypeScript framework, enabling developers to build RAG applications using LlamaCloud's data ingestion capabilities within their TypeScript projects. ```typescript import { LlamaCloud } from "llama-cloud-ts"; // Initialize LlamaCloud client const client = new LlamaCloud("YOUR_API_KEY"); // Example: Indexing data const indexName = "my-rag-index"; const filePath = "./my_document.pdf"; async function indexDocument() { try { await client.indexFile(indexName, filePath); console.log(`Successfully indexed ${filePath} into ${indexName}`); } catch (error) { console.error("Error indexing document:", error); } } indexDocument(); ``` -------------------------------- ### LlamaCloud Python Integration Source: https://docs.cloud.llamaindex.ai/llamacloud/getting_started LlamaCloud seamlessly integrates with the popular Python framework for building RAG applications. This allows developers to leverage LlamaCloud's data ingestion pipeline within their Python projects. ```python from llama_cloud import LlamaCloud # Initialize LlamaCloud client client = LlamaCloud(api_key="YOUR_API_KEY") # Example: Indexing data index_name = "my-rag-index" file_path = "./my_document.pdf" client.index_file(index_name=index_name, file_path=file_path) print(f"Successfully indexed {file_path} into {index_name}") ``` -------------------------------- ### Retrieve Nodes from LlamaCloudIndex Source: https://docs.cloud.llamaindex.ai/llamacloud/how_to/getting-started-with-index Performs a basic retrieval from the LlamaCloudIndex using a query. It then prints the number of nodes found and details for each node, including ID, score, file name, and page label. ```python query ="What is the monthly service fee for Chase Total Checking" nodes = index.as_retriever().retrieve(query) print("Found "+str(len(nodes))+" nodes") for node in nodes: print(f"Node ID: {node.node.id_}") print(f"Score: {node.score}") print(f"File Name: {node.node.metadata.get('file_name')}") print(f"Page Label: {node.node.metadata.get('page_label')}") print("-"*20) ``` -------------------------------- ### Handle Asynchronous Handler Source: https://docs.cloud.llamaindex.ai/llamacloud/how_to/getting-started-with-index This snippet shows how to convert an asynchronous handler object to its string representation. This is typically used for logging or debugging purposes to get a readable output of the handler's state. ```Python print(str(await handler)) ``` -------------------------------- ### Install LlamaCloud Services Source: https://docs.cloud.llamaindex.ai/llamaextract/getting_started/python Installs the necessary Python libraries for LlamaCloud services and loads environment variables. ```Shell pip install llama-cloud-services python-dotenv ``` -------------------------------- ### Instantiate Anthropic LLM Source: https://docs.cloud.llamaindex.ai/llamacloud/how_to/getting-started-with-index Initializes an Anthropic language model instance using the provided API key and a specific model name ('claude-sonnet-4-20250514'). This LLM will be used by the query engine. ```python from llama_index.llms.anthropic import Anthropic llm = Anthropic( api_key=ANTHROPIC_API_KEY, model="claude-sonnet-4-20250514", ) ``` -------------------------------- ### API Request Example in C# Source: https://docs.cloud.llamaindex.ai/API/list-data-sources-api-v-1-data-sources-get This C# code snippet demonstrates how to make a GET request to the Cloud LlamaIndex AI API to retrieve data sources. It includes setting up the HttpClient, HttpRequestMessage, adding necessary headers like Accept and Authorization, sending the request, and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cloud.llamaindex.ai/api/v1/data-sources"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Initialize Llama Cloud API Key and Anthropic API Key Source: https://docs.cloud.llamaindex.ai/llamacloud/how_to/getting-started-with-index Retrieves the necessary API keys from Google Colab's user data storage. LLAMACLOUD_API_KEY is used to access the Llama Cloud index, and ANTHROPIC_API_KEY is used for the Anthropic language model. ```python from google.colab import userdata LLAMACLOUD_API_KEY = userdata.get('llamacloud-demo-video') ANTHROPIC_API_KEY = userdata.get('anthropic-key') ``` -------------------------------- ### C# HttpClient Example for LlamaIndex API Source: https://docs.cloud.llamaindex.ai/API/list-parse-configurations-api-v-1-beta-parse-configurations-get Demonstrates how to use HttpClient in C# to send a GET request to the LlamaIndex Cloud API to retrieve parse configurations. It includes setting the authorization header with a Bearer token and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cloud.llamaindex.ai/api/v1/beta/parse-configurations"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### C# HttpClient Example Source: https://docs.cloud.llamaindex.ai/API/search-agent-data-api-v-1-beta-agent-data-search-post Demonstrates how to make a GET request to the Cloud LlamaIndex AI API using C#'s HttpClient. It includes setting headers for authorization and content type, and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cloud.llamaindex.ai"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); request.Headers.Add("Authorization", "Bearer "); var content = new StringContent(string.Empty); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### REST API for LlamaExtract Source: https://docs.cloud.llamaindex.ai/llamaextract/getting_started For users working with languages other than Python, LlamaExtract offers a REST API. This allows integration with various programming languages and platforms. ```bash # Example of using LlamaExtract REST API with curl # Replace YOUR_API_KEY and adjust the payload as needed. # # curl -X POST https://api.llamaextract.ai/v1/extract \ # -H "Authorization: Bearer YOUR_API_KEY" \ # -H "Content-Type: application/json" \ # -d '{ # "file_url": "https://example.com/document.pdf", # "extraction_schema": {"name": "string", "age": "integer"} # }' ``` -------------------------------- ### LlamaParse REST API: Check Parsing Job Status Source: https://docs.cloud.llamaindex.ai/llamaparse/getting_started Uses curl to send a GET request to the LlamaParse API to check the status of a parsing job using its unique job ID. Requires the Authorization header. ```Shell curl -X 'GET' \ 'https://api.cloud.llamaindex.ai/api/v1/parsing/job/' \ -H 'accept: application/json' \ -H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" ``` -------------------------------- ### Quick Start: Extract Data with Python SDK Source: https://docs.cloud.llamaindex.ai/llamaextract/getting_started/python Demonstrates how to initialize the LlamaExtract client, define a Pydantic schema for data extraction, create an extraction agent, and extract data from a PDF file. ```Python from llama_cloud_services import LlamaExtract from pydantic import BaseModel, Field from dotenv import load_dotenv load_dotenv() # Initialize client extractor = LlamaExtract() # Define schema using Pydantic class Resume(BaseModel): name:str= Field(description="Full name of candidate") email:str= Field(description="Email address") skills:list[str]= Field(description="Technical skills and technologies") # Create extraction agent agent = extractor.create_agent(name="resume-parser", data_schema=Resume) # Extract data from document result = agent.extract("resume.pdf") print(result.data) ``` -------------------------------- ### Install LlamaCloud Services SDK Source: https://docs.cloud.llamaindex.ai/llamaextract/features/options Installs the necessary Python SDK for interacting with LlamaCloud services, specifically for extraction functionalities. ```Shell pip install llama-cloud-services ``` -------------------------------- ### JSON Data Source Configuration Example Source: https://docs.cloud.llamaindex.ai/API/get-data-source-api-v-1-data-sources-data-source-id-get An example JSON object representing a data source configuration, including details like ID, creation/update timestamps, name, source type, custom metadata, component, version metadata, and project ID. ```json { "id":"3fa85f64-5717-4562-b3fc-2c963f66afa6", "created_at":"2024-07-29T15:51:28.071Z", "updated_at":"2024-07-29T15:51:28.071Z", "name":"string", "source_type":"S3", "custom_metadata":{}, "component":{}, "version_metadata":{ "reader_version":"1.0" }, "project_id":"3fa85f64-5717-4562-b3fc-2c963f66afa6" } ``` -------------------------------- ### Get Llamaextract Features in C# Source: https://docs.cloud.llamaindex.ai/API/get-llamaextract-features-api-v-1-admin-llamaextract-features-get Example of how to call the Get Llamaextract Features API using HttpClient in C#. It demonstrates setting headers for authorization and content type. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cloud.llamaindex.ai/api/v1/admin/llamaextract/features"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Resume Matching with LlamaCloud Source: https://docs.cloud.llamaindex.ai/cookbooks An efficient method for matching resumes to job descriptions using LlamaCloud. This cookbook outlines the steps to set up and execute resume matching workflows. ```python from llama_index.core import VectorStoreIndex, SimpleDirectoryReader from llama_index.core.schema import TextNode # Load job description and resumes job_description_doc = SimpleDirectoryReader("job_description").load_data()[0] resume_docs = SimpleDirectoryReader("resumes").load_data() # Combine job description with resumes for indexing combined_docs = [job_description_doc] + resume_docs # Build index index = VectorStoreIndex.from_documents(combined_docs) # Create query engine query_engine = index.as_query_engine() # Query for matching resumes response = query_engine.query(f"Find resumes that match the following job description: {job_description_doc.text}") print(response) ``` -------------------------------- ### Install Llama Cloud Services Source: https://docs.cloud.llamaindex.ai/llamaextract/examples/extract_data_with_citations Installs the necessary Llama Cloud Services Python package using pip. ```bash !pip install llama-cloud-services ``` -------------------------------- ### HTTP GET Request for Data Sink Source: https://docs.cloud.llamaindex.ai/API/get-data-sink-api-v-1-data-sinks-data-sink-id-get C# code example demonstrating how to make an HTTP GET request to retrieve a data sink by its ID. It includes setting headers for authorization and content acceptance. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cloud.llamaindex.ai/api/v1/data-sinks/:data_sink_id"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### C# HttpClient Example for Cloud LlamaIndex API Source: https://docs.cloud.llamaindex.ai/API/list-quota-configurations-api-v-1-beta-quota-management-get Demonstrates how to use C# HttpClient to make a GET request to the Cloud LlamaIndex API's quota-management endpoint. It includes setting the authorization header with a Bearer token and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cloud.llamaindex.ai/api/v1/beta/quota-management"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Load Documents in Python Source: https://docs.cloud.llamaindex.ai/llamacloud/guides/framework_integration Loads documents from a local directory using the SimpleDirectoryReader in Python. This is the first step before creating an index. ```python from llama_index.core import SimpleDirectoryReader documents = SimpleDirectoryReader("data").load_data() ``` -------------------------------- ### Schema Validation Error Example Source: https://docs.cloud.llamaindex.ai/API/get-data-sink-api-v-1-data-sinks-data-sink-id-get Example JSON structure for a schema validation error, detailing the location, message, and type of error. ```json { "detail": [ { "loc": [ "string", 0 ], "msg": "string", "type": "string" } ] } ``` -------------------------------- ### C# HTTP GET Request for Data Source Source: https://docs.cloud.llamaindex.ai/API/get-data-source-api-v-1-data-sources-data-source-id-get A C# example using HttpClient to make a GET request to retrieve a data source from the Cloud LlamaIndex API. It includes setting headers for accept and authorization. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cloud.llamaindex.ai/api/v1/data-sources/:data_source_id"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### JSON Validation Error Example Source: https://docs.cloud.llamaindex.ai/API/get-data-source-api-v-1-data-sources-data-source-id-get An example JSON structure for a validation error response, detailing the location of the error, the error message, and the error type. ```json { "detail":[ { "loc":[ "string", 0 ], "msg":"string", "type":"string" } ] } ``` -------------------------------- ### Create Data Sink JSON Example Source: https://docs.cloud.llamaindex.ai/API/get-data-sink-api-v-1-data-sinks-data-sink-id-get Example JSON payload for creating a data sink. It includes fields like name, sink type, and project ID. ```json { "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "created_at": "2024-07-29T15:51:28.071Z", "updated_at": "2024-07-29T15:51:28.071Z", "name": "string", "sink_type": "PINECONE", "component": {}, "project_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6" } ``` -------------------------------- ### C# Example: Get Pipeline File Status Counts Source: https://docs.cloud.llamaindex.ai/API/get-pipeline-file-status-counts-api-v-1-pipelines-pipeline-id-files-status-counts-get This C# code demonstrates how to use HttpClient to call the LlamaIndex API for getting pipeline file status counts. It sets the necessary headers, including authorization, and handles the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cloud.llamaindex.ai/api/v1/pipelines/:pipeline_id/files/status-counts"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Configure Slack Data Source Source: https://docs.cloud.llamaindex.ai/API/create-data-source-api-v-1-data-sources-post Sets up the Slack data source with parameters like channel patterns and access control. ```Python class_name: CloudSlackDataSource supports_access_control: false channel_patterns: "#general" latest_date: "2023-01-01" earliest_date: "2022-01-01" integration_token: "your_slack_token" ``` -------------------------------- ### LlamaIndex Auto Mode Configuration Example Source: https://docs.cloud.llamaindex.ai/llamaparse/features/automodeTriggers An example of an auto_mode_configuration_json demonstrating the use of various LlamaIndex triggers, including numeric content, layout elements, and text presence, to guide parsing behavior. ```JSON [ { "parsing_conf":{ "user_prompt":"Extract all tabular data into a structured format" }, "table_in_page":true }, { "parsing_conf":{ "user_prompt":"Summarize the executive summary section" }, "text_in_page":"Executive Summary" }, { "parsing_conf":{ "user_prompt":"Extract financial figures from this numbers-heavy page" }, "page_contains_at_least_n_percent_numbers":"25" } ] ``` -------------------------------- ### Install LlamaCloud Services Source: https://docs.cloud.llamaindex.ai/llamaextract/features/schema_design Installs the necessary Python package for LlamaCloud services, which includes LlamaExtract. ```bash pip install llama-cloud-services ``` -------------------------------- ### List Projects C# HttpClient Example Source: https://docs.cloud.llamaindex.ai/API/list-projects-api-v-1-projects-get An example using C#'s HttpClient to fetch a list of projects from the LlamaIndex Cloud API. It demonstrates setting up the request, adding necessary headers like Authorization and Accept, and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cloud.llamaindex.ai/api/v1/projects"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### C# HttpClient Request Example Source: https://docs.cloud.llamaindex.ai/API/get-extraction-agent-api-v-1-extraction-extraction-agents-extraction-agent-id-get Demonstrates how to make a GET request to the Cloud LlamaIndex AI API using C# HttpClient. It includes setting the authorization header and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cloud.llamaindex.ai/api/v1/extraction/extraction-agents/:extraction_agent_id"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Get File Metadata (C#) Source: https://docs.cloud.llamaindex.ai/API/get-file-api-v-1-files-id-get Example of how to retrieve file metadata using HttpClient in C#. It demonstrates setting the request URL, headers (Accept and Authorization), sending the request, and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cloud.llamaindex.ai/api/v1/files/:id"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Sync Agent Deployments (C#) Source: https://docs.cloud.llamaindex.ai/API/sync-deployments-api-v-1-projects-project-id-agents-sync-post Synchronizes agent deployments for a given project using C#. This example demonstrates how to set up an HttpClient, create a POST request to the sync endpoint, add necessary headers, and handle the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://api.cloud.llamaindex.ai/api/v1/projects/:project_id/agents:sync"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Configure Formatting Instruction Source: https://docs.cloud.llamaindex.ai/API/sync-pipeline-data-source-api-v-1-pipelines-pipeline-id-data-sources-data-source-id-sync-post Provides a general instruction for formatting the output content. This can include guidelines on style, tone, or specific formatting requirements. ```Python formatting_instruction: str ``` -------------------------------- ### Get Retrievers API Request (C#) Source: https://docs.cloud.llamaindex.ai/API/list-retrievers-api-v-1-retrievers-get Provides a C# example for making a GET request to the /api/v1/retrievers endpoint. It includes setting the Authorization header with a Bearer token and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cloud.llamaindex.ai/api/v1/retrievers"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Get Pipeline Document (C#) Source: https://docs.cloud.llamaindex.ai/API/get-pipeline-document-api-v-1-pipelines-pipeline-id-documents-document-id-get Example C# code to retrieve a document from a LlamaIndex pipeline using HttpClient. It sets the request method, URL, and necessary headers like Accept and Authorization. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cloud.llamaindex.ai/api/v1/pipelines/:pipeline_id/documents/:document_id"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Rust Example for Upload File V2 Source: https://docs.cloud.llamaindex.ai/API/upload-file-v-2-api-v-2-alpha-1-parse-upload-post A Rust example using the 'reqwest' crate to upload a file. ```rust use reqwest::blocking::multipart; use std::fs::File; fn main() -> Result<(), Box> { let url = "https://api.cloud.llamaindex.ai/api/v2alpha1/parse/upload"; let file_path = ""; let configuration = ""; let file = File::open(file_path)?; let form = multipart::Form::new() .text("configuration", configuration) .file("file", (file_path, file))?; let client = reqwest::blocking::Client::new(); let response = client.post(url) .header("Accept", "application/json") .header("Authorization", "Bearer ") .multipart(form) .send()?; println!("Status: {}", response.status()); println!("Body: {}", response.text()?); Ok(()) } ``` -------------------------------- ### Configure Formatting Instruction Source: https://docs.cloud.llamaindex.ai/API/create-pipeline-api-v-1-pipelines-post Provides a general instruction for formatting the output content. This can include guidelines on style, tone, or specific formatting requirements. ```Python formatting_instruction: str ``` -------------------------------- ### Get Job Details in C# Source: https://docs.cloud.llamaindex.ai/API/get-job-api-v-1-extraction-jobs-job-id-get Provides a C# example using HttpClient to fetch job details from the LlamaIndex Cloud API. It shows how to construct the request, add headers, send it, and process the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cloud.llamaindex.ai/api/v1/extraction/jobs/:job_id"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Basic Retrieval with LlamaCloud Index (TypeScript) Source: https://docs.cloud.llamaindex.ai/llamacloud/retrieval/basic This TypeScript snippet illustrates how to connect to a LlamaCloud index and set up a retriever for basic retrieval. It covers initializing the index with project details and an API key, configuring retrieval parameters, and executing a query. ```TypeScript import{ LlamaCloudIndex }from"llama-cloud-services"; // connect to existing index const index =newLlamaCloudIndex({ name:"example-pipeline", projectName:"Default", apiKey: process.env.LLAMA_CLOUD_API_KEY,// can provide API-key in the constructor or in the env }); // configure retriever const retriever = index.asRetriever({ similarityTopK:3, sparseSimilarityTopK:3, alpha:0.5, enableReranking:true, rerankTopN:3, }); const nodes = retriever.retrieve({ query:"Example Query" }); ``` -------------------------------- ### Get Parsing Job C# Example Source: https://docs.cloud.llamaindex.ai/API/get-job-api-v-1-parsing-job-job-id-get Demonstrates how to retrieve a parsing job using C# with HttpClient. It includes setting the request URL, adding necessary headers like Accept and Authorization, and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cloud.llamaindex.ai/api/v1/parsing/job/:job_id"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Create Project API Request (C#) Source: https://docs.cloud.llamaindex.ai/API/create-project-api-v-1-projects-post Example of creating a new project using the LlamaIndex Cloud API with C#. It demonstrates setting up HttpClient, HttpRequestMessage, headers, and content for a POST request. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://api.cloud.llamaindex.ai/api/v1/projects"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); request.Headers.Add("Authorization", "Bearer "); var content = new StringContent("{\n \"name\": \"string\"\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.