-
Notifications
You must be signed in to change notification settings - Fork 641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ISSUE #4047] Support chatGPT source connector #4817
Merged
Merged
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8b15c8b
[ISSUE #4047] Support chatGPT source connector
jevinjiang 317ffb4
[ISSUE #4047] Add OpenAI configuration and adjust DTO
jevinjiang 608d169
[ISSUE #4047] Join parse request support
e2dcf44
[ISSUE #4047] impl Parse request
jevinjiang ca42ded
[ISSUE #4047] fix code style
jevinjiang 3331997
[ISSUE #4047] fix code style
jevinjiang 126b29d
[ISSUE #4047] fix dependencies check failed
jevinjiang e79795f
[ISSUE #4047] fix dependencies check
5f600c6
[ISSUE #4047] fix license check
6ccc530
[ISSUE #4047] fix review question
010e2a9
[ISSUE #4047] fix review question
7bfadbb
[ISSUE #4047] add default value
c849912
[ISSUE #4047] fix test
0bffda8
[ISSUE #4047] default timeout value is zero , not timeout .
7343c76
[ISSUE #4047] fix review
aab792f
Merge branch 'master' into fix_patch_4047
jevinjiang 86bf139
[ISSUE #4047] fix license check
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
eventmesh-connectors/eventmesh-connector-chatgpt/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
dependencies { | ||
api project(":eventmesh-openconnect:eventmesh-openconnect-java") | ||
implementation project(":eventmesh-common") | ||
implementation 'com.theokanning.openai-gpt3-java:service:0.18.2' | ||
implementation 'io.cloudevents:cloudevents-http-vertx:2.3.0' | ||
implementation 'io.vertx:vertx-web:4.4.6' | ||
|
||
testImplementation "org.apache.httpcomponents:httpclient" | ||
compileOnly 'org.projectlombok:lombok' | ||
annotationProcessor 'org.projectlombok:lombok' | ||
} |
18 changes: 18 additions & 0 deletions
18
eventmesh-connectors/eventmesh-connector-chatgpt/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# 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. | ||
# | ||
pluginType=connector | ||
pluginName=chatgpt |
32 changes: 32 additions & 0 deletions
32
...tgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/config/ChatGPTServerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* 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.config; | ||
|
||
import org.apache.eventmesh.openconnect.api.config.Config; | ||
|
||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
public class ChatGPTServerConfig extends Config { | ||
|
||
private boolean sourceEnable; | ||
|
||
private boolean sinkEnable; | ||
} |
40 changes: 40 additions & 0 deletions
40
...gpt/src/main/java/org/apache/eventmesh/connector/chatgpt/server/ChatGPTConnectServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
...c/main/java/org/apache/eventmesh/connector/chatgpt/source/config/ChatGPTSourceConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* 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.config; | ||
|
||
import org.apache.eventmesh.openconnect.api.config.SourceConfig; | ||
|
||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
public class ChatGPTSourceConfig extends SourceConfig { | ||
|
||
public ChatGPTSourceConnectorConfig connectorConfig; | ||
|
||
public OpenaiProxyConfig openaiProxyConfig; | ||
|
||
public OpenaiConfig openaiConfig; | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
...va/org/apache/eventmesh/connector/chatgpt/source/config/ChatGPTSourceConnectorConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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.config; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class ChatGPTSourceConnectorConfig { | ||
|
||
private String connectorName = "chatgptSource"; | ||
|
||
private String path = "/chatgpt"; | ||
|
||
private int port = 3756; | ||
|
||
private int idleTimeout = 30; | ||
|
||
private boolean proxyEnable = false; | ||
|
||
private String parsePromptFileName = "prompt"; | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
...tgpt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/config/OpenaiConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* 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.config; | ||
|
||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class OpenaiConfig { | ||
|
||
private String token; | ||
private String model = "gpt-3.5-turbo"; | ||
private long timeout = 30; | ||
private Double temperature; | ||
private Integer maxTokens; | ||
private Boolean logprob; | ||
private Double topLogprobs; | ||
private Map<String, Integer> logitBias; | ||
private Double frequencyPenalty; | ||
private Double presencePenalty; | ||
private String user = "eventMesh"; | ||
private List<String> stop; | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...src/main/java/org/apache/eventmesh/connector/chatgpt/source/config/OpenaiProxyConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* 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.config; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class OpenaiProxyConfig { | ||
|
||
private String host; | ||
|
||
private int port; | ||
|
||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we have no idea what kind of scenarios the chatgpt sink connector needs to be used in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jevinjiang this review is waiting for your response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pil0tXia @pandaapo
Sorry, in fact, I can't think of a specific application scenario about sink connector too.
The following are possible scenarios:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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中, 生成研报等文章内容