Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/components/nodes/chains/LLMChain/LLMChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class LLMChain_Chains implements INode {
{
label: 'Output Prediction',
name: 'outputPrediction',
baseClasses: ['string']
baseClasses: ['string', 'json']
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ class ChatPromptTemplate_Prompts implements INode {
{
label: 'Format Prompt Values',
name: 'promptValues',
type: 'string',
rows: 4,
placeholder: `{
"input_language": "English",
"output_language": "French"
}`,
type: 'json',
optional: true,
acceptVariable: true,
list: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ class PromptTemplate_Prompts implements INode {
{
label: 'Format Prompt Values',
name: 'promptValues',
type: 'string',
rows: 4,
placeholder: `{
"input_language": "English",
"output_language": "French"
}`,
type: 'json',
optional: true,
acceptVariable: true,
list: true
Expand Down
41 changes: 0 additions & 41 deletions packages/components/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,47 +245,6 @@ export class CustomChainHandler extends BaseCallbackHandler {
}
}

export const returnJSONStr = (jsonStr: string): string => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chungyau97 removing these since they are not being used anymore

let jsonStrArray = jsonStr.split(':')

let wholeString = ''
for (let i = 0; i < jsonStrArray.length; i++) {
if (jsonStrArray[i].includes(',') && jsonStrArray[i + 1] !== undefined) {
const splitValueAndTitle = jsonStrArray[i].split(',')
const value = splitValueAndTitle[0]
const newTitle = splitValueAndTitle[1]
wholeString += handleEscapeDoubleQuote(value) + ',' + newTitle + ':'
} else {
wholeString += wholeString === '' ? jsonStrArray[i] + ':' : handleEscapeDoubleQuote(jsonStrArray[i])
}
}
return wholeString
}

const handleEscapeDoubleQuote = (value: string): string => {
let newValue = ''
if (value.includes('"')) {
const valueArray = value.split('"')
for (let i = 0; i < valueArray.length; i++) {
if ((i + 1) % 2 !== 0) {
switch (valueArray[i]) {
case '':
newValue += '"'
break
case '}':
newValue += '"}'
break
default:
newValue += '\\"' + valueArray[i] + '\\"'
}
} else {
newValue += valueArray[i]
}
}
}
return newValue === '' ? value : newValue
}

export const availableDependencies = [
'@dqbd/tiktoken',
'@getzep/zep-js',
Expand Down
154 changes: 76 additions & 78 deletions packages/server/marketplaces/Antonym.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,7 @@
"nodes": [
{
"width": 300,
"height": 534,
"id": "promptTemplate_1",
"position": {
"x": 532.2791692529131,
"y": -31.128527027841372
},
"type": "customNode",
"data": {
"id": "promptTemplate_1",
"label": "Prompt Template",
"name": "promptTemplate",
"type": "PromptTemplate",
"baseClasses": ["PromptTemplate", "BaseStringPromptTemplate", "BasePromptTemplate"],
"category": "Prompts",
"description": "Schema to represent a basic prompt for an LLM",
"inputParams": [
{
"label": "Template",
"name": "template",
"type": "string",
"rows": 4,
"placeholder": "What is a good name for a company that makes {product}?",
"id": "promptTemplate_1-input-template-string"
},
{
"label": "Format Prompt Values",
"name": "promptValues",
"type": "string",
"rows": 4,
"placeholder": "{\n \"input_language\": \"English\",\n \"output_language\": \"French\"\n}",
"optional": true,
"acceptVariable": true,
"list": true,
"id": "promptTemplate_1-input-promptValues-string"
}
],
"inputAnchors": [],
"inputs": {
"template": "Word: {word}\\nAntonym: {antonym}\\n",
"promptValues": ""
},
"outputAnchors": [
{
"id": "promptTemplate_1-output-promptTemplate-PromptTemplate|BaseStringPromptTemplate|BasePromptTemplate",
"name": "promptTemplate",
"label": "PromptTemplate",
"type": "PromptTemplate | BaseStringPromptTemplate | BasePromptTemplate"
}
],
"outputs": {},
"selected": false
},
"selected": false,
"positionAbsolute": {
"x": 532.2791692529131,
"y": -31.128527027841372
},
"dragging": false
},
{
"width": 300,
"height": 956,
"height": 955,
"id": "fewShotPromptTemplate_1",
"position": {
"x": 886.3229032369354,
Expand Down Expand Up @@ -139,7 +78,7 @@
],
"inputs": {
"examples": "[\n { \"word\": \"happy\", \"antonym\": \"sad\" },\n { \"word\": \"tall\", \"antonym\": \"short\" }\n]",
"examplePrompt": "{{promptTemplate_1.data.instance}}",
"examplePrompt": "{{promptTemplate_0.data.instance}}",
"prefix": "Give the antonym of every input",
"suffix": "Word: {input}\\nAntonym:",
"exampleSeparator": "\\n\\n",
Expand All @@ -165,7 +104,7 @@
},
{
"width": 300,
"height": 526,
"height": 524,
"id": "openAI_1",
"position": {
"x": 1224.5139327142097,
Expand Down Expand Up @@ -318,7 +257,7 @@
},
{
"width": 300,
"height": 407,
"height": 405,
"id": "llmChain_1",
"position": {
"x": 1635.363191180743,
Expand Down Expand Up @@ -375,10 +314,10 @@
"type": "LLMChain | BaseChain | BaseLangChain"
},
{
"id": "llmChain_1-output-outputPrediction-string",
"id": "llmChain_1-output-outputPrediction-string|json",
"name": "outputPrediction",
"label": "Output Prediction",
"type": "string"
"type": "string | json"
}
],
"default": "llmChain"
Expand All @@ -395,20 +334,68 @@
},
"selected": false,
"dragging": false
},
{
"width": 300,
"height": 475,
"id": "promptTemplate_0",
"position": {
"x": 540.0140796251119,
"y": -33.31673494170347
},
"type": "customNode",
"data": {
"id": "promptTemplate_0",
"label": "Prompt Template",
"name": "promptTemplate",
"type": "PromptTemplate",
"baseClasses": ["PromptTemplate", "BaseStringPromptTemplate", "BasePromptTemplate"],
"category": "Prompts",
"description": "Schema to represent a basic prompt for an LLM",
"inputParams": [
{
"label": "Template",
"name": "template",
"type": "string",
"rows": 4,
"placeholder": "What is a good name for a company that makes {product}?",
"id": "promptTemplate_0-input-template-string"
},
{
"label": "Format Prompt Values",
"name": "promptValues",
"type": "json",
"optional": true,
"acceptVariable": true,
"list": true,
"id": "promptTemplate_0-input-promptValues-json"
}
],
"inputAnchors": [],
"inputs": {
"template": "Word: {word}\\nAntonym: {antonym}\\n",
"promptValues": ""
},
"outputAnchors": [
{
"id": "promptTemplate_0-output-promptTemplate-PromptTemplate|BaseStringPromptTemplate|BasePromptTemplate",
"name": "promptTemplate",
"label": "PromptTemplate",
"type": "PromptTemplate | BaseStringPromptTemplate | BasePromptTemplate"
}
],
"outputs": {},
"selected": false
},
"selected": false,
"positionAbsolute": {
"x": 540.0140796251119,
"y": -33.31673494170347
},
"dragging": false
}
],
"edges": [
{
"source": "promptTemplate_1",
"sourceHandle": "promptTemplate_1-output-promptTemplate-PromptTemplate|BaseStringPromptTemplate|BasePromptTemplate",
"target": "fewShotPromptTemplate_1",
"targetHandle": "fewShotPromptTemplate_1-input-examplePrompt-PromptTemplate",
"type": "buttonedge",
"id": "promptTemplate_1-promptTemplate_1-output-promptTemplate-PromptTemplate|BaseStringPromptTemplate|BasePromptTemplate-fewShotPromptTemplate_1-fewShotPromptTemplate_1-input-examplePrompt-PromptTemplate",
"data": {
"label": ""
}
},
{
"source": "openAI_1",
"sourceHandle": "openAI_1-output-openAI-OpenAI|BaseLLM|BaseLanguageModel|BaseLangChain",
Expand All @@ -430,6 +417,17 @@
"data": {
"label": ""
}
},
{
"source": "promptTemplate_0",
"sourceHandle": "promptTemplate_0-output-promptTemplate-PromptTemplate|BaseStringPromptTemplate|BasePromptTemplate",
"target": "fewShotPromptTemplate_1",
"targetHandle": "fewShotPromptTemplate_1-input-examplePrompt-PromptTemplate",
"type": "buttonedge",
"id": "promptTemplate_0-promptTemplate_0-output-promptTemplate-PromptTemplate|BaseStringPromptTemplate|BasePromptTemplate-fewShotPromptTemplate_1-fewShotPromptTemplate_1-input-examplePrompt-PromptTemplate",
"data": {
"label": ""
}
}
]
}
Loading