Skip to content

Commit

Permalink
Add C# API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
natke committed Nov 17, 2024
1 parent 21e20ad commit 89b0a59
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
86 changes: 86 additions & 0 deletions docs/genai/api/csharp.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,33 @@ public void GenerateNextToken()
public ReadOnlySpan<int> GetSequence(ulong index)
```

### Set active adapter

Sets the active adapter on this Generator instance.

```csharp
using var model = new Model(modelPath);
using var genParams = new GeneratorParams(model);
using var generator = new Generator(model, genParams);
using var adapters = new Adapters(model);
string adapterName = "..."

generator.SetActiveAdapter(adapters, adapterName);
```

#### Parameters

* `adapters`: the previously created `Adapter` object
* `adapterName`: the name of the adapter to activate

#### Return value

`void`

#### Exception

Throws on error.

## Sequences class

### Num sequences member
Expand All @@ -169,3 +196,62 @@ public ulong NumSequences { get { return _numSequences; } }
public ReadOnlySpan<int> this[ulong sequenceIndex]
```

## Adapter class

This API is used to load and switch fine-tuned adapters, such as LoRA adapters.

### Constructor

Construct an instance of an Adapter class.

```csharp
using var model = new Model(modelPath);

using var adapters = new Adapters(model);
```

#### Parameters

* `model`: a previously constructed model class

### Load Adapter method

Loads an adapter file from disk.

```csharp
string adapterPath = Path()
string adapterName = ...

adapters.LoadAdapter(adapterPath, adapterName);
```

#### Parameters

* `adapterPath`: the path to the adapter file on disk
* `adapterName`: a string identifier used to refer to the adapter in subsequent methods

#### Return value

`void`

### Unload Adapter method

Unloads an adapter file from memory.

```csharp
adapters.UnLoadAdapter(adapterName);
```

#### Parameters

* `adapterName`: the name of the adapter to unload

#### Return value

`void`

#### Execption

Throws an exception on error.


4 changes: 4 additions & 0 deletions docs/genai/api/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -610,3 +610,7 @@ public int[] getSequence(long sequenceIndex)

The sequence as an array of integers.


## Adapter class

_Coming very soon!_

0 comments on commit 89b0a59

Please sign in to comment.