Преглед изворни кода

update config `address` to `host`

Bruce MacDonald пре 1 година
родитељ
комит
605f3d16d0
3 измењених фајлова са 6 додато и 18 уклоњено
  1. 4 4
      src/index.ts
  2. 2 2
      src/interfaces.ts
  3. 0 12
      src/utils.ts

+ 4 - 4
src/index.ts

@@ -31,10 +31,10 @@ export class Ollama {
   private readonly config: Config
   private readonly fetch: Fetch
 
-  constructor(config?: Partial<Config>) {
-    this.config = {
-      address: config?.address ?? 'http://127.0.0.1:11434',
-    }
+	constructor (config?: Partial<Config>) {
+		this.config = {
+			host: config?.host ?? "http://127.0.0.1:11434"
+		};
 
     this.fetch = fetch
     if (config?.fetch != null) {

+ 2 - 2
src/interfaces.ts

@@ -1,8 +1,8 @@
 export type Fetch = typeof fetch
 
 export interface Config {
-  address: string
-  fetch?: Fetch
+	host: string,
+	fetch?: Fetch
 }
 
 // request types

+ 0 - 12
src/utils.ts

@@ -1,17 +1,5 @@
 import type { Fetch, ErrorResponse } from './interfaces.js'
 
-export const formatAddress = (address: string): string => {
-  if (!address.startsWith('http://') && !address.startsWith('https://')) {
-    address = `http://${address}`
-  }
-
-  while (address.endsWith('/')) {
-    address = address.substring(0, address.length - 1)
-  }
-
-  return address
-}
-
 const checkOk = async (response: Response): Promise<void> => {
   if (!response.ok) {
     let message = `Error ${response.status}: ${response.statusText}`