From 8662a871ccd45d7a8c7a9b0f0c007d1cb76d4ce0 Mon Sep 17 00:00:00 2001 From: Bruce MacDonald Date: Tue, 27 Feb 2024 17:52:59 -0500 Subject: [PATCH] formatting --- examples/README.md | 2 +- src/browser.ts | 10 +++++----- src/index.ts | 10 +++------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/examples/README.md b/examples/README.md index 996fba5..53f3621 100644 --- a/examples/README.md +++ b/examples/README.md @@ -7,4 +7,4 @@ To run the examples run: ```sh npx tsx /.ts -``` \ No newline at end of file +``` diff --git a/src/browser.ts b/src/browser.ts index 393d2cc..842b6f3 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -20,7 +20,7 @@ import type { ShowRequest, ChatRequest, ChatResponse, - CreateRequest + CreateRequest, } from './interfaces.js' export class Ollama { @@ -97,10 +97,10 @@ export class Ollama { async encodeImage(image: Uint8Array | string): Promise { 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 diff --git a/src/index.ts b/src/index.ts index b18ed49..f75ac60 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 { if (typeof image !== 'string') { // image is Uint8Array or Buffer, convert it to base64 @@ -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 }) } } }