Browse Source

formatting

Bruce MacDonald 1 year ago
parent
commit
8662a871cc
3 changed files with 9 additions and 13 deletions
  1. 1 1
      examples/README.md
  2. 5 5
      src/browser.ts
  3. 3 7
      src/index.ts

+ 1 - 1
examples/README.md

@@ -7,4 +7,4 @@ To run the examples run:
 
 ```sh
 npx tsx <folder-name>/<file-name>.ts
-```
+```

+ 5 - 5
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<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

+ 3 - 7
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<string> {
     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 })
     }
   }
 }