-
Notifications
You must be signed in to change notification settings - Fork 642
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [ISSUE #4047] Support chatGPT source connector * [ISSUE #4047] Add OpenAI configuration and adjust DTO * [ISSUE #4047] Join parse request support * [ISSUE #4047] impl Parse request * [ISSUE #4047] fix code style * [ISSUE #4047] fix code style * [ISSUE #4047] fix dependencies check failed * [ISSUE #4047] fix dependencies check * [ISSUE #4047] fix license check * [ISSUE #4047] fix review question * [ISSUE #4047] fix review question * [ISSUE #4047] add default value * [ISSUE #4047] fix test * [ISSUE #4047] default timeout value is zero , not timeout . * [ISSUE #4047] fix review * [ISSUE #4047] fix license check --------- Co-authored-by: JiangShuJu <[email protected]>
- Loading branch information
1 parent
a899e54
commit fdb96d8
Showing
22 changed files
with
1,297 additions
and
0 deletions.
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; | ||
|
||
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; | ||
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.