From b454083eaf37cb379ff66688eebee1cbe420b45c Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Tue, 25 Jul 2023 23:53:42 +0800 Subject: [PATCH 1/2] change parseInt to parseFloat --- packages/components/nodes/chatmodels/ChatOpenAI/ChatOpenAI.ts | 2 +- packages/components/nodes/llms/OpenAI/OpenAI.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/components/nodes/chatmodels/ChatOpenAI/ChatOpenAI.ts b/packages/components/nodes/chatmodels/ChatOpenAI/ChatOpenAI.ts index 955563f..bd9080c 100644 --- a/packages/components/nodes/chatmodels/ChatOpenAI/ChatOpenAI.ts +++ b/packages/components/nodes/chatmodels/ChatOpenAI/ChatOpenAI.ts @@ -139,7 +139,7 @@ class ChatOpenAI_ChatModels implements INode { } if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10) - if (topP) obj.topP = parseInt(topP, 10) + if (topP) obj.topP = parseFloat(topP) if (frequencyPenalty) obj.frequencyPenalty = parseInt(frequencyPenalty, 10) if (presencePenalty) obj.presencePenalty = parseInt(presencePenalty, 10) if (timeout) obj.timeout = parseInt(timeout, 10) diff --git a/packages/components/nodes/llms/OpenAI/OpenAI.ts b/packages/components/nodes/llms/OpenAI/OpenAI.ts index b0af867..1bf7486 100644 --- a/packages/components/nodes/llms/OpenAI/OpenAI.ts +++ b/packages/components/nodes/llms/OpenAI/OpenAI.ts @@ -139,7 +139,7 @@ class OpenAI_LLMs implements INode { } if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10) - if (topP) obj.topP = parseInt(topP, 10) + if (topP) obj.topP = parseFloat(topP) if (frequencyPenalty) obj.frequencyPenalty = parseInt(frequencyPenalty, 10) if (presencePenalty) obj.presencePenalty = parseInt(presencePenalty, 10) if (timeout) obj.timeout = parseInt(timeout, 10) From 2ad873c34fd24242bd9be9dfd72e14a71a36af4d Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Wed, 26 Jul 2023 01:13:16 +0800 Subject: [PATCH 2/2] modify parse for topP and topK --- .../nodes/chatmodels/ChatAnthropic/ChatAnthropic.ts | 4 ++-- .../nodes/chatmodels/ChatHuggingFace/ChatHuggingFace.ts | 4 ++-- .../components/nodes/chatmodels/ChatLocalAI/ChatLocalAI.ts | 2 +- packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts | 2 +- .../nodes/llms/HuggingFaceInference/HuggingFaceInference.ts | 4 ++-- .../nodes/vectorstores/Chroma_Existing/Chroma_Existing.ts | 2 +- .../nodes/vectorstores/Chroma_Upsert/Chroma_Upsert.ts | 2 +- .../nodes/vectorstores/Faiss_Existing/Faiss_Existing.ts | 2 +- .../nodes/vectorstores/Faiss_Upsert/Faiss_Upsert.ts | 2 +- .../nodes/vectorstores/InMemory/InMemoryVectorStore.ts | 2 +- .../vectorstores/OpenSearch_Existing/OpenSearch_existing.ts | 2 +- .../nodes/vectorstores/OpenSearch_Upsert/OpenSearch_Upsert.ts | 2 +- .../nodes/vectorstores/Pinecone_Existing/Pinecone_Existing.ts | 2 +- .../nodes/vectorstores/Pinecone_Upsert/Pinecone_Upsert.ts | 2 +- .../nodes/vectorstores/Qdrant_Existing/Qdrant_Existing.ts | 2 +- .../nodes/vectorstores/Qdrant_Upsert/Qdrant_Upsert.ts | 2 +- .../vectorstores/Singlestore_Existing/Singlestore_Existing.ts | 2 +- .../vectorstores/Singlestore_Upsert/Singlestore_Upsert.ts | 2 +- .../vectorstores/Supabase_Existing/Supabase_Exisiting.ts | 2 +- .../nodes/vectorstores/Supabase_Upsert/Supabase_Upsert.ts | 2 +- .../nodes/vectorstores/Weaviate_Existing/Weaviate_Existing.ts | 2 +- .../nodes/vectorstores/Weaviate_Upsert/Weaviate_Upsert.ts | 2 +- 22 files changed, 25 insertions(+), 25 deletions(-) diff --git a/packages/components/nodes/chatmodels/ChatAnthropic/ChatAnthropic.ts b/packages/components/nodes/chatmodels/ChatAnthropic/ChatAnthropic.ts index b65c7bd..6334345 100644 --- a/packages/components/nodes/chatmodels/ChatAnthropic/ChatAnthropic.ts +++ b/packages/components/nodes/chatmodels/ChatAnthropic/ChatAnthropic.ts @@ -137,8 +137,8 @@ class ChatAnthropic_ChatModels implements INode { } if (maxTokensToSample) obj.maxTokensToSample = parseInt(maxTokensToSample, 10) - if (topP) obj.topP = parseInt(topP, 10) - if (topK) obj.topK = parseInt(topK, 10) + if (topP) obj.topP = parseFloat(topP) + if (topK) obj.topK = parseFloat(topK) const model = new ChatAnthropic(obj) return model diff --git a/packages/components/nodes/chatmodels/ChatHuggingFace/ChatHuggingFace.ts b/packages/components/nodes/chatmodels/ChatHuggingFace/ChatHuggingFace.ts index d92dd1e..943af58 100644 --- a/packages/components/nodes/chatmodels/ChatHuggingFace/ChatHuggingFace.ts +++ b/packages/components/nodes/chatmodels/ChatHuggingFace/ChatHuggingFace.ts @@ -101,8 +101,8 @@ class ChatHuggingFace_ChatModels implements INode { if (temperature) obj.temperature = parseFloat(temperature) if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10) - if (topP) obj.topP = parseInt(topP, 10) - if (hfTopK) obj.topK = parseInt(hfTopK, 10) + if (topP) obj.topP = parseFloat(topP) + if (hfTopK) obj.topK = parseFloat(hfTopK) if (frequencyPenalty) obj.frequencyPenalty = parseInt(frequencyPenalty, 10) if (endpoint) obj.endpoint = endpoint diff --git a/packages/components/nodes/chatmodels/ChatLocalAI/ChatLocalAI.ts b/packages/components/nodes/chatmodels/ChatLocalAI/ChatLocalAI.ts index c5860b2..ffe2e76 100644 --- a/packages/components/nodes/chatmodels/ChatLocalAI/ChatLocalAI.ts +++ b/packages/components/nodes/chatmodels/ChatLocalAI/ChatLocalAI.ts @@ -80,7 +80,7 @@ class ChatLocalAI_ChatModels implements INode { } if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10) - if (topP) obj.topP = parseInt(topP, 10) + if (topP) obj.topP = parseFloat(topP) if (timeout) obj.timeout = parseInt(timeout, 10) const model = new OpenAIChat(obj, { basePath }) diff --git a/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts b/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts index 130eed3..263dbe3 100644 --- a/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts +++ b/packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts @@ -181,7 +181,7 @@ class AzureOpenAI_LLMs implements INode { } if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10) - if (topP) obj.topP = parseInt(topP, 10) + if (topP) obj.topP = parseFloat(topP) if (frequencyPenalty) obj.frequencyPenalty = parseInt(frequencyPenalty, 10) if (presencePenalty) obj.presencePenalty = parseInt(presencePenalty, 10) if (timeout) obj.timeout = parseInt(timeout, 10) diff --git a/packages/components/nodes/llms/HuggingFaceInference/HuggingFaceInference.ts b/packages/components/nodes/llms/HuggingFaceInference/HuggingFaceInference.ts index 92eb46d..33eedf2 100644 --- a/packages/components/nodes/llms/HuggingFaceInference/HuggingFaceInference.ts +++ b/packages/components/nodes/llms/HuggingFaceInference/HuggingFaceInference.ts @@ -101,8 +101,8 @@ class HuggingFaceInference_LLMs implements INode { if (temperature) obj.temperature = parseFloat(temperature) if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10) - if (topP) obj.topP = parseInt(topP, 10) - if (hfTopK) obj.topK = parseInt(hfTopK, 10) + if (topP) obj.topP = parseFloat(topP) + if (hfTopK) obj.topK = parseFloat(hfTopK) if (frequencyPenalty) obj.frequencyPenalty = parseInt(frequencyPenalty, 10) if (endpoint) obj.endpoint = endpoint diff --git a/packages/components/nodes/vectorstores/Chroma_Existing/Chroma_Existing.ts b/packages/components/nodes/vectorstores/Chroma_Existing/Chroma_Existing.ts index 3ce93e8..e5dfe03 100644 --- a/packages/components/nodes/vectorstores/Chroma_Existing/Chroma_Existing.ts +++ b/packages/components/nodes/vectorstores/Chroma_Existing/Chroma_Existing.ts @@ -69,7 +69,7 @@ class Chroma_Existing_VectorStores implements INode { const chromaURL = nodeData.inputs?.chromaURL as string const output = nodeData.outputs?.output as string const topK = nodeData.inputs?.topK as string - const k = topK ? parseInt(topK, 10) : 4 + const k = topK ? parseFloat(topK) : 4 const obj: { collectionName: string diff --git a/packages/components/nodes/vectorstores/Chroma_Upsert/Chroma_Upsert.ts b/packages/components/nodes/vectorstores/Chroma_Upsert/Chroma_Upsert.ts index f32fbb6..26f3c22 100644 --- a/packages/components/nodes/vectorstores/Chroma_Upsert/Chroma_Upsert.ts +++ b/packages/components/nodes/vectorstores/Chroma_Upsert/Chroma_Upsert.ts @@ -78,7 +78,7 @@ class ChromaUpsert_VectorStores implements INode { const chromaURL = nodeData.inputs?.chromaURL as string const output = nodeData.outputs?.output as string const topK = nodeData.inputs?.topK as string - const k = topK ? parseInt(topK, 10) : 4 + const k = topK ? parseFloat(topK) : 4 const flattenDocs = docs && docs.length ? flatten(docs) : [] const finalDocs = [] diff --git a/packages/components/nodes/vectorstores/Faiss_Existing/Faiss_Existing.ts b/packages/components/nodes/vectorstores/Faiss_Existing/Faiss_Existing.ts index 6dd1859..f303030 100644 --- a/packages/components/nodes/vectorstores/Faiss_Existing/Faiss_Existing.ts +++ b/packages/components/nodes/vectorstores/Faiss_Existing/Faiss_Existing.ts @@ -64,7 +64,7 @@ class Faiss_Existing_VectorStores implements INode { const basePath = nodeData.inputs?.basePath as string const output = nodeData.outputs?.output as string const topK = nodeData.inputs?.topK as string - const k = topK ? parseInt(topK, 10) : 4 + const k = topK ? parseFloat(topK) : 4 const vectorStore = await FaissStore.load(basePath, embeddings) diff --git a/packages/components/nodes/vectorstores/Faiss_Upsert/Faiss_Upsert.ts b/packages/components/nodes/vectorstores/Faiss_Upsert/Faiss_Upsert.ts index 5e5f902..e0fd9a5 100644 --- a/packages/components/nodes/vectorstores/Faiss_Upsert/Faiss_Upsert.ts +++ b/packages/components/nodes/vectorstores/Faiss_Upsert/Faiss_Upsert.ts @@ -73,7 +73,7 @@ class FaissUpsert_VectorStores implements INode { const output = nodeData.outputs?.output as string const basePath = nodeData.inputs?.basePath as string const topK = nodeData.inputs?.topK as string - const k = topK ? parseInt(topK, 10) : 4 + const k = topK ? parseFloat(topK) : 4 const flattenDocs = docs && docs.length ? flatten(docs) : [] const finalDocs = [] diff --git a/packages/components/nodes/vectorstores/InMemory/InMemoryVectorStore.ts b/packages/components/nodes/vectorstores/InMemory/InMemoryVectorStore.ts index 32a785a..ac6ed0b 100644 --- a/packages/components/nodes/vectorstores/InMemory/InMemoryVectorStore.ts +++ b/packages/components/nodes/vectorstores/InMemory/InMemoryVectorStore.ts @@ -64,7 +64,7 @@ class InMemoryVectorStore_VectorStores implements INode { const embeddings = nodeData.inputs?.embeddings as Embeddings const output = nodeData.outputs?.output as string const topK = nodeData.inputs?.topK as string - const k = topK ? parseInt(topK, 10) : 4 + const k = topK ? parseFloat(topK) : 4 const flattenDocs = docs && docs.length ? flatten(docs) : [] const finalDocs = [] diff --git a/packages/components/nodes/vectorstores/OpenSearch_Existing/OpenSearch_existing.ts b/packages/components/nodes/vectorstores/OpenSearch_Existing/OpenSearch_existing.ts index 7aeac91..e0f05aa 100644 --- a/packages/components/nodes/vectorstores/OpenSearch_Existing/OpenSearch_existing.ts +++ b/packages/components/nodes/vectorstores/OpenSearch_Existing/OpenSearch_existing.ts @@ -70,7 +70,7 @@ class OpenSearch_Existing_VectorStores implements INode { const indexName = nodeData.inputs?.indexName as string const output = nodeData.outputs?.output as string const topK = nodeData.inputs?.topK as string - const k = topK ? parseInt(topK, 10) : 4 + const k = topK ? parseFloat(topK) : 4 const client = new Client({ nodes: [opensearchURL] diff --git a/packages/components/nodes/vectorstores/OpenSearch_Upsert/OpenSearch_Upsert.ts b/packages/components/nodes/vectorstores/OpenSearch_Upsert/OpenSearch_Upsert.ts index 8d54392..c225f74 100644 --- a/packages/components/nodes/vectorstores/OpenSearch_Upsert/OpenSearch_Upsert.ts +++ b/packages/components/nodes/vectorstores/OpenSearch_Upsert/OpenSearch_Upsert.ts @@ -79,7 +79,7 @@ class OpenSearchUpsert_VectorStores implements INode { const indexName = nodeData.inputs?.indexName as string const output = nodeData.outputs?.output as string const topK = nodeData.inputs?.topK as string - const k = topK ? parseInt(topK, 10) : 4 + const k = topK ? parseFloat(topK) : 4 const flattenDocs = docs && docs.length ? flatten(docs) : [] const finalDocs = [] diff --git a/packages/components/nodes/vectorstores/Pinecone_Existing/Pinecone_Existing.ts b/packages/components/nodes/vectorstores/Pinecone_Existing/Pinecone_Existing.ts index e57da39..39e9f44 100644 --- a/packages/components/nodes/vectorstores/Pinecone_Existing/Pinecone_Existing.ts +++ b/packages/components/nodes/vectorstores/Pinecone_Existing/Pinecone_Existing.ts @@ -92,7 +92,7 @@ class Pinecone_Existing_VectorStores implements INode { const embeddings = nodeData.inputs?.embeddings as Embeddings const output = nodeData.outputs?.output as string const topK = nodeData.inputs?.topK as string - const k = topK ? parseInt(topK, 10) : 4 + const k = topK ? parseFloat(topK) : 4 const client = new PineconeClient() await client.init({ diff --git a/packages/components/nodes/vectorstores/Pinecone_Upsert/Pinecone_Upsert.ts b/packages/components/nodes/vectorstores/Pinecone_Upsert/Pinecone_Upsert.ts index ad1767c..136ccec 100644 --- a/packages/components/nodes/vectorstores/Pinecone_Upsert/Pinecone_Upsert.ts +++ b/packages/components/nodes/vectorstores/Pinecone_Upsert/Pinecone_Upsert.ts @@ -93,7 +93,7 @@ class PineconeUpsert_VectorStores implements INode { const embeddings = nodeData.inputs?.embeddings as Embeddings const output = nodeData.outputs?.output as string const topK = nodeData.inputs?.topK as string - const k = topK ? parseInt(topK, 10) : 4 + const k = topK ? parseFloat(topK) : 4 const client = new PineconeClient() await client.init({ diff --git a/packages/components/nodes/vectorstores/Qdrant_Existing/Qdrant_Existing.ts b/packages/components/nodes/vectorstores/Qdrant_Existing/Qdrant_Existing.ts index f1eef8f..2dea972 100644 --- a/packages/components/nodes/vectorstores/Qdrant_Existing/Qdrant_Existing.ts +++ b/packages/components/nodes/vectorstores/Qdrant_Existing/Qdrant_Existing.ts @@ -85,7 +85,7 @@ class Qdrant_Existing_VectorStores implements INode { const embeddings = nodeData.inputs?.embeddings as Embeddings const output = nodeData.outputs?.output as string const topK = nodeData.inputs?.topK as string - const k = topK ? parseInt(topK, 10) : 4 + const k = topK ? parseFloat(topK) : 4 // connect to Qdrant Cloud const client = new QdrantClient({ diff --git a/packages/components/nodes/vectorstores/Qdrant_Upsert/Qdrant_Upsert.ts b/packages/components/nodes/vectorstores/Qdrant_Upsert/Qdrant_Upsert.ts index dae1d31..4f1ce91 100644 --- a/packages/components/nodes/vectorstores/Qdrant_Upsert/Qdrant_Upsert.ts +++ b/packages/components/nodes/vectorstores/Qdrant_Upsert/Qdrant_Upsert.ts @@ -86,7 +86,7 @@ class QdrantUpsert_VectorStores implements INode { const embeddings = nodeData.inputs?.embeddings as Embeddings const output = nodeData.outputs?.output as string const topK = nodeData.inputs?.topK as string - const k = topK ? parseInt(topK, 10) : 4 + const k = topK ? parseFloat(topK) : 4 // connect to Qdrant Cloud const client = new QdrantClient({ diff --git a/packages/components/nodes/vectorstores/Singlestore_Existing/Singlestore_Existing.ts b/packages/components/nodes/vectorstores/Singlestore_Existing/Singlestore_Existing.ts index 1b37a40..25be06e 100644 --- a/packages/components/nodes/vectorstores/Singlestore_Existing/Singlestore_Existing.ts +++ b/packages/components/nodes/vectorstores/Singlestore_Existing/Singlestore_Existing.ts @@ -121,7 +121,7 @@ class SingleStoreExisting_VectorStores implements INode { const embeddings = nodeData.inputs?.embeddings as Embeddings const output = nodeData.outputs?.output as string const topK = nodeData.inputs?.topK as string - const k = topK ? parseInt(topK, 10) : 4 + const k = topK ? parseFloat(topK) : 4 let vectorStore: SingleStoreVectorStore diff --git a/packages/components/nodes/vectorstores/Singlestore_Upsert/Singlestore_Upsert.ts b/packages/components/nodes/vectorstores/Singlestore_Upsert/Singlestore_Upsert.ts index eb00381..8847552 100644 --- a/packages/components/nodes/vectorstores/Singlestore_Upsert/Singlestore_Upsert.ts +++ b/packages/components/nodes/vectorstores/Singlestore_Upsert/Singlestore_Upsert.ts @@ -130,7 +130,7 @@ class SingleStoreUpsert_VectorStores implements INode { const embeddings = nodeData.inputs?.embeddings as Embeddings const output = nodeData.outputs?.output as string const topK = nodeData.inputs?.topK as string - const k = topK ? parseInt(topK, 10) : 4 + const k = topK ? parseFloat(topK) : 4 const flattenDocs = docs && docs.length ? flatten(docs) : [] const finalDocs = [] diff --git a/packages/components/nodes/vectorstores/Supabase_Existing/Supabase_Exisiting.ts b/packages/components/nodes/vectorstores/Supabase_Existing/Supabase_Exisiting.ts index 173660c..08cf7ce 100644 --- a/packages/components/nodes/vectorstores/Supabase_Existing/Supabase_Exisiting.ts +++ b/packages/components/nodes/vectorstores/Supabase_Existing/Supabase_Exisiting.ts @@ -89,7 +89,7 @@ class Supabase_Existing_VectorStores implements INode { const supabaseMetadataFilter = nodeData.inputs?.supabaseMetadataFilter const output = nodeData.outputs?.output as string const topK = nodeData.inputs?.topK as string - const k = topK ? parseInt(topK, 10) : 4 + const k = topK ? parseFloat(topK) : 4 const client = createClient(supabaseProjUrl, supabaseApiKey) diff --git a/packages/components/nodes/vectorstores/Supabase_Upsert/Supabase_Upsert.ts b/packages/components/nodes/vectorstores/Supabase_Upsert/Supabase_Upsert.ts index 69997a5..9239847 100644 --- a/packages/components/nodes/vectorstores/Supabase_Upsert/Supabase_Upsert.ts +++ b/packages/components/nodes/vectorstores/Supabase_Upsert/Supabase_Upsert.ts @@ -90,7 +90,7 @@ class SupabaseUpsert_VectorStores implements INode { const embeddings = nodeData.inputs?.embeddings as Embeddings const output = nodeData.outputs?.output as string const topK = nodeData.inputs?.topK as string - const k = topK ? parseInt(topK, 10) : 4 + const k = topK ? parseFloat(topK) : 4 const client = createClient(supabaseProjUrl, supabaseApiKey) diff --git a/packages/components/nodes/vectorstores/Weaviate_Existing/Weaviate_Existing.ts b/packages/components/nodes/vectorstores/Weaviate_Existing/Weaviate_Existing.ts index 595691b..0fa89e4 100644 --- a/packages/components/nodes/vectorstores/Weaviate_Existing/Weaviate_Existing.ts +++ b/packages/components/nodes/vectorstores/Weaviate_Existing/Weaviate_Existing.ts @@ -114,7 +114,7 @@ class Weaviate_Existing_VectorStores implements INode { const embeddings = nodeData.inputs?.embeddings as Embeddings const output = nodeData.outputs?.output as string const topK = nodeData.inputs?.topK as string - const k = topK ? parseInt(topK, 10) : 4 + const k = topK ? parseFloat(topK) : 4 const clientConfig: any = { scheme: weaviateScheme, diff --git a/packages/components/nodes/vectorstores/Weaviate_Upsert/Weaviate_Upsert.ts b/packages/components/nodes/vectorstores/Weaviate_Upsert/Weaviate_Upsert.ts index 0613742..9565d8a 100644 --- a/packages/components/nodes/vectorstores/Weaviate_Upsert/Weaviate_Upsert.ts +++ b/packages/components/nodes/vectorstores/Weaviate_Upsert/Weaviate_Upsert.ts @@ -123,7 +123,7 @@ class WeaviateUpsert_VectorStores implements INode { const embeddings = nodeData.inputs?.embeddings as Embeddings const output = nodeData.outputs?.output as string const topK = nodeData.inputs?.topK as string - const k = topK ? parseInt(topK, 10) : 4 + const k = topK ? parseFloat(topK) : 4 const clientConfig: any = { scheme: weaviateScheme,