You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by "jevinjiang (via GitHub)" <gi...@apache.org> on 2024/04/07 09:57:42 UTC

[PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

jevinjiang opened a new pull request, #4817:
URL: https://github.com/apache/eventmesh/pull/4817

   Fixes https://github.com/apache/eventmesh/issues/4047
   
   Motivation
   
   
   Support chatGPT source connector
   
   Documentation
   
   -Does this pull request introduce a new feature? no


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1565370183


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/connector/ChatGPTSourceConnector.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.source.connector;
+
+import org.apache.eventmesh.common.ThreadPoolFactory;
+import org.apache.eventmesh.common.exception.EventMeshException;
+import org.apache.eventmesh.common.utils.AssertUtils;
+import org.apache.eventmesh.connector.chatgpt.source.config.ChatGPTSourceConfig;
+import org.apache.eventmesh.connector.chatgpt.source.dto.ChatGPTRequestDTO;
+import org.apache.eventmesh.connector.chatgpt.source.enums.ChatGPTRequestType;
+import org.apache.eventmesh.connector.chatgpt.source.handlers.ChatHandler;
+import org.apache.eventmesh.connector.chatgpt.source.handlers.ParseHandler;
+import org.apache.eventmesh.connector.chatgpt.source.managers.OpenaiManager;
+import org.apache.eventmesh.openconnect.api.config.Config;
+import org.apache.eventmesh.openconnect.api.connector.ConnectorContext;
+import org.apache.eventmesh.openconnect.api.connector.SourceConnectorContext;
+import org.apache.eventmesh.openconnect.api.source.Source;
+import org.apache.eventmesh.openconnect.offsetmgmt.api.data.ConnectRecord;
+import org.apache.eventmesh.openconnect.util.CloudEventUtil;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import io.cloudevents.CloudEvent;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.core.http.HttpServerOptions;
+import io.vertx.ext.web.RequestBody;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.BodyHandler;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class ChatGPTSourceConnector implements Source {
+
+    private static final int DEFAULT_BATCH_SIZE = 10;
+
+    private ChatGPTSourceConfig sourceConfig;
+    private BlockingQueue<CloudEvent> queue;
+    private HttpServer server;
+    private final ExecutorService chatgptSourceExecutorService = ThreadPoolFactory.createThreadPoolExecutor(
+        Runtime.getRuntime().availableProcessors() * 2, Runtime.getRuntime().availableProcessors() * 2, "ChatGPTSourceThread");
+
+    private OpenaiManager openaiManager;
+    private String parsePromptTemplateStr;
+    private ChatHandler chatHandler;
+    private ParseHandler parseHandler;
+
+    @Override
+    public Class<? extends Config> configClass() {
+        return ChatGPTSourceConfig.class;
+    }
+
+    @Override
+    public void init(Config config) {
+        this.sourceConfig = (ChatGPTSourceConfig) config;
+        doInit();
+    }
+
+    @Override
+    public void init(ConnectorContext connectorContext) {
+        SourceConnectorContext sourceConnectorContext = (SourceConnectorContext) connectorContext;
+        this.sourceConfig = (ChatGPTSourceConfig) sourceConnectorContext.getSourceConfig();
+        doInit();
+    }
+
+    public void initParsePrompt() {
+        String parsePromptFileName = sourceConfig.getConnectorConfig().getParsePromptFileName();
+        URL resource = Thread.currentThread().getContextClassLoader().getResource(parsePromptFileName);
+        AssertUtils.notNull(resource, String.format("cannot find file %s", parsePromptFileName));

Review Comment:
   It's a bit unfriendly if the user is not going to use prompt, but can't start the Connector. Suggest to make it optional: print a log warning when there is no `parsePromptFileName` configuration, then subsequent processes are executed in normal mode and log to warn the user for the reason when the user request is of type PARSE.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1568616322


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/connector/ChatGPTSourceConnector.java:
##########
@@ -0,0 +1,232 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.source.connector;
+
+import org.apache.eventmesh.common.ThreadPoolFactory;
+import org.apache.eventmesh.common.exception.EventMeshException;
+import org.apache.eventmesh.connector.chatgpt.source.config.ChatGPTSourceConfig;
+import org.apache.eventmesh.connector.chatgpt.source.dto.ChatGPTRequestDTO;
+import org.apache.eventmesh.connector.chatgpt.source.enums.ChatGPTRequestType;
+import org.apache.eventmesh.connector.chatgpt.source.handlers.ChatHandler;
+import org.apache.eventmesh.connector.chatgpt.source.handlers.ParseHandler;
+import org.apache.eventmesh.connector.chatgpt.source.managers.OpenaiManager;
+import org.apache.eventmesh.openconnect.api.config.Config;
+import org.apache.eventmesh.openconnect.api.connector.ConnectorContext;
+import org.apache.eventmesh.openconnect.api.connector.SourceConnectorContext;
+import org.apache.eventmesh.openconnect.api.source.Source;
+import org.apache.eventmesh.openconnect.offsetmgmt.api.data.ConnectRecord;
+import org.apache.eventmesh.openconnect.util.CloudEventUtil;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import io.cloudevents.CloudEvent;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.core.http.HttpServerOptions;
+import io.vertx.ext.web.RequestBody;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.BodyHandler;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class ChatGPTSourceConnector implements Source {
+
+    private static final int DEFAULT_BATCH_SIZE = 10;
+
+    private ChatGPTSourceConfig sourceConfig;
+    private BlockingQueue<CloudEvent> queue;
+    private HttpServer server;
+    private final ExecutorService chatgptSourceExecutorService = ThreadPoolFactory.createThreadPoolExecutor(
+        Runtime.getRuntime().availableProcessors() * 2, Runtime.getRuntime().availableProcessors() * 2, "ChatGPTSourceThread");
+
+    private OpenaiManager openaiManager;
+    private String parsePromptTemplateStr;
+    private ChatHandler chatHandler;
+    private ParseHandler parseHandler;
+
+    @Override
+    public Class<? extends Config> configClass() {
+        return ChatGPTSourceConfig.class;
+    }
+
+    @Override
+    public void init(Config config) {
+        this.sourceConfig = (ChatGPTSourceConfig) config;
+        doInit();
+    }
+
+    @Override
+    public void init(ConnectorContext connectorContext) {
+        SourceConnectorContext sourceConnectorContext = (SourceConnectorContext) connectorContext;
+        this.sourceConfig = (ChatGPTSourceConfig) sourceConnectorContext.getSourceConfig();
+        doInit();
+    }
+
+    public void initParsePrompt() {
+        String parsePromptFileName = sourceConfig.getConnectorConfig().getParsePromptFileName();
+        URL resource = Thread.currentThread().getContextClassLoader().getResource(parsePromptFileName);
+        if (resource == null) {
+            log.warn("cannot find prompt file {} in resources", parsePromptFileName);
+            return;
+        }
+        String filePath = resource.getPath();
+        try (BufferedReader br = new BufferedReader(new FileReader(filePath))) {
+            StringBuilder builder = new StringBuilder();
+            String line;
+            while ((line = br.readLine()) != null) {
+                if (!line.startsWith("#") && StringUtils.isNotBlank(line)) {
+                    builder.append(line).append("\n");
+                }
+            }
+            this.parsePromptTemplateStr = builder.toString();
+        } catch (IOException e) {
+            throw new IllegalStateException("Unable to read file", e);
+        }
+    }
+
+
+    @SuppressWarnings("checkstyle:WhitespaceAround")
+    private void doInit() {
+        initParsePrompt();
+        this.openaiManager = new OpenaiManager(sourceConfig);
+        this.chatHandler = new ChatHandler(this.openaiManager);
+        if (StringUtils.isNotEmpty(parsePromptTemplateStr)) {
+            this.parseHandler = new ParseHandler(openaiManager, parsePromptTemplateStr);
+        }
+        this.queue = new LinkedBlockingQueue<>(1024);
+        final Vertx vertx = Vertx.vertx();
+        final Router router = Router.router(vertx);
+        router.route().path(this.sourceConfig.connectorConfig.getPath()).method(HttpMethod.POST).handler(BodyHandler.create()).handler(ctx -> {
+            try {
+                RequestBody body = ctx.body();
+                ChatGPTRequestDTO bodyObject = body.asPojo(ChatGPTRequestDTO.class);
+                validateRequestDTO(bodyObject);
+                handleRequest(bodyObject, ctx);
+            } catch (Exception e) {
+                handleError(e, ctx);
+            }
+        });
+        this.server = vertx.createHttpServer(new HttpServerOptions().setPort(this.sourceConfig.connectorConfig.getPort())
+            .setIdleTimeout(this.sourceConfig.connectorConfig.getIdleTimeout())).requestHandler(router);

Review Comment:
   How would Vertx handle it when `idleTimeout` is 0?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "jevinjiang (via GitHub)" <gi...@apache.org>.
jevinjiang commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1567436128


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/connector/ChatGPTSourceConnector.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.source.connector;
+
+import org.apache.eventmesh.common.ThreadPoolFactory;
+import org.apache.eventmesh.common.exception.EventMeshException;
+import org.apache.eventmesh.common.utils.AssertUtils;
+import org.apache.eventmesh.connector.chatgpt.source.config.ChatGPTSourceConfig;
+import org.apache.eventmesh.connector.chatgpt.source.dto.ChatGPTRequestDTO;
+import org.apache.eventmesh.connector.chatgpt.source.enums.ChatGPTRequestType;
+import org.apache.eventmesh.connector.chatgpt.source.handlers.ChatHandler;
+import org.apache.eventmesh.connector.chatgpt.source.handlers.ParseHandler;
+import org.apache.eventmesh.connector.chatgpt.source.managers.OpenaiManager;
+import org.apache.eventmesh.openconnect.api.config.Config;
+import org.apache.eventmesh.openconnect.api.connector.ConnectorContext;
+import org.apache.eventmesh.openconnect.api.connector.SourceConnectorContext;
+import org.apache.eventmesh.openconnect.api.source.Source;
+import org.apache.eventmesh.openconnect.offsetmgmt.api.data.ConnectRecord;
+import org.apache.eventmesh.openconnect.util.CloudEventUtil;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import io.cloudevents.CloudEvent;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.core.http.HttpServerOptions;
+import io.vertx.ext.web.RequestBody;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.BodyHandler;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class ChatGPTSourceConnector implements Source {
+
+    private static final int DEFAULT_BATCH_SIZE = 10;
+
+    private ChatGPTSourceConfig sourceConfig;
+    private BlockingQueue<CloudEvent> queue;
+    private HttpServer server;
+    private final ExecutorService chatgptSourceExecutorService = ThreadPoolFactory.createThreadPoolExecutor(
+        Runtime.getRuntime().availableProcessors() * 2, Runtime.getRuntime().availableProcessors() * 2, "ChatGPTSourceThread");
+
+    private OpenaiManager openaiManager;
+    private String parsePromptTemplateStr;
+    private ChatHandler chatHandler;
+    private ParseHandler parseHandler;
+
+    @Override
+    public Class<? extends Config> configClass() {
+        return ChatGPTSourceConfig.class;
+    }
+
+    @Override
+    public void init(Config config) {
+        this.sourceConfig = (ChatGPTSourceConfig) config;
+        doInit();
+    }
+
+    @Override
+    public void init(ConnectorContext connectorContext) {
+        SourceConnectorContext sourceConnectorContext = (SourceConnectorContext) connectorContext;
+        this.sourceConfig = (ChatGPTSourceConfig) sourceConnectorContext.getSourceConfig();
+        doInit();
+    }
+
+    public void initParsePrompt() {
+        String parsePromptFileName = sourceConfig.getConnectorConfig().getParsePromptFileName();
+        URL resource = Thread.currentThread().getContextClassLoader().getResource(parsePromptFileName);
+        AssertUtils.notNull(resource, String.format("cannot find file %s", parsePromptFileName));

Review Comment:
   This is what I think. The user's initial requirement is a parse handler. If the prompt template is not configured and is changed to a chat handler, it may cause unnecessary trouble.
   
   我是这样想的, 用户最开始的需求是parse handler, 如果因为没有配置prompt template 就改为chat handler的话, 可能会造成不必要的麻烦



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "jevinjiang (via GitHub)" <gi...@apache.org>.
jevinjiang commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1567425401


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/server/ChatGPTConnectServer.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.server;
+
+import org.apache.eventmesh.connector.chatgpt.config.ChatGPTServerConfig;
+import org.apache.eventmesh.connector.chatgpt.source.connector.ChatGPTSourceConnector;
+import org.apache.eventmesh.openconnect.Application;
+import org.apache.eventmesh.openconnect.util.ConfigUtil;
+
+public class ChatGPTConnectServer {
+
+    public static void main(String[] args) throws Exception {
+        ChatGPTServerConfig serverConfig = ConfigUtil.parse(ChatGPTServerConfig.class, "server-config.yml");
+
+        if (serverConfig.isSourceEnable()) {
+            Application chatGPTSourceApp = new Application();
+            chatGPTSourceApp.run(ChatGPTSourceConnector.class);
+        }
+
+        if (serverConfig.isSinkEnable()) {
+            // TODO support sink connector
+        }

Review Comment:
   Does such a scenario exist? Create a view that aggregates ten-day data in a database such as mongodb or mysql, and send it to the sink connector of chatgpt through the respective source connector to generate articles such as delayed reports.
   
   这样的场景是否存在, 在mongodb或者mysql等数据库中建立聚合十日等数据的视图, 由各自的source connector 发送到 chatgpt的sink connector中, 生成研报等文章内容



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#issuecomment-2041452904

   plz fix ci~


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1565370183


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/connector/ChatGPTSourceConnector.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.source.connector;
+
+import org.apache.eventmesh.common.ThreadPoolFactory;
+import org.apache.eventmesh.common.exception.EventMeshException;
+import org.apache.eventmesh.common.utils.AssertUtils;
+import org.apache.eventmesh.connector.chatgpt.source.config.ChatGPTSourceConfig;
+import org.apache.eventmesh.connector.chatgpt.source.dto.ChatGPTRequestDTO;
+import org.apache.eventmesh.connector.chatgpt.source.enums.ChatGPTRequestType;
+import org.apache.eventmesh.connector.chatgpt.source.handlers.ChatHandler;
+import org.apache.eventmesh.connector.chatgpt.source.handlers.ParseHandler;
+import org.apache.eventmesh.connector.chatgpt.source.managers.OpenaiManager;
+import org.apache.eventmesh.openconnect.api.config.Config;
+import org.apache.eventmesh.openconnect.api.connector.ConnectorContext;
+import org.apache.eventmesh.openconnect.api.connector.SourceConnectorContext;
+import org.apache.eventmesh.openconnect.api.source.Source;
+import org.apache.eventmesh.openconnect.offsetmgmt.api.data.ConnectRecord;
+import org.apache.eventmesh.openconnect.util.CloudEventUtil;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import io.cloudevents.CloudEvent;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.core.http.HttpServerOptions;
+import io.vertx.ext.web.RequestBody;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.BodyHandler;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class ChatGPTSourceConnector implements Source {
+
+    private static final int DEFAULT_BATCH_SIZE = 10;
+
+    private ChatGPTSourceConfig sourceConfig;
+    private BlockingQueue<CloudEvent> queue;
+    private HttpServer server;
+    private final ExecutorService chatgptSourceExecutorService = ThreadPoolFactory.createThreadPoolExecutor(
+        Runtime.getRuntime().availableProcessors() * 2, Runtime.getRuntime().availableProcessors() * 2, "ChatGPTSourceThread");
+
+    private OpenaiManager openaiManager;
+    private String parsePromptTemplateStr;
+    private ChatHandler chatHandler;
+    private ParseHandler parseHandler;
+
+    @Override
+    public Class<? extends Config> configClass() {
+        return ChatGPTSourceConfig.class;
+    }
+
+    @Override
+    public void init(Config config) {
+        this.sourceConfig = (ChatGPTSourceConfig) config;
+        doInit();
+    }
+
+    @Override
+    public void init(ConnectorContext connectorContext) {
+        SourceConnectorContext sourceConnectorContext = (SourceConnectorContext) connectorContext;
+        this.sourceConfig = (ChatGPTSourceConfig) sourceConnectorContext.getSourceConfig();
+        doInit();
+    }
+
+    public void initParsePrompt() {
+        String parsePromptFileName = sourceConfig.getConnectorConfig().getParsePromptFileName();
+        URL resource = Thread.currentThread().getContextClassLoader().getResource(parsePromptFileName);
+        AssertUtils.notNull(resource, String.format("cannot find file %s", parsePromptFileName));

Review Comment:
   It's a bit unfriendly if the user is not going to use prompt, but can't start the Connector. Suggest to make it optional: print a log warning when cannot find the loaded prompt template file or when there is no `parsePromptFileName` configuration, then subsequent processes are executed in normal mode and log to warn the user for the reason when the user request is of type PARSE.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "jevinjiang (via GitHub)" <gi...@apache.org>.
jevinjiang commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1567417222


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/managers/OpenaiManager.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.source.managers;
+
+import static com.theokanning.openai.service.OpenAiService.defaultObjectMapper;
+import static com.theokanning.openai.service.OpenAiService.defaultRetrofit;
+
+import org.apache.eventmesh.common.utils.AssertUtils;
+import org.apache.eventmesh.common.utils.JsonUtils;
+import org.apache.eventmesh.connector.chatgpt.source.config.ChatGPTSourceConfig;
+import org.apache.eventmesh.connector.chatgpt.source.config.OpenaiConfig;
+import org.apache.eventmesh.connector.chatgpt.source.config.OpenaiProxyConfig;
+
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.time.Duration;
+import java.util.List;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.theokanning.openai.client.OpenAiApi;
+import com.theokanning.openai.completion.chat.ChatCompletionRequest;
+import com.theokanning.openai.completion.chat.ChatCompletionRequest.ChatCompletionRequestBuilder;
+import com.theokanning.openai.completion.chat.ChatMessage;
+import com.theokanning.openai.service.OpenAiService;
+
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+
+import okhttp3.OkHttpClient;
+import retrofit2.Retrofit;
+
+
+@Slf4j
+public class OpenaiManager {
+
+    @Getter
+    private OpenAiService openAiService;
+
+    private String chatCompletionRequestTemplateStr;
+
+    public OpenaiManager(ChatGPTSourceConfig sourceConfig) {
+        initOpenAi(sourceConfig);
+    }
+
+    public String getResult(ChatCompletionRequest req) {
+        StringBuilder gptData = new StringBuilder();
+        try {
+            openAiService.createChatCompletion(req).getChoices()
+                .forEach(chatCompletionChoice -> gptData.append(chatCompletionChoice.getMessage().getContent()));
+        } catch (Exception e) {
+            log.error("Failed to generate GPT connection record: {}", e.getMessage());
+        }
+        return gptData.toString();
+    }
+
+    public ChatCompletionRequest newChatCompletionRequest(List<ChatMessage> chatMessages) {
+        ChatCompletionRequest request = JsonUtils.parseObject(chatCompletionRequestTemplateStr, ChatCompletionRequest.class);
+        request.setMessages(chatMessages);
+        return request;
+    }
+
+    private void initOpenAi(ChatGPTSourceConfig sourceConfig) {
+        OpenaiConfig openaiConfig = sourceConfig.getOpenaiConfig();
+        AssertUtils.isTrue(openaiConfig.getTimeout() > 0, "openaiTimeout must be >= 0");

Review Comment:
   You are right, we do need some default values



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo merged PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "jevinjiang (via GitHub)" <gi...@apache.org>.
jevinjiang commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1565964101


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/resources/prompt:
##########
@@ -0,0 +1,44 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+You are an AI assistant named CloudEventsConverter. avoid escape characters .
+Your task is to construct a JSON object in CloudEvents format. Based on the field name and field description in the 'data' field of the CloudEvents formatted JSON object, convert the input text provided by the user into the content of the 'data' field, which must comply with the specifications of the content of the 'datacontenttype' field.
+The role is :
+ - If the 'datacontenttype' field content is 'application/json', then the' data 'field content should be a JSON object,
+ - else If the 'datacontenttype' field content is not 'application/json' and is 'application/xml', then the' data 'field content should be a string in XML format and the outermost of XML format is <data> </data>, inside is the XML generated by you based on field info;
+ - else the 'datacontenttype' field content is not 'application/json' and 'application/xml', then the' data 'field content is string of the 'text' field content;
+Except for the content of the data field, all other values should be set to and cannot be modified. Finally, return to me the JSON object in CloudEvents format that you constructed
+
+The following text is the field name and field description in the 'data' field of the CloudEvents-formatted JSON object, extract the following information:
+<BEGIN FIELD INFO>
+${fields}
+<END FIELD INFO>
+
+text:  ${text}
+
+The output should be a markdown code snippet formatted in the following schema, including the leading and trailing "```json" and "```":
+```json
+{
+  "specversion": string,  Set to "1.0"
+  "type": string,  Set to  ${type}
+  "source": string, Set to  ${source}
+  "subject": string, Set to ${subject}
+  "id": string, Set to  ${id}
+  "time": string, Set to  ${time}

Review Comment:
   okk~ I will complete this task as soon as possible



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1554955511


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/server/ChatGPTConnectServer.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.server;
+
+import org.apache.eventmesh.connector.chatgpt.config.ChatGPTServerConfig;
+import org.apache.eventmesh.connector.chatgpt.source.connector.ChatGPTSourceConnector;
+import org.apache.eventmesh.openconnect.Application;
+import org.apache.eventmesh.openconnect.util.ConfigUtil;
+
+public class ChatGPTConnectServer {
+
+    public static void main(String[] args) throws Exception {
+        ChatGPTServerConfig serverConfig = ConfigUtil.parse(ChatGPTServerConfig.class, "server-config.yml");
+
+        if (serverConfig.isSourceEnable()) {
+            Application chatGPTSourceApp = new Application();
+            chatGPTSourceApp.run(ChatGPTSourceConnector.class);
+        }
+
+        if (serverConfig.isSinkEnable()) {
+            // TODO support sink connector
+        }

Review Comment:
   Actually we have no idea what kind of scenarios the chatgpt sink connector needs to be used in.



##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/connector/ChatGPTSourceConnector.java:
##########
@@ -0,0 +1,225 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.source.connector;
+
+
+import org.apache.eventmesh.common.ThreadPoolFactory;
+import org.apache.eventmesh.common.exception.EventMeshException;
+import org.apache.eventmesh.connector.chatgpt.source.config.ChatGPTSourceConfig;
+import org.apache.eventmesh.openconnect.api.config.Config;
+import org.apache.eventmesh.openconnect.api.connector.ConnectorContext;
+import org.apache.eventmesh.openconnect.api.connector.SourceConnectorContext;
+import org.apache.eventmesh.openconnect.api.source.Source;
+import org.apache.eventmesh.openconnect.offsetmgmt.api.data.ConnectRecord;
+import org.apache.eventmesh.openconnect.util.CloudEventUtil;
+
+import java.net.URI;
+import java.time.Duration;
+import java.time.ZonedDateTime;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import io.cloudevents.CloudEvent;
+import io.cloudevents.core.builder.CloudEventBuilder;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.core.http.HttpServerOptions;
+import io.vertx.ext.web.RequestBody;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.handler.BodyHandler;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.theokanning.openai.completion.chat.ChatCompletionRequest;
+import com.theokanning.openai.completion.chat.ChatMessage;
+import com.theokanning.openai.completion.chat.ChatMessageRole;
+import com.theokanning.openai.service.OpenAiService;
+
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class ChatGPTSourceConnector implements Source {
+
+    private static final int DEFAULT_BATCH_SIZE = 10;
+
+    private ChatGPTSourceConfig sourceConfig;
+    private BlockingQueue<CloudEvent> queue;
+    private HttpServer server;
+    private OpenAiService openAiService;
+    private ExecutorService consumeExecutorService;
+
+    @Data
+    private static class ChatGPTBody {
+
+        String prompt;
+
+        String source;
+
+        String subject;
+
+        @JsonProperty("datacontenttype")
+        String dataContentType;
+
+        String type;
+    }

Review Comment:
   It will be better to split this part into a dto.



##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/connector/ChatGPTSourceConnector.java:
##########
@@ -0,0 +1,225 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.source.connector;
+
+
+import org.apache.eventmesh.common.ThreadPoolFactory;
+import org.apache.eventmesh.common.exception.EventMeshException;
+import org.apache.eventmesh.connector.chatgpt.source.config.ChatGPTSourceConfig;
+import org.apache.eventmesh.openconnect.api.config.Config;
+import org.apache.eventmesh.openconnect.api.connector.ConnectorContext;
+import org.apache.eventmesh.openconnect.api.connector.SourceConnectorContext;
+import org.apache.eventmesh.openconnect.api.source.Source;
+import org.apache.eventmesh.openconnect.offsetmgmt.api.data.ConnectRecord;
+import org.apache.eventmesh.openconnect.util.CloudEventUtil;
+
+import java.net.URI;
+import java.time.Duration;
+import java.time.ZonedDateTime;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import io.cloudevents.CloudEvent;
+import io.cloudevents.core.builder.CloudEventBuilder;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.core.http.HttpServerOptions;
+import io.vertx.ext.web.RequestBody;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.handler.BodyHandler;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.theokanning.openai.completion.chat.ChatCompletionRequest;
+import com.theokanning.openai.completion.chat.ChatMessage;
+import com.theokanning.openai.completion.chat.ChatMessageRole;
+import com.theokanning.openai.service.OpenAiService;
+
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class ChatGPTSourceConnector implements Source {
+
+    private static final int DEFAULT_BATCH_SIZE = 10;
+
+    private ChatGPTSourceConfig sourceConfig;
+    private BlockingQueue<CloudEvent> queue;
+    private HttpServer server;
+    private OpenAiService openAiService;
+    private ExecutorService consumeExecutorService;
+
+    @Data
+    private static class ChatGPTBody {
+
+        String prompt;
+
+        String source;
+
+        String subject;
+
+        @JsonProperty("datacontenttype")
+        String dataContentType;
+
+        String type;
+    }
+
+    @Override
+    public Class<? extends Config> configClass() {
+        return ChatGPTSourceConfig.class;
+    }
+
+    @Override
+    public void init(Config config) {
+        this.sourceConfig = (ChatGPTSourceConfig) config;
+        doInit();
+    }
+
+    @Override
+    public void init(ConnectorContext connectorContext) {
+        SourceConnectorContext sourceConnectorContext = (SourceConnectorContext) connectorContext;
+        this.sourceConfig = (ChatGPTSourceConfig) sourceConnectorContext.getSourceConfig();
+        doInit();
+    }
+
+    private CloudEvent genGptConnectRecord(ChatGPTBody event) {
+        List<ChatMessage> chatMessages = new ArrayList<>();
+        chatMessages.add(new ChatMessage(ChatMessageRole.USER.value(), event.getPrompt()));
+        ChatCompletionRequest req =
+            ChatCompletionRequest.builder().messages(chatMessages).model(sourceConfig.connectorConfig.getOpenaiModel()).build();
+        StringBuilder gptData = new StringBuilder();
+
+        try {
+            openAiService.createChatCompletion(req).getChoices()
+                .forEach(chatCompletionChoice -> gptData.append(chatCompletionChoice.getMessage().getContent()));
+        } catch (Exception e) {
+            log.error("Failed to generate GPT connection record: {}", e.getMessage());
+        }
+
+        return CloudEventBuilder.v1()
+            .withId(UUID.randomUUID().toString())
+            .withSource(URI.create(event.getSource()))
+            .withType(event.getType())
+            .withTime(ZonedDateTime.now().toOffsetDateTime())
+            .withData(gptData.toString().getBytes())
+            .withSubject(event.getSubject())
+            .withDataContentType(event.getDataContentType())
+            .build();
+    }
+
+    /**
+     *     use proxy:
+     *     ObjectMapper mapper = defaultObjectMapper();
+     *     Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 7890));

Review Comment:
   May you please make this proxy setting a yml configuration?



##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/resources/source-config.yml:
##########
@@ -0,0 +1,33 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+pubSubConfig:
+    meshAddress: 127.0.0.1:10000
+    subject: TopicTest
+    idc: FT
+    env: PRD
+    group: chatgptSource
+    appId: 5032
+    userName: chatgptSourceUser
+    passWord: chatgptPassWord
+connectorConfig:
+    connectorName: chatgptSource
+    path: /chatgpt
+    port: 3756
+    idleTimeout: 999
+    openaiToken:
+    openaiModel: gpt-3.5-turbo

Review Comment:
   It would be nice if you could leave a url maintained by OpenAI in documents indicating what optional values are available.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#issuecomment-2041656698

   @Pil0tXia You have correctly drawn the architecture of this PR (with the specified prompts idea first proposed by the author and your prompts template idea), so I believe you understand the core functionality implemented in this PR now. 
   
   As for the design of the prompt templates and how to send specified prompt, I suggest leaving them to the developer without limiting the developer's thought, as the author creatively thought of multiple data formats can being specified before. Of course the developer can adopt your good design.
   The developer can even temporarily not develop prompt templates and submit the feature of prompt templates after multiple PRs submitted for this Connector.
   > this checking process may not save much performance overhead compared to deserialization. 
   
   Maybe. Maybe the overhead of checking format is less than the overhead of building CloudEvent item by item. Suitable code can even do without explicitly checking format.
   > By not relying on the JSON format generated by ChatGPT, more stable results can be obtained.
   
   I said earlier to make it configurable, with the option to choose how it currently runs like what this PR do, and the option to ask for a specified format to be returned according to a specified prompt. The _stable results_ here only make this Connector feature-poor in practice.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "jevinjiang (via GitHub)" <gi...@apache.org>.
jevinjiang commented on PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#issuecomment-2063848630

   > 好工作!
   > 
   > [后续文档可以在https://github.com/apache/eventmesh-site](https://github.com/apache/eventmesh-site)中添加。
   
   please review  https://github.com/apache/eventmesh-site/pull/215


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "jevinjiang (via GitHub)" <gi...@apache.org>.
jevinjiang commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1567415614


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/server/ChatGPTConnectServer.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.server;
+
+import org.apache.eventmesh.connector.chatgpt.config.ChatGPTServerConfig;
+import org.apache.eventmesh.connector.chatgpt.source.connector.ChatGPTSourceConnector;
+import org.apache.eventmesh.openconnect.Application;
+import org.apache.eventmesh.openconnect.util.ConfigUtil;
+
+public class ChatGPTConnectServer {
+
+    public static void main(String[] args) throws Exception {
+        ChatGPTServerConfig serverConfig = ConfigUtil.parse(ChatGPTServerConfig.class, "server-config.yml");
+
+        if (serverConfig.isSourceEnable()) {
+            Application chatGPTSourceApp = new Application();
+            chatGPTSourceApp.run(ChatGPTSourceConnector.class);
+        }
+
+        if (serverConfig.isSinkEnable()) {
+            // TODO support sink connector
+        }

Review Comment:
   @Pil0tXia @pandaapo  
   Sorry, in fact, I can't think of a specific application scenario  about sink connector too.
   
   The following are possible scenarios:
   1. Expand openai's "function calling" function, which can execute the corresponding function based on the text sent from the upstream , "function calling" is configured in the yaml file, and the specific function is an http request
   2. It can analyze certain files and image streams and send them to the callback url configured by the user according to the user's prompt.
   3. Based on the upstream text data, talk to openai and return to the callback url provided by the user



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "jevinjiang (via GitHub)" <gi...@apache.org>.
jevinjiang commented on PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#issuecomment-2042492458

   I will fix the interface path to /chat and /parse in the next commit. /parse supports "sending prompt and getting the result of cloudevents specification from ChatGPT" and /chat is the current way to interact with OpenAI.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1565465620


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/managers/OpenaiManager.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.source.managers;
+
+import static com.theokanning.openai.service.OpenAiService.defaultObjectMapper;
+import static com.theokanning.openai.service.OpenAiService.defaultRetrofit;
+
+import org.apache.eventmesh.common.utils.AssertUtils;
+import org.apache.eventmesh.common.utils.JsonUtils;
+import org.apache.eventmesh.connector.chatgpt.source.config.ChatGPTSourceConfig;
+import org.apache.eventmesh.connector.chatgpt.source.config.OpenaiConfig;
+import org.apache.eventmesh.connector.chatgpt.source.config.OpenaiProxyConfig;
+
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.time.Duration;
+import java.util.List;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.theokanning.openai.client.OpenAiApi;
+import com.theokanning.openai.completion.chat.ChatCompletionRequest;
+import com.theokanning.openai.completion.chat.ChatCompletionRequest.ChatCompletionRequestBuilder;
+import com.theokanning.openai.completion.chat.ChatMessage;
+import com.theokanning.openai.service.OpenAiService;
+
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+
+import okhttp3.OkHttpClient;
+import retrofit2.Retrofit;
+
+
+@Slf4j
+public class OpenaiManager {
+
+    @Getter
+    private OpenAiService openAiService;
+
+    private String chatCompletionRequestTemplateStr;
+
+    public OpenaiManager(ChatGPTSourceConfig sourceConfig) {
+        initOpenAi(sourceConfig);
+    }
+
+    public String getResult(ChatCompletionRequest req) {
+        StringBuilder gptData = new StringBuilder();
+        try {
+            openAiService.createChatCompletion(req).getChoices()
+                .forEach(chatCompletionChoice -> gptData.append(chatCompletionChoice.getMessage().getContent()));
+        } catch (Exception e) {
+            log.error("Failed to generate GPT connection record: {}", e.getMessage());
+        }
+        return gptData.toString();
+    }
+
+    public ChatCompletionRequest newChatCompletionRequest(List<ChatMessage> chatMessages) {
+        ChatCompletionRequest request = JsonUtils.parseObject(chatCompletionRequestTemplateStr, ChatCompletionRequest.class);
+        request.setMessages(chatMessages);
+        return request;
+    }
+
+    private void initOpenAi(ChatGPTSourceConfig sourceConfig) {
+        OpenaiConfig openaiConfig = sourceConfig.getOpenaiConfig();
+        AssertUtils.isTrue(openaiConfig.getTimeout() > 0, "openaiTimeout must be >= 0");
+        boolean proxyEnable = sourceConfig.connectorConfig.isProxyEnable();
+        if (proxyEnable) {
+            OpenaiProxyConfig chatgptProxyConfig = sourceConfig.openaiProxyConfig;
+            if (chatgptProxyConfig.getHost() == null) {
+                throw new IllegalStateException("chatgpt proxy config 'host' cannot be null");
+            }
+            ObjectMapper mapper = defaultObjectMapper();
+            Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(chatgptProxyConfig.getHost(), chatgptProxyConfig.getPort()));
+            OkHttpClient client =
+                OpenAiService.defaultClient(openaiConfig.getToken(), Duration.ofSeconds(openaiConfig.getTimeout())).newBuilder().proxy(proxy).build();
+            Retrofit retrofit = defaultRetrofit(client, mapper);

Review Comment:
   Can `OpenAiService.defaultClient()` be consistent with the following to use static import?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1564426237


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/resources/prompt:
##########
@@ -0,0 +1,44 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+You are an AI assistant named CloudEventsConverter. avoid escape characters .
+Your task is to construct a JSON object in CloudEvents format. Based on the field name and field description in the 'data' field of the CloudEvents formatted JSON object, convert the input text provided by the user into the content of the 'data' field, which must comply with the specifications of the content of the 'datacontenttype' field.
+The role is :
+ - If the 'datacontenttype' field content is 'application/json', then the' data 'field content should be a JSON object,
+ - else If the 'datacontenttype' field content is not 'application/json' and is 'application/xml', then the' data 'field content should be a string in XML format and the outermost of XML format is <data> </data>, inside is the XML generated by you based on field info;
+ - else the 'datacontenttype' field content is not 'application/json' and 'application/xml', then the' data 'field content is string of the 'text' field content;
+Except for the content of the data field, all other values should be set to and cannot be modified. Finally, return to me the JSON object in CloudEvents format that you constructed
+
+The following text is the field name and field description in the 'data' field of the CloudEvents-formatted JSON object, extract the following information:
+<BEGIN FIELD INFO>
+${fields}
+<END FIELD INFO>
+
+text:  ${text}
+
+The output should be a markdown code snippet formatted in the following schema, including the leading and trailing "```json" and "```":
+```json
+{
+  "specversion": string,  Set to "1.0"
+  "type": string,  Set to  ${type}
+  "source": string, Set to  ${source}
+  "subject": string, Set to ${subject}
+  "id": string, Set to  ${id}
+  "time": string, Set to  ${time}
+  "datacontenttype": string, Set to  ${datacontenttype}

Review Comment:
   I find that my understanding of this prompt file is indeed not as good as ChatGPT's. When users use the prompt mode, do they refer to or directly use the prompt file, and then replace all ${} in the file with their own content?
   
   我发现我对该prompt文件的理解能力确实不如ChatGPT。用户使用prompt模式时,是参照该prompt文件或直接使用该文件,然后将该文件中所有${}替换成自己的内容吗?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "jevinjiang (via GitHub)" <gi...@apache.org>.
jevinjiang commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1564716682


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/resources/prompt:
##########
@@ -0,0 +1,44 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+You are an AI assistant named CloudEventsConverter. avoid escape characters .
+Your task is to construct a JSON object in CloudEvents format. Based on the field name and field description in the 'data' field of the CloudEvents formatted JSON object, convert the input text provided by the user into the content of the 'data' field, which must comply with the specifications of the content of the 'datacontenttype' field.
+The role is :
+ - If the 'datacontenttype' field content is 'application/json', then the' data 'field content should be a JSON object,
+ - else If the 'datacontenttype' field content is not 'application/json' and is 'application/xml', then the' data 'field content should be a string in XML format and the outermost of XML format is <data> </data>, inside is the XML generated by you based on field info;
+ - else the 'datacontenttype' field content is not 'application/json' and 'application/xml', then the' data 'field content is string of the 'text' field content;
+Except for the content of the data field, all other values should be set to and cannot be modified. Finally, return to me the JSON object in CloudEvents format that you constructed
+
+The following text is the field name and field description in the 'data' field of the CloudEvents-formatted JSON object, extract the following information:
+<BEGIN FIELD INFO>
+${fields}
+<END FIELD INFO>
+
+text:  ${text}
+
+The output should be a markdown code snippet formatted in the following schema, including the leading and trailing "```json" and "```":
+```json
+{
+  "specversion": string,  Set to "1.0"
+  "type": string,  Set to  ${type}
+  "source": string, Set to  ${source}
+  "subject": string, Set to ${subject}
+  "id": string, Set to  ${id}
+  "time": string, Set to  ${time}
+  "datacontenttype": string, Set to  ${datacontenttype}

Review Comment:
   @pandaapo 
   In fact, it depends on the user's description of the field information. I have not made any relevant guarantees. I tested it. If the field does not exist in the text, the description of the field will be returned. The following is a return example:
   ```json
   {
     "specversion": "1.0",
     "type": "com.example.someevent",
     "source": "/mycontext",
     "subject": "test",
     "id": "56bf1ce4-d57f-4591-9196-fe0cb8abf9c7",
     "time": "2024-04-14T21:01:34.548791+08:00",
     "datacontenttype": "application/json",
     "data": {
       "orderNo": "this is order number",
       "address": "this is a address",
       "phone": "this is phone number",
       "text": "There are a cloth sofa, a wood table and two wood chairs in the living room"
     }
   }
   ```
   Users can adjust the description information in fields, such as
   ```
   <BEGIN FIELD INFO>
   orderNo:this is order number!If this information is not found, output none.
   address:this is a address!If this information is not found, output none.
   phone:this is phone number!If this information is not found, output none.
   <END FIELD INFO>
   ```
   In this case, the return of chatgpt is
   ```json
   
   {
     "specversion": "1.0",
     "type": "com.example.someevent",
     "source": "/mycontext",
     "subject": "test",
     "id": "51387c66-2a4c-4b7a-a1cc-f9f554aa039b",
     "time": "2024-04-14T20:57:08.864208+08:00",
     "datacontenttype": "application/json",
     "data": {
       "orderNo": "none",
       "address": "none",
       "phone": "none"
     }
   }
   
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1564653390


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/resources/prompt:
##########
@@ -0,0 +1,44 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+You are an AI assistant named CloudEventsConverter. avoid escape characters .
+Your task is to construct a JSON object in CloudEvents format. Based on the field name and field description in the 'data' field of the CloudEvents formatted JSON object, convert the input text provided by the user into the content of the 'data' field, which must comply with the specifications of the content of the 'datacontenttype' field.
+The role is :
+ - If the 'datacontenttype' field content is 'application/json', then the' data 'field content should be a JSON object,
+ - else If the 'datacontenttype' field content is not 'application/json' and is 'application/xml', then the' data 'field content should be a string in XML format and the outermost of XML format is <data> </data>, inside is the XML generated by you based on field info;
+ - else the 'datacontenttype' field content is not 'application/json' and 'application/xml', then the' data 'field content is string of the 'text' field content;
+Except for the content of the data field, all other values should be set to and cannot be modified. Finally, return to me the JSON object in CloudEvents format that you constructed
+
+The following text is the field name and field description in the 'data' field of the CloudEvents-formatted JSON object, extract the following information:
+<BEGIN FIELD INFO>
+${fields}
+<END FIELD INFO>
+
+text:  ${text}
+
+The output should be a markdown code snippet formatted in the following schema, including the leading and trailing "```json" and "```":
+```json
+{
+  "specversion": string,  Set to "1.0"
+  "type": string,  Set to  ${type}
+  "source": string, Set to  ${source}
+  "subject": string, Set to ${subject}
+  "id": string, Set to  ${id}
+  "time": string, Set to  ${time}
+  "datacontenttype": string, Set to  ${datacontenttype}

Review Comment:
   What will be the result returned by ChatGPT for this prompt?
   
   To generate this full prompt text after replacing the placeholders, what would a user's request to access this Connector look like?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#issuecomment-2041481115

   >sending prompt and getting the result of cloudevents specification from ChatGPT
   
   I also think it's a good idea, but it's technically unworkable.
   
   This is the required ChatGPT source connector architecture described in https://github.com/apache/eventmesh/issues/4047#issuecomment-1569754745:
   
   ![ChatGPT-Source-Connector_correct](https://github.com/apache/eventmesh/assets/41445332/5831e183-66bc-49b7-a427-2891dc969769)
   
   If we let ChatGPT source connector to send prompts, then there will be two inputs, and there's no way to customize the content of prompts:
   
   ![ChatGPT-Source-Connector_prompts](https://github.com/apache/eventmesh/assets/41445332/413999bf-7ec4-4d9b-a006-a159d3f8f4bf)
   
   Moreover, the step that "creating new content **from source connector to Event Source**" goes against the design of the source connector. The source connector should only listen to the Event Source and receive new content.
   
   Secondly, In the case of GPT 3.5, even if the output format is specified using prompts, it is possible for it to output something like the following, which the source connector cannot pass directly without processing:
   
   ```
   Of course. Here is the CloudEvent data you required:
   
   {
       ......
   }
   ```
   
   On the other hand, users can enter prompts even if they are not sent by the source connector. The current design does not cause the ChatGPT source connector to not support the prompts feature.
   
   Any new idea? ☺️


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "jevinjiang (via GitHub)" <gi...@apache.org>.
jevinjiang commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1570693648


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/test/java/org/apache/eventmesh/connector/chatgpt/source/connector/ChatGPTSourceConnectorTest.java:
##########
@@ -108,17 +108,6 @@ void testPoll() throws Exception {
 
         List<ConnectRecord> res1 = connector.poll();
         Assertions.assertEquals(batchSize, res1.size());
-
-        // test invalid requests
-        TestEvent event = new TestEvent();
-        event.type = "com.example.someevent";
-        event.source = "/mycontext";
-        event.datacontenttype = "text/plain";
-        event.text = expectedMessage;
-        HttpPost invalidPost = new HttpPost(uri);
-        invalidPost.setEntity(new StringEntity(JsonUtils.toJSONString(event)));
-        HttpResponse resp = httpClient.execute(invalidPost);
-        Assertions.assertEquals(HttpStatus.SC_BAD_REQUEST, resp.getStatusLine().getStatusCode());

Review Comment:
   Because
   ```java
    ChatGPTRequestDTO bodyObject = body.asPojo(ChatGPTRequestDTO.class);
   ```
   when deserializing ChatGPTRequest, the null value will be ignored and the default value will be used.
   
   The following check will never be triggered
   ```java
     private void validateRequestDTO(ChatGPTRequestDTO bodyObject) {
           if (bodyObject.getSubject() == null || bodyObject.getDataContentType() == null || bodyObject.getText() == null) {
               throw new IllegalArgumentException("Attributes 'subject', 'datacontenttype', and 'text' cannot be null");
           }
       }
   
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#issuecomment-2041492816

   > > sending prompt and getting the result of cloudevents specification from ChatGPT
   > 
   > I also think it's a good idea, but it's technically unworkable.
   > 
   > This is the required ChatGPT source connector architecture described in [#4047 (comment)](https://github.com/apache/eventmesh/issues/4047#issuecomment-1569754745):
   > 
   > ![ChatGPT-Source-Connector_correct](https://private-user-images.githubusercontent.com/41445332/320287338-728001b3-5bcc-47dd-86be-d1bb08c758e1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTI1MDExNTEsIm5iZiI6MTcxMjUwMDg1MSwicGF0aCI6Ii80MTQ0NTMzMi8zMjAyODczMzgtNzI4MDAxYjMtNWJjYy00N2RkLTg2YmUtZDFiYjA4Yzc1OGUxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA0MDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNDA3VDE0NDA1MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWVhNTE0MjQ2Y2Y0MTQ1MTc0ZDE3ZDhmYzM4MDUyY2I3OWQ0NmYwYThkMmJiZGVjYTEzZWM3YmQ3YWYxY2JiNzUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.au0IMFESrPmESTGy9pBGAffJF7OZduD-I2usyfnYt0o)
   > 
   > If we let ChatGPT source connector to send prompts, then there will be two inputs, and there's no way to customize the content of prompts:
   > 
   > ![ChatGPT-Source-Connector_prompts](https://private-user-images.githubusercontent.com/41445332/320287328-92ee4037-850d-426f-a1b4-9d27901623aa.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTI1MDExNTEsIm5iZiI6MTcxMjUwMDg1MSwicGF0aCI6Ii80MTQ0NTMzMi8zMjAyODczMjgtOTJlZTQwMzctODUwZC00MjZmLWExYjQtOWQyNzkwMTYyM2FhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA0MDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNDA3VDE0NDA1MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ3OTkyMWMyYzQ3NGI2NDQ3NGIwNGJmYjc1YzViMGFhNGJmMWI4OWQ5NDhkOWQxMmMwMDVhYmRmYmU1NjJkM2MmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.6SHJVyqgvrtpW6Yhy1SnWOJDfjlaxzE-Z2uVlNdv2W4)
   > 
   > Moreover, the step that "creating new content **from source connector to Event Source**" goes against the design of the source connector. The source connector should only listen to the Event Source and receive new content.
   > 
   > Secondly, In the case of GPT 3.5, even if the output format is specified using prompts, it is possible for it to output something like the following, which the source connector cannot pass directly without processing:
   > 
   > ```
   > Of course. Here is the CloudEvent data you required:
   > 
   > {
   >     ......
   > }
   > ```
   > 
   > On the other hand, users can enter prompts even if they are not sent by the source connector. The current design does not cause the ChatGPT source connector to not support the prompts feature.
   > 
   > Any new idea? ☺️
   
   @Pil0tXia Based on the content you've written, it seems like you may not have carefully reviewed the core functionality implemented in this PR. Otherwise, according to your understanding of https://github.com/apache/eventmesh/issues/4047#issuecomment-1569754745 , you would also have raised similar questions regarding this PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#issuecomment-2067601174

   @jevinjiang Note the slight error in CI.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1564661386


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/resources/prompt:
##########
@@ -0,0 +1,44 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+You are an AI assistant named CloudEventsConverter. avoid escape characters .
+Your task is to construct a JSON object in CloudEvents format. Based on the field name and field description in the 'data' field of the CloudEvents formatted JSON object, convert the input text provided by the user into the content of the 'data' field, which must comply with the specifications of the content of the 'datacontenttype' field.
+The role is :
+ - If the 'datacontenttype' field content is 'application/json', then the' data 'field content should be a JSON object,
+ - else If the 'datacontenttype' field content is not 'application/json' and is 'application/xml', then the' data 'field content should be a string in XML format and the outermost of XML format is <data> </data>, inside is the XML generated by you based on field info;
+ - else the 'datacontenttype' field content is not 'application/json' and 'application/xml', then the' data 'field content is string of the 'text' field content;
+Except for the content of the data field, all other values should be set to and cannot be modified. Finally, return to me the JSON object in CloudEvents format that you constructed
+
+The following text is the field name and field description in the 'data' field of the CloudEvents-formatted JSON object, extract the following information:
+<BEGIN FIELD INFO>
+${fields}
+<END FIELD INFO>
+
+text:  ${text}
+
+The output should be a markdown code snippet formatted in the following schema, including the leading and trailing "```json" and "```":
+```json
+{
+  "specversion": string,  Set to "1.0"
+  "type": string,  Set to  ${type}
+  "source": string, Set to  ${source}
+  "subject": string, Set to ${subject}
+  "id": string, Set to  ${id}
+  "time": string, Set to  ${time}
+  "datacontenttype": string, Set to  ${datacontenttype}

Review Comment:
   What is the purpose of the "'text': 'User 13356288979 from Tianjin store placed an order with order number 11221122'"  in this request?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1567200062


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/server/ChatGPTConnectServer.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.server;
+
+import org.apache.eventmesh.connector.chatgpt.config.ChatGPTServerConfig;
+import org.apache.eventmesh.connector.chatgpt.source.connector.ChatGPTSourceConnector;
+import org.apache.eventmesh.openconnect.Application;
+import org.apache.eventmesh.openconnect.util.ConfigUtil;
+
+public class ChatGPTConnectServer {
+
+    public static void main(String[] args) throws Exception {
+        ChatGPTServerConfig serverConfig = ConfigUtil.parse(ChatGPTServerConfig.class, "server-config.yml");
+
+        if (serverConfig.isSourceEnable()) {
+            Application chatGPTSourceApp = new Application();
+            chatGPTSourceApp.run(ChatGPTSourceConnector.class);
+        }
+
+        if (serverConfig.isSinkEnable()) {
+            // TODO support sink connector
+        }

Review Comment:
   @jevinjiang this review is waiting for your response.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1564426237


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/resources/prompt:
##########
@@ -0,0 +1,44 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+You are an AI assistant named CloudEventsConverter. avoid escape characters .
+Your task is to construct a JSON object in CloudEvents format. Based on the field name and field description in the 'data' field of the CloudEvents formatted JSON object, convert the input text provided by the user into the content of the 'data' field, which must comply with the specifications of the content of the 'datacontenttype' field.
+The role is :
+ - If the 'datacontenttype' field content is 'application/json', then the' data 'field content should be a JSON object,
+ - else If the 'datacontenttype' field content is not 'application/json' and is 'application/xml', then the' data 'field content should be a string in XML format and the outermost of XML format is <data> </data>, inside is the XML generated by you based on field info;
+ - else the 'datacontenttype' field content is not 'application/json' and 'application/xml', then the' data 'field content is string of the 'text' field content;
+Except for the content of the data field, all other values should be set to and cannot be modified. Finally, return to me the JSON object in CloudEvents format that you constructed
+
+The following text is the field name and field description in the 'data' field of the CloudEvents-formatted JSON object, extract the following information:
+<BEGIN FIELD INFO>
+${fields}
+<END FIELD INFO>
+
+text:  ${text}
+
+The output should be a markdown code snippet formatted in the following schema, including the leading and trailing "```json" and "```":
+```json
+{
+  "specversion": string,  Set to "1.0"
+  "type": string,  Set to  ${type}
+  "source": string, Set to  ${source}
+  "subject": string, Set to ${subject}
+  "id": string, Set to  ${id}
+  "time": string, Set to  ${time}
+  "datacontenttype": string, Set to  ${datacontenttype}

Review Comment:
   I find that my understanding of this prompt is indeed not as good as ChatGPT's. When users use the prompt mode, do they refer to or directly use the prompt file, and then replace all ${} in the file with their own content?
   
   我发现我对这段prompt的理解能力确实不如ChatGPT。用户使用prompt模式时,是参照该prompt文件或直接使用该文件,然后将该文件中所有${}替换成自己的内容吗?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "jevinjiang (via GitHub)" <gi...@apache.org>.
jevinjiang commented on PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#issuecomment-2067603045

   @pandaapo  thank you very much for helping me complete this PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "jevinjiang (via GitHub)" <gi...@apache.org>.
jevinjiang commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1565966801


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/managers/OpenaiManager.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.source.managers;
+
+import static com.theokanning.openai.service.OpenAiService.defaultObjectMapper;
+import static com.theokanning.openai.service.OpenAiService.defaultRetrofit;
+
+import org.apache.eventmesh.common.utils.AssertUtils;
+import org.apache.eventmesh.common.utils.JsonUtils;
+import org.apache.eventmesh.connector.chatgpt.source.config.ChatGPTSourceConfig;
+import org.apache.eventmesh.connector.chatgpt.source.config.OpenaiConfig;
+import org.apache.eventmesh.connector.chatgpt.source.config.OpenaiProxyConfig;
+
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.time.Duration;
+import java.util.List;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.theokanning.openai.client.OpenAiApi;
+import com.theokanning.openai.completion.chat.ChatCompletionRequest;
+import com.theokanning.openai.completion.chat.ChatCompletionRequest.ChatCompletionRequestBuilder;
+import com.theokanning.openai.completion.chat.ChatMessage;
+import com.theokanning.openai.service.OpenAiService;
+
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+
+import okhttp3.OkHttpClient;
+import retrofit2.Retrofit;
+
+
+@Slf4j
+public class OpenaiManager {
+
+    @Getter
+    private OpenAiService openAiService;
+
+    private String chatCompletionRequestTemplateStr;
+
+    public OpenaiManager(ChatGPTSourceConfig sourceConfig) {
+        initOpenAi(sourceConfig);
+    }
+
+    public String getResult(ChatCompletionRequest req) {
+        StringBuilder gptData = new StringBuilder();
+        try {
+            openAiService.createChatCompletion(req).getChoices()
+                .forEach(chatCompletionChoice -> gptData.append(chatCompletionChoice.getMessage().getContent()));
+        } catch (Exception e) {
+            log.error("Failed to generate GPT connection record: {}", e.getMessage());
+        }
+        return gptData.toString();
+    }
+
+    public ChatCompletionRequest newChatCompletionRequest(List<ChatMessage> chatMessages) {
+        ChatCompletionRequest request = JsonUtils.parseObject(chatCompletionRequestTemplateStr, ChatCompletionRequest.class);
+        request.setMessages(chatMessages);
+        return request;
+    }
+
+    private void initOpenAi(ChatGPTSourceConfig sourceConfig) {
+        OpenaiConfig openaiConfig = sourceConfig.getOpenaiConfig();
+        AssertUtils.isTrue(openaiConfig.getTimeout() > 0, "openaiTimeout must be >= 0");

Review Comment:
   The current default configuration is equal to the default configuration of openai. This judgment is to prevent users from configuring the openaiTimeout to be 0



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1567184420


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/connector/ChatGPTSourceConnector.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.source.connector;
+
+import org.apache.eventmesh.common.ThreadPoolFactory;
+import org.apache.eventmesh.common.exception.EventMeshException;
+import org.apache.eventmesh.common.utils.AssertUtils;
+import org.apache.eventmesh.connector.chatgpt.source.config.ChatGPTSourceConfig;
+import org.apache.eventmesh.connector.chatgpt.source.dto.ChatGPTRequestDTO;
+import org.apache.eventmesh.connector.chatgpt.source.enums.ChatGPTRequestType;
+import org.apache.eventmesh.connector.chatgpt.source.handlers.ChatHandler;
+import org.apache.eventmesh.connector.chatgpt.source.handlers.ParseHandler;
+import org.apache.eventmesh.connector.chatgpt.source.managers.OpenaiManager;
+import org.apache.eventmesh.openconnect.api.config.Config;
+import org.apache.eventmesh.openconnect.api.connector.ConnectorContext;
+import org.apache.eventmesh.openconnect.api.connector.SourceConnectorContext;
+import org.apache.eventmesh.openconnect.api.source.Source;
+import org.apache.eventmesh.openconnect.offsetmgmt.api.data.ConnectRecord;
+import org.apache.eventmesh.openconnect.util.CloudEventUtil;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import io.cloudevents.CloudEvent;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.core.http.HttpServerOptions;
+import io.vertx.ext.web.RequestBody;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.BodyHandler;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class ChatGPTSourceConnector implements Source {
+
+    private static final int DEFAULT_BATCH_SIZE = 10;
+
+    private ChatGPTSourceConfig sourceConfig;
+    private BlockingQueue<CloudEvent> queue;
+    private HttpServer server;
+    private final ExecutorService chatgptSourceExecutorService = ThreadPoolFactory.createThreadPoolExecutor(
+        Runtime.getRuntime().availableProcessors() * 2, Runtime.getRuntime().availableProcessors() * 2, "ChatGPTSourceThread");
+
+    private OpenaiManager openaiManager;
+    private String parsePromptTemplateStr;
+    private ChatHandler chatHandler;
+    private ParseHandler parseHandler;
+
+    @Override
+    public Class<? extends Config> configClass() {
+        return ChatGPTSourceConfig.class;
+    }
+
+    @Override
+    public void init(Config config) {
+        this.sourceConfig = (ChatGPTSourceConfig) config;
+        doInit();
+    }
+
+    @Override
+    public void init(ConnectorContext connectorContext) {
+        SourceConnectorContext sourceConnectorContext = (SourceConnectorContext) connectorContext;
+        this.sourceConfig = (ChatGPTSourceConfig) sourceConnectorContext.getSourceConfig();
+        doInit();
+    }
+
+    public void initParsePrompt() {
+        String parsePromptFileName = sourceConfig.getConnectorConfig().getParsePromptFileName();
+        URL resource = Thread.currentThread().getContextClassLoader().getResource(parsePromptFileName);
+        AssertUtils.notNull(resource, String.format("cannot find file %s", parsePromptFileName));

Review Comment:
   You didn't adopt this latter point "_then subsequent processes are executed in normal mode and log to warn the user for the reason when the user request is of type PARSE_", in which case you handle it by reporting an error. I think that's fine.
   
   您并没有采纳后面这一点“当用户的请求是PARSE类型时,后续流程以普通模式执行,并用日志警告用户原因”,这种情况下,您的处理方式是报错。我觉得也可以。



##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/managers/OpenaiManager.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.source.managers;
+
+import static com.theokanning.openai.service.OpenAiService.defaultObjectMapper;
+import static com.theokanning.openai.service.OpenAiService.defaultRetrofit;
+
+import org.apache.eventmesh.common.utils.AssertUtils;
+import org.apache.eventmesh.common.utils.JsonUtils;
+import org.apache.eventmesh.connector.chatgpt.source.config.ChatGPTSourceConfig;
+import org.apache.eventmesh.connector.chatgpt.source.config.OpenaiConfig;
+import org.apache.eventmesh.connector.chatgpt.source.config.OpenaiProxyConfig;
+
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.time.Duration;
+import java.util.List;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.theokanning.openai.client.OpenAiApi;
+import com.theokanning.openai.completion.chat.ChatCompletionRequest;
+import com.theokanning.openai.completion.chat.ChatCompletionRequest.ChatCompletionRequestBuilder;
+import com.theokanning.openai.completion.chat.ChatMessage;
+import com.theokanning.openai.service.OpenAiService;
+
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+
+import okhttp3.OkHttpClient;
+import retrofit2.Retrofit;
+
+
+@Slf4j
+public class OpenaiManager {
+
+    @Getter
+    private OpenAiService openAiService;
+
+    private String chatCompletionRequestTemplateStr;
+
+    public OpenaiManager(ChatGPTSourceConfig sourceConfig) {
+        initOpenAi(sourceConfig);
+    }
+
+    public String getResult(ChatCompletionRequest req) {
+        StringBuilder gptData = new StringBuilder();
+        try {
+            openAiService.createChatCompletion(req).getChoices()
+                .forEach(chatCompletionChoice -> gptData.append(chatCompletionChoice.getMessage().getContent()));
+        } catch (Exception e) {
+            log.error("Failed to generate GPT connection record: {}", e.getMessage());
+        }
+        return gptData.toString();
+    }
+
+    public ChatCompletionRequest newChatCompletionRequest(List<ChatMessage> chatMessages) {
+        ChatCompletionRequest request = JsonUtils.parseObject(chatCompletionRequestTemplateStr, ChatCompletionRequest.class);
+        request.setMessages(chatMessages);
+        return request;
+    }
+
+    private void initOpenAi(ChatGPTSourceConfig sourceConfig) {
+        OpenaiConfig openaiConfig = sourceConfig.getOpenaiConfig();
+        AssertUtils.isTrue(openaiConfig.getTimeout() > 0, "openaiTimeout must be >= 0");

Review Comment:
   I'm a bit uncertain. If the configuration file does not have 'timeout' or it is present but the user hasn't configured a value for it, would having a default value of >0 for 'timeout' prevent reporting this error to the user?
   
   我有些不确定。当配置文件中没有timeout或者有但是用户没有配置它的值的时候,如果timeout有>0的默认值是不是就能避免将该错误报告给用户?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "jevinjiang (via GitHub)" <gi...@apache.org>.
jevinjiang commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1568852210


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/connector/ChatGPTSourceConnector.java:
##########
@@ -0,0 +1,232 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.source.connector;
+
+import org.apache.eventmesh.common.ThreadPoolFactory;
+import org.apache.eventmesh.common.exception.EventMeshException;
+import org.apache.eventmesh.connector.chatgpt.source.config.ChatGPTSourceConfig;
+import org.apache.eventmesh.connector.chatgpt.source.dto.ChatGPTRequestDTO;
+import org.apache.eventmesh.connector.chatgpt.source.enums.ChatGPTRequestType;
+import org.apache.eventmesh.connector.chatgpt.source.handlers.ChatHandler;
+import org.apache.eventmesh.connector.chatgpt.source.handlers.ParseHandler;
+import org.apache.eventmesh.connector.chatgpt.source.managers.OpenaiManager;
+import org.apache.eventmesh.openconnect.api.config.Config;
+import org.apache.eventmesh.openconnect.api.connector.ConnectorContext;
+import org.apache.eventmesh.openconnect.api.connector.SourceConnectorContext;
+import org.apache.eventmesh.openconnect.api.source.Source;
+import org.apache.eventmesh.openconnect.offsetmgmt.api.data.ConnectRecord;
+import org.apache.eventmesh.openconnect.util.CloudEventUtil;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import io.cloudevents.CloudEvent;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.core.http.HttpServerOptions;
+import io.vertx.ext.web.RequestBody;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.BodyHandler;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class ChatGPTSourceConnector implements Source {
+
+    private static final int DEFAULT_BATCH_SIZE = 10;
+
+    private ChatGPTSourceConfig sourceConfig;
+    private BlockingQueue<CloudEvent> queue;
+    private HttpServer server;
+    private final ExecutorService chatgptSourceExecutorService = ThreadPoolFactory.createThreadPoolExecutor(
+        Runtime.getRuntime().availableProcessors() * 2, Runtime.getRuntime().availableProcessors() * 2, "ChatGPTSourceThread");
+
+    private OpenaiManager openaiManager;
+    private String parsePromptTemplateStr;
+    private ChatHandler chatHandler;
+    private ParseHandler parseHandler;
+
+    @Override
+    public Class<? extends Config> configClass() {
+        return ChatGPTSourceConfig.class;
+    }
+
+    @Override
+    public void init(Config config) {
+        this.sourceConfig = (ChatGPTSourceConfig) config;
+        doInit();
+    }
+
+    @Override
+    public void init(ConnectorContext connectorContext) {
+        SourceConnectorContext sourceConnectorContext = (SourceConnectorContext) connectorContext;
+        this.sourceConfig = (ChatGPTSourceConfig) sourceConnectorContext.getSourceConfig();
+        doInit();
+    }
+
+    public void initParsePrompt() {
+        String parsePromptFileName = sourceConfig.getConnectorConfig().getParsePromptFileName();
+        URL resource = Thread.currentThread().getContextClassLoader().getResource(parsePromptFileName);
+        if (resource == null) {
+            log.warn("cannot find prompt file {} in resources", parsePromptFileName);
+            return;
+        }
+        String filePath = resource.getPath();
+        try (BufferedReader br = new BufferedReader(new FileReader(filePath))) {
+            StringBuilder builder = new StringBuilder();
+            String line;
+            while ((line = br.readLine()) != null) {
+                if (!line.startsWith("#") && StringUtils.isNotBlank(line)) {
+                    builder.append(line).append("\n");
+                }
+            }
+            this.parsePromptTemplateStr = builder.toString();
+        } catch (IOException e) {
+            throw new IllegalStateException("Unable to read file", e);
+        }
+    }
+
+
+    @SuppressWarnings("checkstyle:WhitespaceAround")
+    private void doInit() {
+        initParsePrompt();
+        this.openaiManager = new OpenaiManager(sourceConfig);
+        this.chatHandler = new ChatHandler(this.openaiManager);
+        if (StringUtils.isNotEmpty(parsePromptTemplateStr)) {
+            this.parseHandler = new ParseHandler(openaiManager, parsePromptTemplateStr);
+        }
+        this.queue = new LinkedBlockingQueue<>(1024);
+        final Vertx vertx = Vertx.vertx();
+        final Router router = Router.router(vertx);
+        router.route().path(this.sourceConfig.connectorConfig.getPath()).method(HttpMethod.POST).handler(BodyHandler.create()).handler(ctx -> {
+            try {
+                RequestBody body = ctx.body();
+                ChatGPTRequestDTO bodyObject = body.asPojo(ChatGPTRequestDTO.class);
+                validateRequestDTO(bodyObject);
+                handleRequest(bodyObject, ctx);
+            } catch (Exception e) {
+                handleError(e, ctx);
+            }
+        });
+        this.server = vertx.createHttpServer(new HttpServerOptions().setPort(this.sourceConfig.connectorConfig.getPort())
+            .setIdleTimeout(this.sourceConfig.connectorConfig.getIdleTimeout())).requestHandler(router);

Review Comment:
   The same problem as openaiTimeout will also occur. I added the processing logic and rechecked the places where default values ​​need to be added.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1565370183


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/connector/ChatGPTSourceConnector.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.source.connector;
+
+import org.apache.eventmesh.common.ThreadPoolFactory;
+import org.apache.eventmesh.common.exception.EventMeshException;
+import org.apache.eventmesh.common.utils.AssertUtils;
+import org.apache.eventmesh.connector.chatgpt.source.config.ChatGPTSourceConfig;
+import org.apache.eventmesh.connector.chatgpt.source.dto.ChatGPTRequestDTO;
+import org.apache.eventmesh.connector.chatgpt.source.enums.ChatGPTRequestType;
+import org.apache.eventmesh.connector.chatgpt.source.handlers.ChatHandler;
+import org.apache.eventmesh.connector.chatgpt.source.handlers.ParseHandler;
+import org.apache.eventmesh.connector.chatgpt.source.managers.OpenaiManager;
+import org.apache.eventmesh.openconnect.api.config.Config;
+import org.apache.eventmesh.openconnect.api.connector.ConnectorContext;
+import org.apache.eventmesh.openconnect.api.connector.SourceConnectorContext;
+import org.apache.eventmesh.openconnect.api.source.Source;
+import org.apache.eventmesh.openconnect.offsetmgmt.api.data.ConnectRecord;
+import org.apache.eventmesh.openconnect.util.CloudEventUtil;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import io.cloudevents.CloudEvent;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.core.http.HttpServerOptions;
+import io.vertx.ext.web.RequestBody;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.BodyHandler;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class ChatGPTSourceConnector implements Source {
+
+    private static final int DEFAULT_BATCH_SIZE = 10;
+
+    private ChatGPTSourceConfig sourceConfig;
+    private BlockingQueue<CloudEvent> queue;
+    private HttpServer server;
+    private final ExecutorService chatgptSourceExecutorService = ThreadPoolFactory.createThreadPoolExecutor(
+        Runtime.getRuntime().availableProcessors() * 2, Runtime.getRuntime().availableProcessors() * 2, "ChatGPTSourceThread");
+
+    private OpenaiManager openaiManager;
+    private String parsePromptTemplateStr;
+    private ChatHandler chatHandler;
+    private ParseHandler parseHandler;
+
+    @Override
+    public Class<? extends Config> configClass() {
+        return ChatGPTSourceConfig.class;
+    }
+
+    @Override
+    public void init(Config config) {
+        this.sourceConfig = (ChatGPTSourceConfig) config;
+        doInit();
+    }
+
+    @Override
+    public void init(ConnectorContext connectorContext) {
+        SourceConnectorContext sourceConnectorContext = (SourceConnectorContext) connectorContext;
+        this.sourceConfig = (ChatGPTSourceConfig) sourceConnectorContext.getSourceConfig();
+        doInit();
+    }
+
+    public void initParsePrompt() {
+        String parsePromptFileName = sourceConfig.getConnectorConfig().getParsePromptFileName();
+        URL resource = Thread.currentThread().getContextClassLoader().getResource(parsePromptFileName);
+        AssertUtils.notNull(resource, String.format("cannot find file %s", parsePromptFileName));

Review Comment:
   It's a bit unfriendly if the user is not going to use prompt, but can't start the Connector. Suggest to make it optional: print a log warning when cannot find the loaded prompt template file or when there is no `parsePromptFileName` configuration. Subsequent operations are executed in normal mode.



##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/connector/ChatGPTSourceConnector.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.source.connector;
+
+import org.apache.eventmesh.common.ThreadPoolFactory;
+import org.apache.eventmesh.common.exception.EventMeshException;
+import org.apache.eventmesh.common.utils.AssertUtils;
+import org.apache.eventmesh.connector.chatgpt.source.config.ChatGPTSourceConfig;
+import org.apache.eventmesh.connector.chatgpt.source.dto.ChatGPTRequestDTO;
+import org.apache.eventmesh.connector.chatgpt.source.enums.ChatGPTRequestType;
+import org.apache.eventmesh.connector.chatgpt.source.handlers.ChatHandler;
+import org.apache.eventmesh.connector.chatgpt.source.handlers.ParseHandler;
+import org.apache.eventmesh.connector.chatgpt.source.managers.OpenaiManager;
+import org.apache.eventmesh.openconnect.api.config.Config;
+import org.apache.eventmesh.openconnect.api.connector.ConnectorContext;
+import org.apache.eventmesh.openconnect.api.connector.SourceConnectorContext;
+import org.apache.eventmesh.openconnect.api.source.Source;
+import org.apache.eventmesh.openconnect.offsetmgmt.api.data.ConnectRecord;
+import org.apache.eventmesh.openconnect.util.CloudEventUtil;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import io.cloudevents.CloudEvent;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.core.http.HttpServerOptions;
+import io.vertx.ext.web.RequestBody;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.BodyHandler;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class ChatGPTSourceConnector implements Source {
+
+    private static final int DEFAULT_BATCH_SIZE = 10;
+
+    private ChatGPTSourceConfig sourceConfig;
+    private BlockingQueue<CloudEvent> queue;
+    private HttpServer server;
+    private final ExecutorService chatgptSourceExecutorService = ThreadPoolFactory.createThreadPoolExecutor(
+        Runtime.getRuntime().availableProcessors() * 2, Runtime.getRuntime().availableProcessors() * 2, "ChatGPTSourceThread");
+
+    private OpenaiManager openaiManager;
+    private String parsePromptTemplateStr;
+    private ChatHandler chatHandler;
+    private ParseHandler parseHandler;
+
+    @Override
+    public Class<? extends Config> configClass() {
+        return ChatGPTSourceConfig.class;
+    }
+
+    @Override
+    public void init(Config config) {
+        this.sourceConfig = (ChatGPTSourceConfig) config;
+        doInit();
+    }
+
+    @Override
+    public void init(ConnectorContext connectorContext) {
+        SourceConnectorContext sourceConnectorContext = (SourceConnectorContext) connectorContext;
+        this.sourceConfig = (ChatGPTSourceConfig) sourceConnectorContext.getSourceConfig();
+        doInit();
+    }
+
+    public void initParsePrompt() {
+        String parsePromptFileName = sourceConfig.getConnectorConfig().getParsePromptFileName();
+        URL resource = Thread.currentThread().getContextClassLoader().getResource(parsePromptFileName);
+        AssertUtils.notNull(resource, String.format("cannot find file %s", parsePromptFileName));
+        String filePath = resource.getPath();
+        try (BufferedReader br = new BufferedReader(new FileReader(filePath))) {
+            StringBuilder builder = new StringBuilder();
+            String line;
+            while ((line = br.readLine()) != null) {
+                if (!line.startsWith("#") && StringUtils.isNotBlank(line)) {
+                    builder.append(line).append("\n");
+                }
+            }
+            this.parsePromptTemplateStr = builder.toString();
+        } catch (IOException e) {
+            throw new IllegalStateException("Unable to read file", e);
+        }
+    }
+
+
+    @SuppressWarnings("checkstyle:WhitespaceAround")
+    private void doInit() {
+        initParsePrompt();
+        this.openaiManager = new OpenaiManager(sourceConfig);
+        this.chatHandler = new ChatHandler(this.openaiManager);
+        this.parseHandler = new ParseHandler(openaiManager, parsePromptTemplateStr);
+        this.queue = new LinkedBlockingQueue<>(1024);
+        final Vertx vertx = Vertx.vertx();
+        final Router router = Router.router(vertx);
+        router.route().path(this.sourceConfig.connectorConfig.getPath()).method(HttpMethod.POST).handler(BodyHandler.create()).handler(ctx -> {
+            try {
+                RequestBody body = ctx.body();
+                ChatGPTRequestDTO bodyObject = body.asPojo(ChatGPTRequestDTO.class);
+                validateRequestDTO(bodyObject);
+                handleRequest(bodyObject, ctx);
+            } catch (Exception e) {
+                handleError(e, ctx);
+            }
+        });
+        this.server = vertx.createHttpServer(new HttpServerOptions().setPort(this.sourceConfig.connectorConfig.getPort())
+            .setIdleTimeout(this.sourceConfig.connectorConfig.getIdleTimeout())).requestHandler(router);
+    }
+
+
+    private void validateRequestDTO(ChatGPTRequestDTO bodyObject) {
+        if (bodyObject.getSubject() == null || bodyObject.getDataContentType() == null || bodyObject.getText() == null) {

Review Comment:
   For the convenience of users, I recommend to simplify as much as possible the required items in the user request, such as 'type', 'source', 'subject', 'datacontenttype', can all these have default values when the user does not pass values? Like 'requestType'.



##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/managers/OpenaiManager.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.source.managers;
+
+import static com.theokanning.openai.service.OpenAiService.defaultObjectMapper;
+import static com.theokanning.openai.service.OpenAiService.defaultRetrofit;
+
+import org.apache.eventmesh.common.utils.AssertUtils;
+import org.apache.eventmesh.common.utils.JsonUtils;
+import org.apache.eventmesh.connector.chatgpt.source.config.ChatGPTSourceConfig;
+import org.apache.eventmesh.connector.chatgpt.source.config.OpenaiConfig;
+import org.apache.eventmesh.connector.chatgpt.source.config.OpenaiProxyConfig;
+
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.time.Duration;
+import java.util.List;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.theokanning.openai.client.OpenAiApi;
+import com.theokanning.openai.completion.chat.ChatCompletionRequest;
+import com.theokanning.openai.completion.chat.ChatCompletionRequest.ChatCompletionRequestBuilder;
+import com.theokanning.openai.completion.chat.ChatMessage;
+import com.theokanning.openai.service.OpenAiService;
+
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+
+import okhttp3.OkHttpClient;
+import retrofit2.Retrofit;
+
+
+@Slf4j
+public class OpenaiManager {
+
+    @Getter
+    private OpenAiService openAiService;
+
+    private String chatCompletionRequestTemplateStr;
+
+    public OpenaiManager(ChatGPTSourceConfig sourceConfig) {
+        initOpenAi(sourceConfig);
+    }
+
+    public String getResult(ChatCompletionRequest req) {
+        StringBuilder gptData = new StringBuilder();
+        try {
+            openAiService.createChatCompletion(req).getChoices()
+                .forEach(chatCompletionChoice -> gptData.append(chatCompletionChoice.getMessage().getContent()));
+        } catch (Exception e) {
+            log.error("Failed to generate GPT connection record: {}", e.getMessage());
+        }
+        return gptData.toString();
+    }
+
+    public ChatCompletionRequest newChatCompletionRequest(List<ChatMessage> chatMessages) {
+        ChatCompletionRequest request = JsonUtils.parseObject(chatCompletionRequestTemplateStr, ChatCompletionRequest.class);
+        request.setMessages(chatMessages);
+        return request;
+    }
+
+    private void initOpenAi(ChatGPTSourceConfig sourceConfig) {
+        OpenaiConfig openaiConfig = sourceConfig.getOpenaiConfig();
+        AssertUtils.isTrue(openaiConfig.getTimeout() > 0, "openaiTimeout must be >= 0");
+        boolean proxyEnable = sourceConfig.connectorConfig.isProxyEnable();
+        if (proxyEnable) {

Review Comment:
   Does proxy mean that Connector accesses ChatGPT through a proxy instead of directly?



##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/managers/OpenaiManager.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.source.managers;
+
+import static com.theokanning.openai.service.OpenAiService.defaultObjectMapper;
+import static com.theokanning.openai.service.OpenAiService.defaultRetrofit;
+
+import org.apache.eventmesh.common.utils.AssertUtils;
+import org.apache.eventmesh.common.utils.JsonUtils;
+import org.apache.eventmesh.connector.chatgpt.source.config.ChatGPTSourceConfig;
+import org.apache.eventmesh.connector.chatgpt.source.config.OpenaiConfig;
+import org.apache.eventmesh.connector.chatgpt.source.config.OpenaiProxyConfig;
+
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.time.Duration;
+import java.util.List;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.theokanning.openai.client.OpenAiApi;
+import com.theokanning.openai.completion.chat.ChatCompletionRequest;
+import com.theokanning.openai.completion.chat.ChatCompletionRequest.ChatCompletionRequestBuilder;
+import com.theokanning.openai.completion.chat.ChatMessage;
+import com.theokanning.openai.service.OpenAiService;
+
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+
+import okhttp3.OkHttpClient;
+import retrofit2.Retrofit;
+
+
+@Slf4j
+public class OpenaiManager {
+
+    @Getter
+    private OpenAiService openAiService;
+
+    private String chatCompletionRequestTemplateStr;
+
+    public OpenaiManager(ChatGPTSourceConfig sourceConfig) {
+        initOpenAi(sourceConfig);
+    }
+
+    public String getResult(ChatCompletionRequest req) {
+        StringBuilder gptData = new StringBuilder();
+        try {
+            openAiService.createChatCompletion(req).getChoices()
+                .forEach(chatCompletionChoice -> gptData.append(chatCompletionChoice.getMessage().getContent()));
+        } catch (Exception e) {
+            log.error("Failed to generate GPT connection record: {}", e.getMessage());
+        }
+        return gptData.toString();
+    }
+
+    public ChatCompletionRequest newChatCompletionRequest(List<ChatMessage> chatMessages) {
+        ChatCompletionRequest request = JsonUtils.parseObject(chatCompletionRequestTemplateStr, ChatCompletionRequest.class);
+        request.setMessages(chatMessages);
+        return request;
+    }
+
+    private void initOpenAi(ChatGPTSourceConfig sourceConfig) {
+        OpenaiConfig openaiConfig = sourceConfig.getOpenaiConfig();
+        AssertUtils.isTrue(openaiConfig.getTimeout() > 0, "openaiTimeout must be >= 0");

Review Comment:
   A similar suggestion. To reduce the required configuration items for user convenience, use default values as much as possible when they are missing. You can check if there are any other similar places that can be handled in this way.



##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/resources/prompt:
##########
@@ -0,0 +1,44 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+You are an AI assistant named CloudEventsConverter. avoid escape characters .
+Your task is to construct a JSON object in CloudEvents format. Based on the field name and field description in the 'data' field of the CloudEvents formatted JSON object, convert the input text provided by the user into the content of the 'data' field, which must comply with the specifications of the content of the 'datacontenttype' field.
+The role is :
+ - If the 'datacontenttype' field content is 'application/json', then the' data 'field content should be a JSON object,
+ - else If the 'datacontenttype' field content is not 'application/json' and is 'application/xml', then the' data 'field content should be a string in XML format and the outermost of XML format is <data> </data>, inside is the XML generated by you based on field info;
+ - else the 'datacontenttype' field content is not 'application/json' and 'application/xml', then the' data 'field content is string of the 'text' field content;
+Except for the content of the data field, all other values should be set to and cannot be modified. Finally, return to me the JSON object in CloudEvents format that you constructed
+
+The following text is the field name and field description in the 'data' field of the CloudEvents-formatted JSON object, extract the following information:
+<BEGIN FIELD INFO>
+${fields}
+<END FIELD INFO>
+
+text:  ${text}
+
+The output should be a markdown code snippet formatted in the following schema, including the leading and trailing "```json" and "```":
+```json
+{
+  "specversion": string,  Set to "1.0"
+  "type": string,  Set to  ${type}
+  "source": string, Set to  ${source}
+  "subject": string, Set to ${subject}
+  "id": string, Set to  ${id}
+  "time": string, Set to  ${time}

Review Comment:
   When this PR is merged, I hope you can add the documentation for the use of the Connector here https://github.com/apache/eventmesh/pull/4817#pullrequestreview-1985067036 . In the documentation, It will be nice to provide some clarity on the use of this prompt file, the construction of the user's request body when using prompt mode, and the correspondence between the two.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "jevinjiang (via GitHub)" <gi...@apache.org>.
jevinjiang commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1564663115


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/resources/prompt:
##########
@@ -0,0 +1,44 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+You are an AI assistant named CloudEventsConverter. avoid escape characters .
+Your task is to construct a JSON object in CloudEvents format. Based on the field name and field description in the 'data' field of the CloudEvents formatted JSON object, convert the input text provided by the user into the content of the 'data' field, which must comply with the specifications of the content of the 'datacontenttype' field.
+The role is :
+ - If the 'datacontenttype' field content is 'application/json', then the' data 'field content should be a JSON object,
+ - else If the 'datacontenttype' field content is not 'application/json' and is 'application/xml', then the' data 'field content should be a string in XML format and the outermost of XML format is <data> </data>, inside is the XML generated by you based on field info;
+ - else the 'datacontenttype' field content is not 'application/json' and 'application/xml', then the' data 'field content is string of the 'text' field content;
+Except for the content of the data field, all other values should be set to and cannot be modified. Finally, return to me the JSON object in CloudEvents format that you constructed
+
+The following text is the field name and field description in the 'data' field of the CloudEvents-formatted JSON object, extract the following information:
+<BEGIN FIELD INFO>
+${fields}
+<END FIELD INFO>
+
+text:  ${text}
+
+The output should be a markdown code snippet formatted in the following schema, including the leading and trailing "```json" and "```":
+```json
+{
+  "specversion": string,  Set to "1.0"
+  "type": string,  Set to  ${type}
+  "source": string, Set to  ${source}
+  "subject": string, Set to ${subject}
+  "id": string, Set to  ${id}
+  "time": string, Set to  ${time}
+  "datacontenttype": string, Set to  ${datacontenttype}

Review Comment:
   @pandaapo  the purpose of the type is PARSE is to parse the unstructured data input by the user into a json or xml structured data set into the data field in cloudevent. text is user-defined unstructured data, chatgpt according to field info Extract information from text and convert it into structured data,Return to finally give me a complete cloud event.
   
   PARSE 的目的是,根据用户输入的非结构化数据(text)解析为一个 json 或者 xml 的结构化数据, 然后放入cloudevent 中的data字段中,text 是用户自定义的非结构化数据,chatgpt 根据fields传入的信息从text中提取信息,转化为结构化数据,最终返回给我一个完整的cloudevent。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "jevinjiang (via GitHub)" <gi...@apache.org>.
jevinjiang commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1564633149


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/resources/prompt:
##########
@@ -0,0 +1,44 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+You are an AI assistant named CloudEventsConverter. avoid escape characters .
+Your task is to construct a JSON object in CloudEvents format. Based on the field name and field description in the 'data' field of the CloudEvents formatted JSON object, convert the input text provided by the user into the content of the 'data' field, which must comply with the specifications of the content of the 'datacontenttype' field.
+The role is :
+ - If the 'datacontenttype' field content is 'application/json', then the' data 'field content should be a JSON object,
+ - else If the 'datacontenttype' field content is not 'application/json' and is 'application/xml', then the' data 'field content should be a string in XML format and the outermost of XML format is <data> </data>, inside is the XML generated by you based on field info;
+ - else the 'datacontenttype' field content is not 'application/json' and 'application/xml', then the' data 'field content is string of the 'text' field content;
+Except for the content of the data field, all other values should be set to and cannot be modified. Finally, return to me the JSON object in CloudEvents format that you constructed
+
+The following text is the field name and field description in the 'data' field of the CloudEvents-formatted JSON object, extract the following information:
+<BEGIN FIELD INFO>
+${fields}
+<END FIELD INFO>
+
+text:  ${text}
+
+The output should be a markdown code snippet formatted in the following schema, including the leading and trailing "```json" and "```":
+```json
+{
+  "specversion": string,  Set to "1.0"
+  "type": string,  Set to  ${type}
+  "source": string, Set to  ${source}
+  "subject": string, Set to ${subject}
+  "id": string, Set to  ${id}
+  "time": string, Set to  ${time}
+  "datacontenttype": string, Set to  ${datacontenttype}

Review Comment:
   @pandaapo Yes, this file named prompt is actually a prompt template, which replaces the content in ${} according to the user's input. The following is an example of a final prompt:
   ```
   You are an AI assistant named CloudEventsConverter. avoid escape characters .
   Your task is to construct a JSON object in CloudEvents format. Based on the field name and field description in the 'data' field of the CloudEvents formatted JSON object, convert the input text provided by the user into the content of the 'data' field, which must comply with the specifications of the content of the 'datacontenttype' field.
   The role is :
    - If the 'datacontenttype' field content is 'application/json', then the' data 'field content should be a JSON object,
    - else If the 'datacontenttype' field content is not 'application/json' and is 'application/xml', then the' data 'field content should be a string in XML format and the outermost of XML format is <data> </data>, inside is the XML generated by you based on field info;
    - else the 'datacontenttype' field content is not 'application/json' and 'application/xml', then the' data 'field content is string of the 'text' field content;
   Except for the content of the data field, all other values should be set to and cannot be modified. Finally, return to me the JSON object in CloudEvents format that you constructed
   The following text is the field name and field description in the 'data' field of the CloudEvents-formatted JSON object, extract the following information:
   <BEGIN FIELD INFO>
   orderNo:this is order number
   address:this is a address
   phone:this is phone number
   <END FIELD INFO>
   text:  User 13356288979 from Tianjin store placed an order with order number 11221122
   The output should be a markdown code snippet formatted in the following schema, including the leading and trailing "```json" and "```":
   ```json
   {
     "specversion": string,  Set to "1.0"
     "type": string,  Set to  com.example.someevent
     "source": string, Set to  /mycontext
     "subject": string, Set to test
     "id": string, Set to  9aae39c3-7641-474a-b181-f4560d6aee3b
     "time": string, Set to  2024-04-14T18:59:44.365946+08:00
     "datacontenttype": string, Set to  application/json
     "data": object or string
   }
   
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1573084688


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/config/ChatGPTSourceConnectorConfig.java:
##########
@@ -28,7 +28,7 @@ public class ChatGPTSourceConnectorConfig {
 
     private int port = 3756;
 
-    private int idleTimeout = 30;
+    private int idleTimeout = 0;

Review Comment:
   Since the default value is 0, can this assignment code be removed? Similarly with `private long timeout = 0`.



##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/connector/ChatGPTSourceConnector.java:
##########
@@ -150,8 +153,8 @@ private void doInit() {
 
 
     private void validateRequestDTO(ChatGPTRequestDTO bodyObject) {
-        if (bodyObject.getSubject() == null || bodyObject.getDataContentType() == null || bodyObject.getText() == null) {
-            throw new IllegalArgumentException("Attributes 'subject', 'datacontenttype', and 'text' cannot be null");
+        if (bodyObject.getSubject() == null || bodyObject.getText() == null) {

Review Comment:
   Since `subject` has a default value, is it still necessary to check the null value of `subject` here? Maybe change it to blank check? If change it to blank check, can `text` also be changed  to blank check?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1573100620


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/test/java/org/apache/eventmesh/connector/chatgpt/source/connector/ChatGPTSourceConnectorTest.java:
##########
@@ -108,17 +108,6 @@ void testPoll() throws Exception {
 
         List<ConnectRecord> res1 = connector.poll();
         Assertions.assertEquals(batchSize, res1.size());
-
-        // test invalid requests
-        TestEvent event = new TestEvent();
-        event.type = "com.example.someevent";
-        event.source = "/mycontext";
-        event.datacontenttype = "text/plain";
-        event.text = expectedMessage;
-        HttpPost invalidPost = new HttpPost(uri);
-        invalidPost.setEntity(new StringEntity(JsonUtils.toJSONString(event)));
-        HttpResponse resp = httpClient.execute(invalidPost);
-        Assertions.assertEquals(HttpStatus.SC_BAD_REQUEST, resp.getStatusLine().getStatusCode());

Review Comment:
   > Note the file conflict below.
   
   Try to draw your attention.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "jevinjiang (via GitHub)" <gi...@apache.org>.
jevinjiang commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1565962855


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/managers/OpenaiManager.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.chatgpt.source.managers;
+
+import static com.theokanning.openai.service.OpenAiService.defaultObjectMapper;
+import static com.theokanning.openai.service.OpenAiService.defaultRetrofit;
+
+import org.apache.eventmesh.common.utils.AssertUtils;
+import org.apache.eventmesh.common.utils.JsonUtils;
+import org.apache.eventmesh.connector.chatgpt.source.config.ChatGPTSourceConfig;
+import org.apache.eventmesh.connector.chatgpt.source.config.OpenaiConfig;
+import org.apache.eventmesh.connector.chatgpt.source.config.OpenaiProxyConfig;
+
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.time.Duration;
+import java.util.List;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.theokanning.openai.client.OpenAiApi;
+import com.theokanning.openai.completion.chat.ChatCompletionRequest;
+import com.theokanning.openai.completion.chat.ChatCompletionRequest.ChatCompletionRequestBuilder;
+import com.theokanning.openai.completion.chat.ChatMessage;
+import com.theokanning.openai.service.OpenAiService;
+
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+
+import okhttp3.OkHttpClient;
+import retrofit2.Retrofit;
+
+
+@Slf4j
+public class OpenaiManager {
+
+    @Getter
+    private OpenAiService openAiService;
+
+    private String chatCompletionRequestTemplateStr;
+
+    public OpenaiManager(ChatGPTSourceConfig sourceConfig) {
+        initOpenAi(sourceConfig);
+    }
+
+    public String getResult(ChatCompletionRequest req) {
+        StringBuilder gptData = new StringBuilder();
+        try {
+            openAiService.createChatCompletion(req).getChoices()
+                .forEach(chatCompletionChoice -> gptData.append(chatCompletionChoice.getMessage().getContent()));
+        } catch (Exception e) {
+            log.error("Failed to generate GPT connection record: {}", e.getMessage());
+        }
+        return gptData.toString();
+    }
+
+    public ChatCompletionRequest newChatCompletionRequest(List<ChatMessage> chatMessages) {
+        ChatCompletionRequest request = JsonUtils.parseObject(chatCompletionRequestTemplateStr, ChatCompletionRequest.class);
+        request.setMessages(chatMessages);
+        return request;
+    }
+
+    private void initOpenAi(ChatGPTSourceConfig sourceConfig) {
+        OpenaiConfig openaiConfig = sourceConfig.getOpenaiConfig();
+        AssertUtils.isTrue(openaiConfig.getTimeout() > 0, "openaiTimeout must be >= 0");
+        boolean proxyEnable = sourceConfig.connectorConfig.isProxyEnable();
+        if (proxyEnable) {

Review Comment:
   yes...    network ...  Is a huge wall



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1570371574


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/test/java/org/apache/eventmesh/connector/chatgpt/source/connector/ChatGPTSourceConnectorTest.java:
##########
@@ -108,17 +108,6 @@ void testPoll() throws Exception {
 
         List<ConnectRecord> res1 = connector.poll();
         Assertions.assertEquals(batchSize, res1.size());
-
-        // test invalid requests
-        TestEvent event = new TestEvent();
-        event.type = "com.example.someevent";
-        event.source = "/mycontext";
-        event.datacontenttype = "text/plain";
-        event.text = expectedMessage;
-        HttpPost invalidPost = new HttpPost(uri);
-        invalidPost.setEntity(new StringEntity(JsonUtils.toJSONString(event)));
-        HttpResponse resp = httpClient.execute(invalidPost);
-        Assertions.assertEquals(HttpStatus.SC_BAD_REQUEST, resp.getStatusLine().getStatusCode());

Review Comment:
   What is your reason for removing this piece of your test code?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1570371574


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/test/java/org/apache/eventmesh/connector/chatgpt/source/connector/ChatGPTSourceConnectorTest.java:
##########
@@ -108,17 +108,6 @@ void testPoll() throws Exception {
 
         List<ConnectRecord> res1 = connector.poll();
         Assertions.assertEquals(batchSize, res1.size());
-
-        // test invalid requests
-        TestEvent event = new TestEvent();
-        event.type = "com.example.someevent";
-        event.source = "/mycontext";
-        event.datacontenttype = "text/plain";
-        event.text = expectedMessage;
-        HttpPost invalidPost = new HttpPost(uri);
-        invalidPost.setEntity(new StringEntity(JsonUtils.toJSONString(event)));
-        HttpResponse resp = httpClient.execute(invalidPost);
-        Assertions.assertEquals(HttpStatus.SC_BAD_REQUEST, resp.getStatusLine().getStatusCode());

Review Comment:
   What is your reason for removing this piece of your test code? Note the file conflict below.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "jevinjiang (via GitHub)" <gi...@apache.org>.
jevinjiang commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1564656387


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/resources/prompt:
##########
@@ -0,0 +1,44 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+You are an AI assistant named CloudEventsConverter. avoid escape characters .
+Your task is to construct a JSON object in CloudEvents format. Based on the field name and field description in the 'data' field of the CloudEvents formatted JSON object, convert the input text provided by the user into the content of the 'data' field, which must comply with the specifications of the content of the 'datacontenttype' field.
+The role is :
+ - If the 'datacontenttype' field content is 'application/json', then the' data 'field content should be a JSON object,
+ - else If the 'datacontenttype' field content is not 'application/json' and is 'application/xml', then the' data 'field content should be a string in XML format and the outermost of XML format is <data> </data>, inside is the XML generated by you based on field info;
+ - else the 'datacontenttype' field content is not 'application/json' and 'application/xml', then the' data 'field content is string of the 'text' field content;
+Except for the content of the data field, all other values should be set to and cannot be modified. Finally, return to me the JSON object in CloudEvents format that you constructed
+
+The following text is the field name and field description in the 'data' field of the CloudEvents-formatted JSON object, extract the following information:
+<BEGIN FIELD INFO>
+${fields}
+<END FIELD INFO>
+
+text:  ${text}
+
+The output should be a markdown code snippet formatted in the following schema, including the leading and trailing "```json" and "```":
+```json
+{
+  "specversion": string,  Set to "1.0"
+  "type": string,  Set to  ${type}
+  "source": string, Set to  ${source}
+  "subject": string, Set to ${subject}
+  "id": string, Set to  ${id}
+  "time": string, Set to  ${time}
+  "datacontenttype": string, Set to  ${datacontenttype}

Review Comment:
   @pandaapo 
   chatgpt result:
   ```json
   {
     "specversion": "1.0",
     "type": "com.example.someevent",
     "source": "/mycontext",
     "subject": "test",
     "id": "0171d995-f97a-4533-9c70-e2fb14fa297e",
     "time": "2024-04-14T20:01:19.939919+08:00",
     "datacontenttype": "application/json",
     "data": {
       "orderNo": "11221122",
       "address": "Tianjin store",
       "phone": "13356288979"
     }
   }
   ```
   
   
   request:
   ```json
   {
       "requestType": "PARSE",
       "type": "com.example.someevent",
       "source": "/mycontext",
       "subject": "test",
       "datacontenttype": "application/json",
       "text": "User 13356288979 from Tianjin store placed an order with order number 11221122",
       "fields": "orderNo:this is order number;address:this is a address;phone:this is phone number"
   }
   ```
   
   If your data content type is application/xml, then chatgpt return, <data> in xml is the root path specified by me by default.:
   ```json
   {
     "specversion": "1.0",
     "type": "com.example.someevent",
     "source": "/mycontext",
     "subject": "test",
     "id": "ee446a10-f7eb-4596-a81b-bdc79d45bca5",
     "time": "2024-04-14T20:02:36.738191+08:00",
     "datacontenttype": "application/xml",
     "data": "<data><orderNo>11221122</orderNo><address>Tianjin store</address><phone>13356288979</phone></data>"
   }
   
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1564661386


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/resources/prompt:
##########
@@ -0,0 +1,44 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+You are an AI assistant named CloudEventsConverter. avoid escape characters .
+Your task is to construct a JSON object in CloudEvents format. Based on the field name and field description in the 'data' field of the CloudEvents formatted JSON object, convert the input text provided by the user into the content of the 'data' field, which must comply with the specifications of the content of the 'datacontenttype' field.
+The role is :
+ - If the 'datacontenttype' field content is 'application/json', then the' data 'field content should be a JSON object,
+ - else If the 'datacontenttype' field content is not 'application/json' and is 'application/xml', then the' data 'field content should be a string in XML format and the outermost of XML format is <data> </data>, inside is the XML generated by you based on field info;
+ - else the 'datacontenttype' field content is not 'application/json' and 'application/xml', then the' data 'field content is string of the 'text' field content;
+Except for the content of the data field, all other values should be set to and cannot be modified. Finally, return to me the JSON object in CloudEvents format that you constructed
+
+The following text is the field name and field description in the 'data' field of the CloudEvents-formatted JSON object, extract the following information:
+<BEGIN FIELD INFO>
+${fields}
+<END FIELD INFO>
+
+text:  ${text}
+
+The output should be a markdown code snippet formatted in the following schema, including the leading and trailing "```json" and "```":
+```json
+{
+  "specversion": string,  Set to "1.0"
+  "type": string,  Set to  ${type}
+  "source": string, Set to  ${source}
+  "subject": string, Set to ${subject}
+  "id": string, Set to  ${id}
+  "time": string, Set to  ${time}
+  "datacontenttype": string, Set to  ${datacontenttype}

Review Comment:
   What is the purpose of the "'text': 'User 13356288979 from Tianjin store placed an order with order number 11221122'"  in this request?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#discussion_r1564686507


##########
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/resources/prompt:
##########
@@ -0,0 +1,44 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+You are an AI assistant named CloudEventsConverter. avoid escape characters .
+Your task is to construct a JSON object in CloudEvents format. Based on the field name and field description in the 'data' field of the CloudEvents formatted JSON object, convert the input text provided by the user into the content of the 'data' field, which must comply with the specifications of the content of the 'datacontenttype' field.
+The role is :
+ - If the 'datacontenttype' field content is 'application/json', then the' data 'field content should be a JSON object,
+ - else If the 'datacontenttype' field content is not 'application/json' and is 'application/xml', then the' data 'field content should be a string in XML format and the outermost of XML format is <data> </data>, inside is the XML generated by you based on field info;
+ - else the 'datacontenttype' field content is not 'application/json' and 'application/xml', then the' data 'field content is string of the 'text' field content;
+Except for the content of the data field, all other values should be set to and cannot be modified. Finally, return to me the JSON object in CloudEvents format that you constructed
+
+The following text is the field name and field description in the 'data' field of the CloudEvents-formatted JSON object, extract the following information:
+<BEGIN FIELD INFO>
+${fields}
+<END FIELD INFO>
+
+text:  ${text}
+
+The output should be a markdown code snippet formatted in the following schema, including the leading and trailing "```json" and "```":
+```json
+{
+  "specversion": string,  Set to "1.0"
+  "type": string,  Set to  ${type}
+  "source": string, Set to  ${source}
+  "subject": string, Set to ${subject}
+  "id": string, Set to  ${id}
+  "time": string, Set to  ${time}
+  "datacontenttype": string, Set to  ${datacontenttype}

Review Comment:
   What happens if the content of "text" entered by the user does not match the parse rule in "fields"? (I want to get clarity on some functionality to reduce the difficulty of review)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#issuecomment-2041526552

   I came up with a way that allows users to specify whether or not to use prompts:
   
   ![ChatGPT-Source-Connector_prompts_v2](https://github.com/apache/eventmesh/assets/41445332/e83b4ff1-e6ce-4c11-9f84-4bc7b33e3c06)
   
   Users can indicate in the request parameters of the Web API whether they want to use predefined prompts templates and which template to use.
   
   The ChatGPT source connector needs to check if the returned result from ChatGPT, when prompts templates are enabled by the user, is in the correct JSON format. If not, the entire result will be wrapped in a CloudEvent. However, this checking process may not save much performance overhead compared to deserialization. By not relying on the JSON format generated by ChatGPT, more stable results can be obtained.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #4047] Support chatGPT source connector (eventmesh)

Posted by "jevinjiang (via GitHub)" <gi...@apache.org>.
jevinjiang commented on PR #4817:
URL: https://github.com/apache/eventmesh/pull/4817#issuecomment-2046751309

   @Pil0tXia @pandaapo please review again.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org