top of page

Exploring the Capabilities of GPT-4 for SFTP Integrations in Mule 4

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.



Cover graphic for GPT-4 & SFTP Integration in Mule 4.
GPT-4 & SFTP in Mule 4 display

This post details my SFTP integration experiment for the GPT-4 large language model (LLM).


Quick Navigation


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

  1. Write Mule 4 code

  2. Read a file from an SFTP

  3. Enable Streaming


ChatGPT SFTP Integration Results


ChatGPT responds with a text to use the SFTP Connector with the file:read operation followed by a transform message component. It then provides a dependency.
Screenshot #1 of ChatGPTs Response

Code Snippet 1

<dependency>
    <groupId>org.mule.connectors</groupId>
    <artifactId>mule-sftp-connector</artifactId>
    <version>1.4.0</version>
</dependency>

ChatGPT responds with the next step to configure the SFTP Connector and CSV streaming in Mule flow. It also provides a copyable XML Configuration file.
Screenshot #2 of ChatGPTs Response

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>

ChatGPT responds by explaining the code snippet and the tweaks needed when using the application.
Screenshot #3 of ChatGPT Response

My Observations

Now it's time for the eyeball test. How accurate is this code?

  1. 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.

  2. This code provides a dependency for your pom.xml. This is good.

  3. GPT-4 understands that you must use an SFTP connector to build an integration.

  4. GPT-4 does not understand the correct operation for the SFTP connector. It goes for the File read operation instead.

  5. GPT-4 attempted DataWeave. GPT3.5 (legacy) was not trained in DataWeave and wrote misleading DW scripts.

  6. 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?

  7. 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.


My Observations

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:

  1. The SFTP dependency was not the latest. I had to tweak the dependency.

  2. The namespaces were incorrect.

  3. 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


Conclusion

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.

214 views0 comments

Recent Posts

See All
bottom of page