Parse Data is giving error while calling it from js api #5590
Replies: 1 comment 1 reply
-
The error you're encountering, "string indices must be integers, not 'str'," suggests that the template in your In your template, you're using expressions like Here are a few steps to troubleshoot and resolve the issue:
By verifying these aspects, you should be able to identify and correct the mismatch causing the error. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Beta Was this translation helpful? Give feedback.
-
I am build this flow when i run it in playground it works fine but when i call it through my api i get this error
Error: {detail: {"message":"Error running graph: Error building Component Parse Data: \\n\\nstring indices must be integers, not 'str'","traceback":null,"description":null,"code":null,"suggestion":null}
}`
Data that i am parsing:
[ { "type": "reel", "total_likes": 340, "total_shares": 110, "total_comments": 95 }, { "type": "carousel", "total_likes": 120, "total_shares": 30, "total_comments": 20 }, { "type": "static", "total_likes": 490, "total_shares": 60, "total_comments": 15 } ]
JS Code: import axios from "axios";
import dotenv from "dotenv";
dotenv.config({
path: "../../.env",
});
export const runLangFlow = async () => {
const url =
"https://api.langflow.astra.datastax.com/lf/6f5d319d-0f28-4d22-bbee-a976d981680d/api/v1/run/f268c20a-a94f-484a-96d9-23b8f115c0ac?stream=false";
const token = process.env.LANGFLOW_TOKEN;
const inputValue = "static";
const payload = {
input_value: inputValue,
output_type: "chat",
input_type: "chat",
tweaks: {
"APIRequest-NPp4t": {},
"ParseData-qPubJ": {
sep: "\n",
template:
Reel Like: {result[0][total_likes]}\n Reel Shares: {result[0][total_shares]}\n Reel Comments: {result[0][total_comments]}\n Carousel Like: {result[1][total_likes]}\n Carousel Shares: {result[1][total_shares]}\n Carousel Comments: {result[1][total_comments]}\n Static Like: {result[2][total_likes]}\n Static Shares: {result[2][total_shares]}\n Static Comments: {result[2][total_comments]}\n
},
"Prompt-r82pU": {},
"ChatInput-AwsLA": {},
"ChatOutput-pqVuM": {},
"GroqModel-vKAET": {},
},
};
try {
const response = await axios.post(url, payload, {
headers: {
"Content-Type": "application/json",
Authorization:
Bearer ${token}
,},
});
} catch (error) {
console.error("Error:", error.response?.data || error.message);
throw new Error("Failed to fetch data from LangFlow API");
}
};
Beta Was this translation helpful? Give feedback.
All reactions