Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
BruceMacD committed Feb 27, 2024
1 parent 8e185e0 commit 8662a87
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ To run the examples run:

```sh
npx tsx <folder-name>/<file-name>.ts
```
```
10 changes: 5 additions & 5 deletions src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {
ShowRequest,
ChatRequest,
ChatResponse,
CreateRequest
CreateRequest,
} from './interfaces.js'

export class Ollama {
Expand Down Expand Up @@ -97,10 +97,10 @@ export class Ollama {
async encodeImage(image: Uint8Array | string): Promise<string> {
if (typeof image !== 'string') {
// image is Uint8Array convert it to base64
const uint8Array = new Uint8Array(image);
const numberArray = Array.from(uint8Array);
const base64String = btoa(String.fromCharCode.apply(null, numberArray));
return base64String;
const uint8Array = new Uint8Array(image)
const numberArray = Array.from(uint8Array)
const base64String = btoa(String.fromCharCode.apply(null, numberArray))
return base64String
}
// the string may be base64 encoded
return image
Expand Down
10 changes: 3 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ import { createHash } from 'crypto'
import { homedir } from 'os'
import { Ollama as OllamaBrowser } from './browser.js'

import type {
CreateRequest,
ProgressResponse,
} from './interfaces.js'
import type { CreateRequest, ProgressResponse } from './interfaces.js'

export class Ollama extends OllamaBrowser {

async encodeImage(image: Uint8Array | Buffer | string): Promise<string> {
if (typeof image !== 'string') {
// image is Uint8Array or Buffer, convert it to base64
Expand Down Expand Up @@ -147,9 +143,9 @@ export class Ollama extends OllamaBrowser {

// check stream here so that typescript knows which overload to use
if (request.stream) {
return super.create(request as CreateRequest & { stream: true });
return super.create(request as CreateRequest & { stream: true })
} else {
return super.create(request as CreateRequest & { stream: false });
return super.create(request as CreateRequest & { stream: false })
}
}
}
Expand Down

0 comments on commit 8662a87

Please sign in to comment.