If you clicked on this post, you might already know that Open AI released GPT 4 and an optimized version of GPT3.5. Excited about the new version, I ran several experiments where I tested ChatGPT and Mule 4. In the experiment, I found that ChatGPT was on its way to building Mule applications that relied on HTTP listeners with ease. However, was ChatGPT aware of the SFTP connector? Could it build SFTP integrations with ease? That was the question.
This post details my SFTP integration experiment for the GPT-4 large language model (LLM).
ChatGPT+ Mule 4 SFTP Integration Experiment
Below is my prompt, the ChatGPT result, the code, and my observations. Feel free to copy the code and reuse the code for your code analysis.
My SFTP Integration Prompt
Curious if ChatGPT could make an SFTP integration, I fed the Chat Bot this prompt:
Mule 4 code to enable CSV streaming on an SFTP connector. Although this prompt is very generic. I wanted to test ChatGPTs ability to
Write Mule 4 code
Read a file from an SFTP
ChatGPT SFTP Integration Results
Code Snippet 1
<dependency> <groupId>org.mule.connectors</groupId> <artifactId>mule-sftp-connector</artifactId> <version>1.4.0</version> </dependency>
Code Snippet 2
<?xml version="1.0" encoding="UTF-8"?> <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sftp="http://www.mulesoft.org/schema/mule/sftp" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xsi:schemaLocation=" http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd"> <sftp:config name="SFTP_Config" doc:name="SFTP Config"> <sftp:connection host="your_host" port="your_port" username="your_username" password="your_password" /> </sftp:config> <flow name="CSVStreamingFlow" > <file:read config-ref="SFTP_Config" path="path/to/your/file.csv" outputMimeType="application/csv; streaming=true" /> <ee:transform doc:name="Transform Message"> <ee:message> <ee:set-payload><![CDATA[%dw 2.0 output application/java --- payload map (row, index) -> row]]></ee:set-payload> </ee:message> </ee:transform> <foreach doc:name="For Each"> <logger level="INFO" doc:name="Logger" message="#[payload]" /> </foreach> </flow> </mule>
Now it's time for the eyeball test. How accurate is this code?
I'm very impressed that ChatGPT is providing an entire XML config file. The now GPT3.5 legacy model only provided a snippet and thought the language was PHP.
This code provides a dependency for your pom.xml. This is good.
GPT-4 understands that you must use an SFTP connector to build an integration.
GPT-4 does not understand the correct operation for the SFTP connector. It goes for the File read operation instead.
GPT-4 attempted DataWeave. GPT3.5 (legacy) was not trained in DataWeave and wrote misleading DW scripts.
GPT-4 makes an assumption that the SFTP server needed a username and password pair to log in to the SFTP server. What about logging in with an SSH key?
GPT-4 understands how to set MIMETypes to application/csv.
What are your observations?
Creating a Mule app with ChatGPT Code
Now this is the moment of truth. Does the code actually work with ChatGPTs suggested tweaks? I have spotted many errors without copying the code to Anypoint Studio 7 or Anypoint Code Builder.
However, I wondered how much work would be involved and if generating an SFTP flow using ChatGPT was genuinely worth it.
As you may have expected, copying the flow was not an easy task. I created a brand new Mule 4 application in Anypoint Studio 7 first. Then I copied the dependency and the XML configuration file. Here is a list of issues:
The SFTP dependency was not the latest. I had to tweak the dependency.
The namespaces were incorrect.
The SFTP connector was correct, but ChatGPT chose the wrong operation. The file:read operation belongs to the file connector. The model should have used GPT-4.
Watch My SFTP Integration Experiment
Feel free to watch my experiment below.
Here are the relevant timestamps:
Build an SFTP Mule app: 37:24
Validate SFTP Mule app code using Documentation: 38:32
Validate SFTP Mule app using Anypoint Studio 7: 50:41
In conclusion, ChatGPT was not very good at building Mule 4 flows that used the SFTP Connector. Copying the code required significant tweaks. One could argue that using the low code drag and drop functionality and scaffolding functionality done through APIkit Router is more productive than generating Mule flows from a prompt.
Guess what? Bard can code. I wonder if it knows Mule 4.
Subscribe to my blog and never miss a post.