From af6737eb1e10faa985e9e305d743ca24609d3263 Mon Sep 17 00:00:00 2001 From: Tyler Maran Date: Wed, 11 Sep 2024 22:01:56 -0700 Subject: [PATCH] shuffle things around in the readme --- README.md | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index e52d490..033b65d 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ This is how the pricing stacks up to other document processers. Running 1,000 pa | ------------------------ | -------------------- | -------- | ------------- | | Zerox (gpt-mini) | $ 4.00 / 1,000 pages | High | High | -## Installation +## Getting Started Zerox is available as both a Node and Python package. @@ -139,13 +139,19 @@ Request #3 => page_2_markdown + page_3_image ## Python Zerox -#### (Python SDK - supports vision models from different providers like OpenAI, Azure OpenAI, Anthropic, AWS Bedrock etc) +(Python SDK - supports vision models from different providers like OpenAI, Azure OpenAI, Anthropic, AWS Bedrock etc) -Installation: +### Installation: - Install **poppler-utils** on the system, it should be available in path variable - Install py-zerox: `pip install py-zerox` +The `zerox` function is an asynchronous API that performs OCR (Optical Character Recognition) to markdown using vision models. It processes PDF files and converts them into markdown format. Make sure to set up the environment variables for the model and the model provider before using this API. + +Refer to the [LiteLLM Documentation](https://docs.litellm.ai/docs/providers) for setting up the environment and passing the correct model name. + +### Usage + ```python from py_zerox import zerox import os @@ -221,21 +227,7 @@ result = asyncio.run(main()) print(result) ``` -### Example Output (Output from "azure/gpt-4o-mini"): - -````console -ZeroxOutput(completion_time=21192.572, file_name='cs101', input_tokens=0, output_tokens=0, pages=[Page(content='# 26.3. Variables\n\n| Type | Description | Wrapper Class |\n|---------|---------------------------------------------|---------------|\n| byte | 8-bit signed 2s complement integer | Byte |\n| short | 16-bit signed 2s complement integer | Short |\n| int | 32-bit signed 2s complement integer | Integer |\n| long | 64-bit signed 2s complement integer | Long |\n| float | 32-bit IEEE 754 floating point number | Float |\n| double | 64-bit floating point number | Double |\n| boolean | may be set to true or false | Boolean |\n| char | 16-bit Unicode (UTF-16) character | Character |\n\n**Table 26.2:** Primitive types in Java\n\n## 26.3.1. Declaration & Assignment\n\nJava is a statically typed language meaning that all variables must be declared before you can use them or refer to them. In addition, when declaring a variable, you must specify both its type and its identifier. For example:\n\n```java\nint numUnits;\ndouble costPerUnit;\nchar firstInitial;\nboolean isStudent;\n```\n\nEach declaration specifies the variable’s type followed by the identifier and ending with a semicolon. The identifier rules are fairly standard: a name can consist of lowercase and uppercase alphabetic characters, numbers, and underscores but may not begin with a numeric character. We adopt the modern camelCasing naming convention for variables in our code. In general, variables must be assigned a value before you can use them in an expression. You do not have to immediately assign a value when you declare them (though it is good practice), but some value must be assigned before they can be used or the compiler will issue an error. \n\nThe assignment operator is a single equal sign, `=` and is a right-to-left assignment. That is, the variable that we wish to assign the value to appears on the left-hand-side while the value (literal, variable or expression) is on the right-hand-size. Using our variables from before, we can assign them values:\n\n> Instance variables, that is variables declared as part of an object do have default values. For objects, the default is `null`, for all numeric types, zero is the default value. For the boolean type, `false` is the default, and the default `char` value is `\\0`, the null-terminating character (zero in the ASCII table).', content_length=2420, page=1)]) -```` - -### Python API doc - -## `zerox` Function - -The `zerox` function is an asynchronous API that performs OCR (Optical Character Recognition) to markdown using vision models. It processes PDF files and converts them into markdown format. Make sure to set up the environment variables for the model and the model provider before using this API. - -Refer to the [LiteLLM Documentation](https://docs.litellm.ai/docs/providers) for setting up the environment and passing the correct model name. - -### Function Signature +### Parameters ```python async def zerox( @@ -281,6 +273,12 @@ Returns - ZeroxOutput: The markdown content generated by the model. +### Example Output (Output from "azure/gpt-4o-mini"): + +````console +ZeroxOutput(completion_time=21192.572, file_name='cs101', input_tokens=0, output_tokens=0, pages=[Page(content='# 26.3. Variables\n\n| Type | Description | Wrapper Class |\n|---------|---------------------------------------------|---------------|\n| byte | 8-bit signed 2s complement integer | Byte |\n| short | 16-bit signed 2s complement integer | Short |\n| int | 32-bit signed 2s complement integer | Integer |\n| long | 64-bit signed 2s complement integer | Long |\n| float | 32-bit IEEE 754 floating point number | Float |\n| double | 64-bit floating point number | Double |\n| boolean | may be set to true or false | Boolean |\n| char | 16-bit Unicode (UTF-16) character | Character |\n\n**Table 26.2:** Primitive types in Java\n\n## 26.3.1. Declaration & Assignment\n\nJava is a statically typed language meaning that all variables must be declared before you can use them or refer to them. In addition, when declaring a variable, you must specify both its type and its identifier. For example:\n\n```java\nint numUnits;\ndouble costPerUnit;\nchar firstInitial;\nboolean isStudent;\n```\n\nEach declaration specifies the variable’s type followed by the identifier and ending with a semicolon. The identifier rules are fairly standard: a name can consist of lowercase and uppercase alphabetic characters, numbers, and underscores but may not begin with a numeric character. We adopt the modern camelCasing naming convention for variables in our code. In general, variables must be assigned a value before you can use them in an expression. You do not have to immediately assign a value when you declare them (though it is good practice), but some value must be assigned before they can be used or the compiler will issue an error. \n\nThe assignment operator is a single equal sign, `=` and is a right-to-left assignment. That is, the variable that we wish to assign the value to appears on the left-hand-side while the value (literal, variable or expression) is on the right-hand-size. Using our variables from before, we can assign them values:\n\n> Instance variables, that is variables declared as part of an object do have default values. For objects, the default is `null`, for all numeric types, zero is the default value. For the boolean type, `false` is the default, and the default `char` value is `\\0`, the null-terminating character (zero in the ASCII table).', content_length=2420, page=1)]) +```` + ## Credits - [Litellm](https://github.com/BerriAI/litellm): https://github.com/BerriAI/litellm | This powers our python sdk to support all popular vision models different providers.