From 2ad873c34fd24242bd9be9dfd72e14a71a36af4d Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Wed, 26 Jul 2023 01:13:16 +0800 Subject: [PATCH] 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 b65c7bd89..633434505 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 d92dd1e04..943af5879 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 c5860b242..ffe2e7692 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 130eed339..263dbe332 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 92eb46d50..33eedf2f5 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 3ce93e872..e5dfe03e1 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 f32fbb671..26f3c2228 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 6dd185948..f3030305e 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 5e5f9028c..e0fd9a525 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 32a785a5f..ac6ed0b2a 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 7aeac9192..e0f05aade 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 8d54392b0..c225f74ac 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 e57da3962..39e9f4414 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 ad1767c25..136ccec21 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 f1eef8f90..2dea97253 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 dae1d31d6..4f1ce91b1 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 1b37a4008..25be06e7b 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 eb00381d2..884755296 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 173660cae..08cf7ce48 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 69997a563..92398476c 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 595691bdc..0fa89e494 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 061374263..9565d8a2b 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,