diff --git a/README.md b/README.md index af522cc..e043dea 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,9 @@ console.log(response.message.content) ``` ### Browser Usage + To use the library without node, import the browser module. + ```javascript import ollama from 'ollama/browser' ``` @@ -34,7 +36,11 @@ Response streaming can be enabled by setting `stream: true`, modifying function import ollama from 'ollama' const message = { role: 'user', content: 'Why is the sky blue?' } -const response = await ollama.chat({ model: 'llama3.1', messages: [message], stream: true }) +const response = await ollama.chat({ + model: 'llama3.1', + messages: [message], + stream: true, +}) for await (const part of response) { process.stdout.write(part.message.content) } @@ -207,7 +213,7 @@ ollama.abort() This method will abort **all** streamed generations currently running with the client instance. If there is a need to manage streams with timeouts, it is recommended to have one Ollama client per stream. -All asynchronous threads listening to streams (typically the ```for await (const part of response)```) will throw an ```AbortError``` exception. See [examples/abort/abort-all-requests.ts](examples/abort/abort-all-requests.ts) for an example. +All asynchronous threads listening to streams (typically the `for await (const part of response)`) will throw an `AbortError` exception. See [examples/abort/abort-all-requests.ts](examples/abort/abort-all-requests.ts) for an example. ## Custom client diff --git a/examples/abort/abort-all-requests.ts b/examples/abort/abort-all-requests.ts index 3832cd0..8c99193 100644 --- a/examples/abort/abort-all-requests.ts +++ b/examples/abort/abort-all-requests.ts @@ -8,45 +8,45 @@ setTimeout(() => { // Start multiple concurrent streaming requests Promise.all([ - ollama.generate({ - model: 'llama3.2', - prompt: 'Write a long story about dragons', - stream: true, - }).then( - async (stream) => { + ollama + .generate({ + model: 'llama3.2', + prompt: 'Write a long story about dragons', + stream: true, + }) + .then(async (stream) => { console.log(' Starting stream for dragons story...') for await (const chunk of stream) { process.stdout.write(' 1> ' + chunk.response) } - } - ), + }), - ollama.generate({ - model: 'llama3.2', - prompt: 'Write a long story about wizards', - stream: true, - }).then( - async (stream) => { + ollama + .generate({ + model: 'llama3.2', + prompt: 'Write a long story about wizards', + stream: true, + }) + .then(async (stream) => { console.log(' Starting stream for wizards story...') for await (const chunk of stream) { process.stdout.write(' 2> ' + chunk.response) } - } - ), + }), - ollama.generate({ - model: 'llama3.2', - prompt: 'Write a long story about knights', - stream: true, - }).then( - async (stream) => { + ollama + .generate({ + model: 'llama3.2', + prompt: 'Write a long story about knights', + stream: true, + }) + .then(async (stream) => { console.log(' Starting stream for knights story...') for await (const chunk of stream) { process.stdout.write(' 3>' + chunk.response) } - } - ) -]).catch(error => { + }), +]).catch((error) => { if (error.name === 'AbortError') { console.log('All requests have been aborted') } else { diff --git a/examples/abort/abort-single-request.ts b/examples/abort/abort-single-request.ts index 214ac87..2252d07 100644 --- a/examples/abort/abort-single-request.ts +++ b/examples/abort/abort-single-request.ts @@ -13,38 +13,35 @@ setTimeout(() => { // Start multiple concurrent streaming requests with different clients Promise.all([ - client1.generate({ - model: 'llama3.2', - prompt: 'Write a long story about dragons', - stream: true, - }).then( - async (stream) => { + client1 + .generate({ + model: 'llama3.2', + prompt: 'Write a long story about dragons', + stream: true, + }) + .then(async (stream) => { console.log(' Starting stream for dragons story...') for await (const chunk of stream) { process.stdout.write(' 1> ' + chunk.response) } - } - ), + }), - client2.generate({ - model: 'llama3.2', - prompt: 'Write a short story about wizards', - stream: true, - }).then( - async (stream) => { + client2 + .generate({ + model: 'llama3.2', + prompt: 'Write a short story about wizards', + stream: true, + }) + .then(async (stream) => { console.log(' Starting stream for wizards story...') for await (const chunk of stream) { process.stdout.write(' 2> ' + chunk.response) } - } - ), - -]).catch(error => { + }), +]).catch((error) => { if (error.name === 'AbortError') { console.log('Dragons story request has been aborted') } else { console.error('An error occurred:', error) } }) - - diff --git a/examples/structured_outputs/structured-outputs-image.ts b/examples/structured_outputs/structured-outputs-image.ts index 89fea3f..0c7a18a 100644 --- a/examples/structured_outputs/structured-outputs-image.ts +++ b/examples/structured_outputs/structured-outputs-image.ts @@ -1,10 +1,10 @@ -import ollama from 'ollama'; +import ollama from 'ollama' -import { z } from 'zod'; -import { zodToJsonSchema } from 'zod-to-json-schema'; -import { readFileSync } from 'fs'; -import { resolve } from 'path'; -import { createInterface } from 'readline'; +import { z } from 'zod' +import { zodToJsonSchema } from 'zod-to-json-schema' +import { readFileSync } from 'fs' +import { resolve } from 'path' +import { createInterface } from 'readline' /* Ollama vision capabilities with structured outputs @@ -14,70 +14,83 @@ import { createInterface } from 'readline'; // Schema for individual objects detected in the image const ObjectSchema = z.object({ - name: z.string().describe('The name of the object'), - confidence: z.number().min(0).max(1).describe('The confidence score of the object detection'), - attributes: z.record(z.any()).optional().describe('Additional attributes of the object') -}); + name: z.string().describe('The name of the object'), + confidence: z + .number() + .min(0) + .max(1) + .describe('The confidence score of the object detection'), + attributes: z + .record(z.any()) + .optional() + .describe('Additional attributes of the object'), +}) // Schema for individual objects detected in the image const ImageDescriptionSchema = z.object({ - summary: z.string().describe('A concise summary of the image'), - objects: z.array(ObjectSchema).describe('An array of objects detected in the image'), - scene: z.string().describe('The scene of the image'), - colors: z.array(z.string()).describe('An array of colors detected in the image'), - time_of_day: z.enum(['Morning', 'Afternoon', 'Evening', 'Night']).describe('The time of day the image was taken'), - setting: z.enum(['Indoor', 'Outdoor', 'Unknown']).describe('The setting of the image'), - text_content: z.string().describe('Any text detected in the image') -}); + summary: z.string().describe('A concise summary of the image'), + objects: z.array(ObjectSchema).describe('An array of objects detected in the image'), + scene: z.string().describe('The scene of the image'), + colors: z.array(z.string()).describe('An array of colors detected in the image'), + time_of_day: z + .enum(['Morning', 'Afternoon', 'Evening', 'Night']) + .describe('The time of day the image was taken'), + setting: z.enum(['Indoor', 'Outdoor', 'Unknown']).describe('The setting of the image'), + text_content: z.string().describe('Any text detected in the image'), +}) async function run(model: string) { - // Create readline interface for user input - const rl = createInterface({ - input: process.stdin, - output: process.stdout - }); + // Create readline interface for user input + const rl = createInterface({ + input: process.stdin, + output: process.stdout, + }) - // Get path from user input - const path = await new Promise(resolve => { - rl.question('Enter the path to your image: ', resolve); - }); - rl.close(); + // Get path from user input + const path = await new Promise((resolve) => { + rl.question('Enter the path to your image: ', resolve) + }) + rl.close() - // Verify the file exists and read it - try { - const imagePath = resolve(path); - const imageBuffer = readFileSync(imagePath); - const base64Image = imageBuffer.toString('base64'); - - // Convert the Zod schema to JSON Schema format - const jsonSchema = zodToJsonSchema(ImageDescriptionSchema); + // Verify the file exists and read it + try { + const imagePath = resolve(path) + const imageBuffer = readFileSync(imagePath) + const base64Image = imageBuffer.toString('base64') - const messages = [{ - role: 'user', - content: 'Analyze this image and return a detailed JSON description including objects, scene, colors and any text detected. If you cannot determine certain details, leave those fields empty.', - images: [base64Image] - }]; + // Convert the Zod schema to JSON Schema format + const jsonSchema = zodToJsonSchema(ImageDescriptionSchema) - const response = await ollama.chat({ - model: model, - messages: messages, - format: jsonSchema, - options: { - temperature: 0 // Make responses more deterministic - } - }); + const messages = [ + { + role: 'user', + content: + 'Analyze this image and return a detailed JSON description including objects, scene, colors and any text detected. If you cannot determine certain details, leave those fields empty.', + images: [base64Image], + }, + ] - // Parse and validate the response - try { - const imageAnalysis = ImageDescriptionSchema.parse(JSON.parse(response.message.content)); - console.log('Image Analysis:', imageAnalysis); - } catch (error) { - console.error("Generated invalid response:", error); - } + const response = await ollama.chat({ + model: model, + messages: messages, + format: jsonSchema, + options: { + temperature: 0, // Make responses more deterministic + }, + }) + // Parse and validate the response + try { + const imageAnalysis = ImageDescriptionSchema.parse( + JSON.parse(response.message.content), + ) + console.log('Image Analysis:', imageAnalysis) } catch (error) { - console.error("Error reading image file:", error); + console.error('Generated invalid response:', error) } + } catch (error) { + console.error('Error reading image file:', error) + } } -run('llama3.2-vision').catch(console.error); \ No newline at end of file +run('llama3.2-vision').catch(console.error) diff --git a/examples/structured_outputs/structured-outputs.ts b/examples/structured_outputs/structured-outputs.ts index 855806e..1ccbbf1 100644 --- a/examples/structured_outputs/structured-outputs.ts +++ b/examples/structured_outputs/structured-outputs.ts @@ -1,7 +1,7 @@ -import ollama from 'ollama'; +import ollama from 'ollama' -import { z } from 'zod'; -import { zodToJsonSchema } from 'zod-to-json-schema'; +import { z } from 'zod' +import { zodToJsonSchema } from 'zod-to-json-schema' /* Ollama structured outputs capabilities @@ -10,21 +10,21 @@ import { zodToJsonSchema } from 'zod-to-json-schema'; // Define the schema for friend info const FriendInfoSchema = z.object({ - name: z.string().describe('The name of the friend'), - age: z.number().int().describe('The age of the friend'), - is_available: z.boolean().describe('Whether the friend is available') -}); + name: z.string().describe('The name of the friend'), + age: z.number().int().describe('The age of the friend'), + is_available: z.boolean().describe('Whether the friend is available'), +}) // Define the schema for friend list const FriendListSchema = z.object({ - friends: z.array(FriendInfoSchema).describe('An array of friends') -}); + friends: z.array(FriendInfoSchema).describe('An array of friends'), +}) async function run(model: string) { - // Convert the Zod schema to JSON Schema format - const jsonSchema = zodToJsonSchema(FriendListSchema); + // Convert the Zod schema to JSON Schema format + const jsonSchema = zodToJsonSchema(FriendListSchema) - /* Can use manually defined schema directly + /* Can use manually defined schema directly const schema = { 'type': 'object', 'properties': { @@ -45,27 +45,30 @@ async function run(model: string) { } */ - const messages = [{ - role: 'user', - content: 'I have two friends. The first is Ollama 22 years old busy saving the world, and the second is Alonso 23 years old and wants to hang out. Return a list of friends in JSON format' - }]; + const messages = [ + { + role: 'user', + content: + 'I have two friends. The first is Ollama 22 years old busy saving the world, and the second is Alonso 23 years old and wants to hang out. Return a list of friends in JSON format', + }, + ] - const response = await ollama.chat({ - model: model, - messages: messages, - format: jsonSchema, // or format: schema - options: { - temperature: 0 // Make responses more deterministic - } - }); + const response = await ollama.chat({ + model: model, + messages: messages, + format: jsonSchema, // or format: schema + options: { + temperature: 0, // Make responses more deterministic + }, + }) - // Parse and validate the response - try { - const friendsResponse = FriendListSchema.parse(JSON.parse(response.message.content)); - console.log(friendsResponse); - } catch (error) { - console.error("Generated invalid response:", error); - } + // Parse and validate the response + try { + const friendsResponse = FriendListSchema.parse(JSON.parse(response.message.content)) + console.log(friendsResponse) + } catch (error) { + console.error('Generated invalid response:', error) + } } -run('llama3.1:8b').catch(console.error); \ No newline at end of file +run('llama3.1:8b').catch(console.error) diff --git a/examples/tools/calculator.ts b/examples/tools/calculator.ts index 5160256..a2684bd 100644 --- a/examples/tools/calculator.ts +++ b/examples/tools/calculator.ts @@ -1,95 +1,95 @@ -import ollama from 'ollama'; +import ollama from 'ollama' // Add two numbers function -function addTwoNumbers(args: { a: number, b: number }): number { - return args.a + args.b; +function addTwoNumbers(args: { a: number; b: number }): number { + return args.a + args.b } -// Subtract two numbers function -function subtractTwoNumbers(args: { a: number, b: number }): number { - return args.a - args.b; +// Subtract two numbers function +function subtractTwoNumbers(args: { a: number; b: number }): number { + return args.a - args.b } // Tool definition for add function const addTwoNumbersTool = { - type: 'function', - function: { - name: 'addTwoNumbers', - description: 'Add two numbers together', - parameters: { - type: 'object', - required: ['a', 'b'], - properties: { - a: { type: 'number', description: 'The first number' }, - b: { type: 'number', description: 'The second number' } - } - } - } -}; + type: 'function', + function: { + name: 'addTwoNumbers', + description: 'Add two numbers together', + parameters: { + type: 'object', + required: ['a', 'b'], + properties: { + a: { type: 'number', description: 'The first number' }, + b: { type: 'number', description: 'The second number' }, + }, + }, + }, +} // Tool definition for subtract function const subtractTwoNumbersTool = { - type: 'function', - function: { - name: 'subtractTwoNumbers', - description: 'Subtract two numbers', - parameters: { - type: 'object', - required: ['a', 'b'], - properties: { - a: { type: 'number', description: 'The first number' }, - b: { type: 'number', description: 'The second number' } - } - } - } -}; + type: 'function', + function: { + name: 'subtractTwoNumbers', + description: 'Subtract two numbers', + parameters: { + type: 'object', + required: ['a', 'b'], + properties: { + a: { type: 'number', description: 'The first number' }, + b: { type: 'number', description: 'The second number' }, + }, + }, + }, +} async function run(model: string) { - const messages = [{ role: 'user', content: 'What is three minus one?' }]; - console.log('Prompt:', messages[0].content); - - const availableFunctions = { - addTwoNumbers: addTwoNumbers, - subtractTwoNumbers: subtractTwoNumbers - }; + const messages = [{ role: 'user', content: 'What is three minus one?' }] + console.log('Prompt:', messages[0].content) - const response = await ollama.chat({ - model: model, - messages: messages, - tools: [addTwoNumbersTool, subtractTwoNumbersTool] - }); + const availableFunctions = { + addTwoNumbers: addTwoNumbers, + subtractTwoNumbers: subtractTwoNumbers, + } - let output: number; - if (response.message.tool_calls) { - // Process tool calls from the response - for (const tool of response.message.tool_calls) { - const functionToCall = availableFunctions[tool.function.name]; - if (functionToCall) { - console.log('Calling function:', tool.function.name); - console.log('Arguments:', tool.function.arguments); - output = functionToCall(tool.function.arguments); - console.log('Function output:', output); + const response = await ollama.chat({ + model: model, + messages: messages, + tools: [addTwoNumbersTool, subtractTwoNumbersTool], + }) - // Add the function response to messages for the model to use - messages.push(response.message); - messages.push({ - role: 'tool', - content: output.toString(), - }); - } else { - console.log('Function', tool.function.name, 'not found'); - } - } + let output: number + if (response.message.tool_calls) { + // Process tool calls from the response + for (const tool of response.message.tool_calls) { + const functionToCall = availableFunctions[tool.function.name] + if (functionToCall) { + console.log('Calling function:', tool.function.name) + console.log('Arguments:', tool.function.arguments) + output = functionToCall(tool.function.arguments) + console.log('Function output:', output) - // Get final response from model with function outputs - const finalResponse = await ollama.chat({ - model: model, - messages: messages - }); - console.log('Final response:', finalResponse.message.content); - } else { - console.log('No tool calls returned from model'); + // Add the function response to messages for the model to use + messages.push(response.message) + messages.push({ + role: 'tool', + content: output.toString(), + }) + } else { + console.log('Function', tool.function.name, 'not found') + } } + + // Get final response from model with function outputs + const finalResponse = await ollama.chat({ + model: model, + messages: messages, + }) + console.log('Final response:', finalResponse.message.content) + } else { + console.log('No tool calls returned from model') + } } -run('llama3.1:8b').catch(error => console.error("An error occurred:", error)); \ No newline at end of file +run('llama3.1:8b').catch((error) => console.error('An error occurred:', error)) diff --git a/examples/tools/flight-tracker.ts b/examples/tools/flight-tracker.ts index 7b7bc43..fff1191 100644 --- a/examples/tools/flight-tracker.ts +++ b/examples/tools/flight-tracker.ts @@ -1,90 +1,95 @@ -import ollama from 'ollama'; +import ollama from 'ollama' // Simulates an API call to get flight times // In a real application, this would fetch data from a live database or API function getFlightTimes(args: { [key: string]: any }) { - // this is where you would validate the arguments you received - const departure = args.departure; - const arrival = args.arrival; + // this is where you would validate the arguments you received + const departure = args.departure + const arrival = args.arrival - const flights = { - "LGA-LAX": { departure: "08:00 AM", arrival: "11:30 AM", duration: "5h 30m" }, - "LAX-LGA": { departure: "02:00 PM", arrival: "10:30 PM", duration: "5h 30m" }, - "LHR-JFK": { departure: "10:00 AM", arrival: "01:00 PM", duration: "8h 00m" }, - "JFK-LHR": { departure: "09:00 PM", arrival: "09:00 AM", duration: "7h 00m" }, - "CDG-DXB": { departure: "11:00 AM", arrival: "08:00 PM", duration: "6h 00m" }, - "DXB-CDG": { departure: "03:00 AM", arrival: "07:30 AM", duration: "7h 30m" } - }; + const flights = { + 'LGA-LAX': { departure: '08:00 AM', arrival: '11:30 AM', duration: '5h 30m' }, + 'LAX-LGA': { departure: '02:00 PM', arrival: '10:30 PM', duration: '5h 30m' }, + 'LHR-JFK': { departure: '10:00 AM', arrival: '01:00 PM', duration: '8h 00m' }, + 'JFK-LHR': { departure: '09:00 PM', arrival: '09:00 AM', duration: '7h 00m' }, + 'CDG-DXB': { departure: '11:00 AM', arrival: '08:00 PM', duration: '6h 00m' }, + 'DXB-CDG': { departure: '03:00 AM', arrival: '07:30 AM', duration: '7h 30m' }, + } - const key = `${departure}-${arrival}`.toUpperCase(); - return JSON.stringify(flights[key] || { error: "Flight not found" }); + const key = `${departure}-${arrival}`.toUpperCase() + return JSON.stringify(flights[key] || { error: 'Flight not found' }) } async function run(model: string) { - // Initialize conversation with a user query - let messages = [{ role: 'user', content: 'What is the flight time from New York (LGA) to Los Angeles (LAX)?' }]; + // Initialize conversation with a user query + let messages = [ + { + role: 'user', + content: 'What is the flight time from New York (LGA) to Los Angeles (LAX)?', + }, + ] - // First API call: Send the query and function description to the model - const response = await ollama.chat({ - model: model, - messages: messages, - tools: [ - { - type: 'function', - function: { - name: 'get_flight_times', - description: 'Get the flight times between two cities', - parameters: { - type: 'object', - properties: { - departure: { - type: 'string', - description: 'The departure city (airport code)', - }, - arrival: { - type: 'string', - description: 'The arrival city (airport code)', - }, - }, - required: ['departure', 'arrival'], - }, - }, + // First API call: Send the query and function description to the model + const response = await ollama.chat({ + model: model, + messages: messages, + tools: [ + { + type: 'function', + function: { + name: 'get_flight_times', + description: 'Get the flight times between two cities', + parameters: { + type: 'object', + properties: { + departure: { + type: 'string', + description: 'The departure city (airport code)', + }, + arrival: { + type: 'string', + description: 'The arrival city (airport code)', + }, }, - ], - }) - // Add the model's response to the conversation history - messages.push(response.message); + required: ['departure', 'arrival'], + }, + }, + }, + ], + }) + // Add the model's response to the conversation history + messages.push(response.message) - // Check if the model decided to use the provided function - if (!response.message.tool_calls || response.message.tool_calls.length === 0) { - console.log("The model didn't use the function. Its response was:"); - console.log(response.message.content); - return; - } + // Check if the model decided to use the provided function + if (!response.message.tool_calls || response.message.tool_calls.length === 0) { + console.log("The model didn't use the function. Its response was:") + console.log(response.message.content) + return + } - // Process function calls made by the model - if (response.message.tool_calls) { - const availableFunctions = { - get_flight_times: getFlightTimes, - }; - for (const tool of response.message.tool_calls) { - const functionToCall = availableFunctions[tool.function.name]; - const functionResponse = functionToCall(tool.function.arguments); - console.log('functionResponse', functionResponse) - // Add function response to the conversation - messages.push({ - role: 'tool', - content: functionResponse, - }); - } + // Process function calls made by the model + if (response.message.tool_calls) { + const availableFunctions = { + get_flight_times: getFlightTimes, + } + for (const tool of response.message.tool_calls) { + const functionToCall = availableFunctions[tool.function.name] + const functionResponse = functionToCall(tool.function.arguments) + console.log('functionResponse', functionResponse) + // Add function response to the conversation + messages.push({ + role: 'tool', + content: functionResponse, + }) } + } - // Second API call: Get final response from the model - const finalResponse = await ollama.chat({ - model: model, - messages: messages, - }); - console.log(finalResponse.message.content); + // Second API call: Get final response from the model + const finalResponse = await ollama.chat({ + model: model, + messages: messages, + }) + console.log(finalResponse.message.content) } -run('mistral').catch(error => console.error("An error occurred:", error)); +run('mistral').catch((error) => console.error('An error occurred:', error)) diff --git a/src/interfaces.ts b/src/interfaces.ts index a941c9f..2fb8015 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -69,30 +69,30 @@ export interface Message { export interface ToolCall { function: { - name: string; + name: string arguments: { - [key: string]: any; - }; - }; + [key: string]: any + } + } } export interface Tool { - type: string; + type: string function: { - name: string; - description: string; + name: string + description: string parameters: { - type: string; - required: string[]; + type: string + required: string[] properties: { [key: string]: { - type: string; - description: string; - enum?: string[]; - }; - }; - }; - }; + type: string + description: string + enum?: string[] + } + } + } + } } export interface ChatRequest { diff --git a/src/utils.ts b/src/utils.ts index 76976bf..f0cdb6b 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -27,7 +27,11 @@ export class AbortableAsyncIterator { private readonly itr: AsyncGenerator private readonly doneCallback: () => void - constructor(abortController: AbortController, itr: AsyncGenerator, doneCallback: () => void) { + constructor( + abortController: AbortController, + itr: AsyncGenerator, + doneCallback: () => void, + ) { this.abortController = abortController this.itr = itr this.doneCallback = doneCallback @@ -123,12 +127,17 @@ const fetchWithHeaders = async ( // Filter out default headers from custom headers const customHeaders = Object.fromEntries( - Object.entries(options.headers).filter(([key]) => !Object.keys(defaultHeaders).some(defaultKey => defaultKey.toLowerCase() === key.toLowerCase())) + Object.entries(options.headers).filter( + ([key]) => + !Object.keys(defaultHeaders).some( + (defaultKey) => defaultKey.toLowerCase() === key.toLowerCase(), + ), + ), ) options.headers = { ...defaultHeaders, - ...customHeaders + ...customHeaders, } return fetch(url, options) @@ -140,9 +149,13 @@ const fetchWithHeaders = async ( * @param host {string} - The host to fetch * @returns {Promise} - The fetch response */ -export const get = async (fetch: Fetch, host: string, options?: { headers?: HeadersInit }): Promise => { +export const get = async ( + fetch: Fetch, + host: string, + options?: { headers?: HeadersInit }, +): Promise => { const response = await fetchWithHeaders(fetch, host, { - headers: options?.headers + headers: options?.headers, }) await checkOk(response) @@ -176,7 +189,7 @@ export const post = async ( fetch: Fetch, host: string, data?: Record | BodyInit, - options?: { signal?: AbortSignal, headers?: HeadersInit }, + options?: { signal?: AbortSignal; headers?: HeadersInit }, ): Promise => { const isRecord = (input: any): input is Record => { return input !== null && typeof input === 'object' && !Array.isArray(input) @@ -188,7 +201,7 @@ export const post = async ( method: 'POST', body: formattedData, signal: options?.signal, - headers: options?.headers + headers: options?.headers, }) await checkOk(response) @@ -211,7 +224,7 @@ export const del = async ( const response = await fetchWithHeaders(fetch, host, { method: 'DELETE', body: JSON.stringify(data), - headers: options?.headers + headers: options?.headers, }) await checkOk(response) diff --git a/tsconfig.json b/tsconfig.json index 327ed39..667d872 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,11 +13,7 @@ "module": "ES2022", "outDir": "./dist", "target": "ES6", - "lib": [ - "es6", - "es2018.asyncgenerator", - "dom" - ] + "lib": ["es6", "es2018.asyncgenerator", "dom"], }, "ts-node": {