forked from apache/eventmesh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ISSUE apache#4047] Add OpenAI configuration and adjust DTO
- Loading branch information
1 parent
8b15c8b
commit 317ffb4
Showing
10 changed files
with
251 additions
and
90 deletions.
There are no files selected for viewing
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
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
25 changes: 25 additions & 0 deletions
25
...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,25 @@ | ||
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; | ||
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; | ||
private List<String> stop; | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
...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,12 @@ | ||
package org.apache.eventmesh.connector.chatgpt.source.config; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class OpenaiProxyConfig { | ||
|
||
private String host; | ||
|
||
private int port; | ||
|
||
} |
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
26 changes: 26 additions & 0 deletions
26
...pt/src/main/java/org/apache/eventmesh/connector/chatgpt/source/dto/ChatGPTRequestDTO.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,26 @@ | ||
package org.apache.eventmesh.connector.chatgpt.source.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class ChatGPTRequestDTO { | ||
|
||
private String source; | ||
|
||
private String subject; | ||
|
||
@JsonProperty("datacontenttype") | ||
private String dataContentType; | ||
|
||
private String type; | ||
|
||
private String prompt; | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
eventmesh-connectors/eventmesh-connector-chatgpt/src/main/resources/prompt
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,21 @@ | ||
You are an AI assistant named CloudEventsConverter. Your task is to convert input text provided by the user into a CloudEvents-formatted JSON object, avoid escape characters . | ||
|
||
For the following text, extract the following information: | ||
|
||
Create a CloudEvents-formatted JSON object with the following fields: | ||
- specversion: Set to "1.0" (the current CloudEvents specification version) | ||
- type: Set to \\\ {type} \\\ | ||
- source: Set to \\\ {source} \\\ | ||
- id: Set to \\\ {id} \\\ (Generate a unique identifier for the event (e.g., "A234-1234-1234")) | ||
- time: Set to \\\ {time} \\\ (the current timestamp in ISO 8601 format. e.g:"2023-03-25T12:34:56.789Z") | ||
- datacontenttype: Set to \\\ {datacontenttype} \\\ | ||
- data: Set to the input text provided by the user | ||
\\\ | ||
{fields} | ||
\\\ | ||
|
||
text: \\\ {text} \\\ | ||
|
||
If any of the fields marked as \\\ {} \\\ are null or empty, use a default value. | ||
|
||
Return the CloudEvents-formatted JSON object to the user,The format of the data field matches the datacontenttype,Just need to return the JSON object, nothing else needs to be returned。 |
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
Oops, something went wrong.