Hi, we will now try to explore AI. Have anyone been able to send all the App’s data to Open AI and then asked Open AI to research the data sent? In other words, we plan to send a lot of data to Open AI and then ask Open AI to analyse it… As a live integration to the data seems to be impossible; could it be possible to download all data in a static file?
Hi,
The answer to this depends on the use case, and most of the answer is not directly related to Appfarm. There are many possibilties for this, depending on the amount of data, how often new data should be fed, how often you prompt etc. And also dependent on the amount of effort you want to put in.
In general, with regards to “sending all data to OpenAI”: Open AI received either text, images, or audio. And files (typically being transformed to text by OpenAI, so this is just a convenient “tool” provided to users by them).
If the data you are taking about is stored in Appfarm: For example a table of Products (with names, categories and prices), and a table of Order lines (with product references, amounts etc), and you want to automate this export, you may use the Export Data action node in Appfarm to export these as a CSV files, that may be sent to OpenAI Chat Completion endpoint together with the prompt.
For larger sets of data, I would consider an approach using file search / vector stores. This is built-in in OpenAI (Responses API and the File Search APIs. In this case, however, you must make sure to keep the file store up to date, so the approach is OK for data that does not change very often.
Another approach (not tested yet) for large and dynamic data sets may be to enable GraphQL endpoints on relevant object classes in Appfarm, and create a system instruction to OpenAI to generate GraphQL queries according to the table and property names, responding to the user need. This query may be fed into a web request such as described here. The result (relevant records) may then be fed to the chat completion API for the AI to analyze the relevant data according to the need/use case.
Thank you! We will as a starting point export all data tables as CSV files and prompt Open AI. Later we can try more advanced solutions.
Hi, I have created a File Object Class (openAIFileObjectClass) containg all CSV data. But seems like it is not transferred to Chat GDP. The Web Request Body Content contains this:
UPDATE: seems like this is the trick:
“file”: JSON.stringify(${openAIFileObjectClass})
This was a quick test. Anyway, I now get improvement suggestions from Open AI based on the data uploaded, but the responses are not accurate. So the conclusion is that Open AI is not able to fully understand the data model in the CSV file. I tried to help Open AI understand it by describing the model in words and I think this helps a little. So for now this is a problem.
Update: When switching from “gpt-3.5-turbo-1106” to “gpt-4-turbo” I get: “Please upload a valid CSV file to proceed with the analysis and recommendations.”
“The files are incorrectly referenced as JSON of ‘[object Object]’, which indicates a serialization error.”
Hi!
What your are trying to achieve is not supported in the API. You cannot send CSV files directly to the Chat Completion API. It is documented here.
I also see that you may have copied a bit “outdated” info from the guide in our documetation. The gpt-3.5-turbo is old. See the model guide here.
However: We have updated our guide now, and included some examples on how to proceed on some use cases regarding “Sending data to OpenAI”. Please read the following section:
PS: Regarding the conversion of CSV to string, that currently needs to be done using the function editor in Appfarm Create, but we have registered an internal challenge / feature request on that one to have it more explicit.
Good luck!
Thank you! Great advices and service.
To the forum: can anyone see what I do wrong here:
Open AI tells me that: “The provided dataset does not contain readable Goal, Challenge, or Task information. Please provide actual data for review.” Also it tells me “Ensure all imported data objects are legible and human-readable, not placeholders like [object Object].” “Add clear audit trails and visibility of imported data to enable traceability and accountability in the model.”
Change
“text”: CSVtoText(${…})
To
“text”: ${CSVtoText(…)}
You are not executing that function the way you have it in the screenshot. Should be as this:
${code returning some text here}
PS: just use ChatGPT og Gemini for such purposes - paste the code and ask the same question - it will locate the error immediately!
Hi Kristian, I did so. But still seems like there are no datasets sent to Open AI. Is there any fault with my function? Maybe I need to declare “projects” in any way?
Hi,
You have just written a javascript function within the appfarm function. You just need the “inside” of that javascript function, or to call that javascript function at the end. The appfarm function must return something, which it currently does not.
You may read more about functions here:
Hi, yes. I call the function:
${CSVtoText(…)} with the file objects as input (…). So there is something else that is wrong.
This return nothing found from Open AI: “0”
function CSVtoText(projects) {
// Creating a CSV representation of the data source “projects”
// “projects” has been added as a function parameter
if (!Array.isArray(projects) || projects.length === 0) return "";
// Collect all unique keys across all projects
const allKeys = Array.from(
new Set(projects.flatMap(project => Object.keys(project)))
);
// Create header row
const header = allKeys.join(";");
// Create data rows
const rows = projects.map(project => {
return allKeys.map(key => {
const value = project[key];
if (value === undefined || value === null) return '""';
if (typeof value === "string") return `"${value.replace(/"/g, '""')}"`;
return value;
}).join(";");
});
// Combine header and rows
return [header, ...rows].join("\n");
}
const system = `Act as a professional Objectives and Key Results (OKRs) framework and Enterprise Risk Manager expert.
First paragraph:
- Holds the exact title for the Goal, Challenge or Task.
Second paragraph:
- Holds the path of the improvement. For Challenge the path will an existing Goal. For a Task the path will be an existing Challenge.
Third paragraph:
- Holds the description of the improvement. Describe why this improvement is important.
- Maximum 200 characters
Give me the response in JSON format. The key should be “paragraphs” and each paragraph is represented
as a JSON object with 1 property: text.
Example:
{
“paragraphs”: [
{“text”: “the generated title / first paragraph”},
{“text”: “the generated second paragraph”},
{“text”: “the generated third paragraph”},
]
}
`
// Return the improvements in the 3-paragraph format as described in the system prompt.
// For sending CSV or other file formats, they must be converted to a string, and passed along with the prompt as a text message.
const userinput = `
Analyze the provided Goals, Challenges, and Tasks. For each improvement:
- Only propose improvements to existing Goals (do not invent new ones) one-by-one.
- Propose new Challenges (Key Results or Key Risks) under an existing Goal (do not invent new ones). Always reference the Goal by exact title from the data.
- Propose new or improved Tasks under an existing Challenge. Always reference the Challenge by exact title from the data.
- Clearly link each improvement to its existing parent (Goal or Challenge) using the titles found in the data.
- Do not suggest changes that cannot be grounded in the provided dataset.
- Verify that the Goal exist in the provided dataset.
Return the the number of Goals found in the datasets.
{
“type”: “text”,
“text”:
"The data model:
DELETED TO MAKE THE POST SMALLER
"
}
`
const datamodelinput1 = { "type": "text", "text": ${CSVtoText(openAIFileObjectClassGoals)} + "schemaName: Goals\n" }
const datamodelinput2 = { "type": "text", "text": ${CSVtoText(openAIFileObjectClassChallenges)} + "schemaName: Challenges\n" }
const datamodelinput3 = { "type": "text", "text": ${CSVtoText(openAIFileObjectClassTasks)} + "schemaName: Tasks\n" }
const datamodelinput4 = { "type": "text", "text": ${CSVtoText(openAIFileObjectClassTeams)} + "schemaName: Teams\n" }
const datamodelinput5 = { "type": "text", "text": ${CSVtoText(openAIFileObjectClassCheckIns)} + "schemaName: Check-ins\n" }
const datamodelinput6 = { "type": "text", "text": ${CSVtoText(openAIFileObjectClassChallengeRatingMatrix)} + "schemaName: ChallengeRatingMatrix\n" }
return {
“model”: “gpt-4.1”,
“messages”: [
{“role”: “system”, “content”: system},
{“role”: “user”, “content”: userinput},
{“role”: “user”, “content”: datamodelinput1},
{“role”: “user”, “content”: datamodelinput2},
{“role”: “user”, “content”: datamodelinput3},
{“role”: “user”, “content”: datamodelinput4},
{“role”: “user”, “content”: datamodelinput5},
{“role”: “user”, “content”: datamodelinput6},
] ,
“temperature”: 0.6,
“max_tokens”: 2000,
“top_p”: 1,
“frequency_penalty”: 0,
“presence_penalty”: 0,
“response_format”: { “type”: “json_object” }
}
Hi,
Not sure, you might want to try to copy that function into a “console log” action node or similar, and debug the code. I am no coder (no-coder)
Thank you, but someone in Appfarm created this guide on how to do the conversion of CSV to a string. Who can assist with more details on how to use this function?
Hi,
I just tested the function in the guide, and it works like it should. This function, where the data source “projects” has been added as function parmeters, takes all entries in the projects data source and returns it as a CSV string:
Takk så mye. Forsår at konverteringsfunksjonen må flyttes ut og kjøre på objektet. Har defor prøvd dette men får ikke data inn i CSVtoText. Mulig jeg må kontakte Anna da
Hi!
One thing I quickly noticed. In that function, where you’ve added “projects,” the example expects “projects” to be a data source with cardinality “Many” (i.e., a list of objects—in other words, the rows that should be converted to CSV). Based on the screenshot, you’ve added a data source with cardinality One (“Open AI FOC Goals” has cardinality One, meaning it can only hold one object and is not a list of objects).
Takk så mye! Nå får jeg data inn i CVStoText. Så nærmer meg endelig løsning nå.
Hi, can I ask where the Function is called from in the appfarm Open AI demo solution? Also what is the definition of the data-source Projects?