Skip to content

Commit

Permalink
javadoc and build updates
Browse files Browse the repository at this point in the history
  • Loading branch information
fionabos committed Jul 3, 2024
1 parent 6932c52 commit 31bb0e2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 64 deletions.
64 changes: 8 additions & 56 deletions docs/genai/api/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,10 @@ _Note: this API is in preview and is subject to change._
{:toc}

## Install and import
//ADD LATER
The Java API is delivered by the onnxruntime-genai Java package.

```bash
//install onnxruntime-genai
```

```java
import onnxruntime_genai
```

## Exception Class

An exception which contains the error message and code produced by the native layer.

### Constructor
The Java API is delivered by the ai.onnxruntime.genai Java package. Package publication is pending. To build the package from source, see the [installation guide](../howto/install.md).

```java
public GenAIException(String message)
```

#### Example

```java
catch (GenAIException e) {
throw new GenAIException("Token generation loop failed.", e);
}
import ai.onnxruntime.genai.*;
```

## SimpleGenAI Class
Expand Down Expand Up @@ -140,46 +117,21 @@ public GeneratorParams createGeneratorParams(String prompt) throws GenAIExceptio

The generator parameters.

//delete
## GenAI Class

GenAI class provides a set of static functions and string definitions used to describe current running environment.

### Initialize GenAI environment

Load all the libraries required by GenAI.

```java
static synchronized void init() throws IOException;
```

#### Throws

`IOException` - if any of required libraries fail to load.

#### Example

```java
GenAI.init();
```
## Exception Class

### Check Android Method
An exception which contains the error message and code produced by the native layer.

Check if we're running on Android.
### Constructor

```java
static boolean isAndroid()
public GenAIException(String message)
```

#### Returns

Returns True if the property java.vendor equals The Android Project, false otherwise.

#### Example

```java
if (GenAI.isAndroid()) {
// Android-specific code
catch (GenAIException e) {
throw new GenAIException("Token generation loop failed.", e);
}
```

Expand Down
28 changes: 20 additions & 8 deletions docs/genai/howto/build-from-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ nav_order: 2

## Pre-requisites

`cmake`
- `cmake`
- `.Net v6` (if building C# library or API)

## Clone the onnxruntime-genai repo

Expand Down Expand Up @@ -154,36 +155,45 @@ This step assumes that you are in the root of the onnxruntime-genai repo, and yo
cd ../onnxruntime-genai
```

### Build for Windows CPU
### Build Python API

#### Build for Windows CPU

```bash
python build.py
```

### Build for Windows DirectML
#### Build for Windows DirectML

```bash
python build.py --use_dml
```

### Build on Linux
#### Build on Linux

```bash
python build.py
```

### Build on Linux with CUDA
#### Build on Linux with CUDA

```bash
python build.py --use_cuda
```

### Build on Mac
#### Build on Mac

```bash
python build.py
```


### Build Java API

```bash
python build.py --build_java --config Release
```
Change config to Debug for debug builds.

## Install the library into your application

### Install Python wheel
Expand All @@ -193,9 +203,11 @@ cd build/wheel
pip install *.whl
```

### Install Nuget package
### Install .jar

Copy `build/Windows/Release/src/java/build/libs/*.jar` into your application.

### Install Nuget package

### Install C/C++ header file and library

Expand Down

0 comments on commit 31bb0e2

Please sign in to comment.