Skip to content

Commit cf568de

Browse files
isJsonObject added
1 parent b2083cb commit cf568de

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tiny-ai-api",
33
"description": "A customizable and extensible client api for managing conversations and AI interactions, currently supporting the **Google Gemini** API — with flexibility to support any similar AI APIs.",
4-
"version": "1.1.6",
4+
"version": "1.1.7",
55
"main": "./dist/index.cjs",
66
"module": "./dist/index.mjs",
77
"types": "./dist/index.d.mts",

src/TinyAiInstance.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import objHash from 'object-hash';
22
import { EventEmitter } from 'events';
3-
import { objType } from 'tiny-essentials';
3+
import { isJsonObject, objType } from 'tiny-essentials';
44

55
/**
66
* Tiny AI Server Communication API
@@ -393,7 +393,7 @@ class TinyAiInstance {
393393
// Validate the custom value
394394
const props = history.customList.find((/** @type {*} */ item) => item.name === name);
395395
if (
396-
objType(props, 'object') &&
396+
isJsonObject(props) &&
397397
typeof props.type === 'string' &&
398398
typeof props.name === 'string'
399399
) {
@@ -839,7 +839,7 @@ class TinyAiInstance {
839839
* @returns {Record<string, any>|null} The inserted model data, or null if the model already exists.
840840
*/
841841
_insertNewModel(model) {
842-
if (!objType(model, 'object')) throw new Error('Model data must be a valid object.');
842+
if (!isJsonObject(model)) throw new Error('Model data must be a valid object.');
843843

844844
if (this.models.findIndex((item) => item.id === model.id) < 0) {
845845
/** @type {Record<string, any>} */
@@ -962,7 +962,7 @@ class TinyAiInstance {
962962
if (errData) {
963963
if (typeof errData === 'string') return { text: errData };
964964
// @ts-ignore
965-
else if (objType(errData, 'object') && typeof errData.text === 'string') return errData;
965+
else if (isJsonObject(errData) && typeof errData.text === 'string') return errData;
966966
}
967967
}
968968
return null;
@@ -1331,7 +1331,7 @@ class TinyAiInstance {
13311331
this.history[selectedId].nextId++;
13321332
const hash = objHash(data);
13331333

1334-
const tokenContent = objType(tokenData, 'object')
1334+
const tokenContent = isJsonObject(tokenData)
13351335
? tokenData
13361336
: { count: typeof tokenData === 'number' ? tokenData : null };
13371337

0 commit comments

Comments
 (0)