Skip to main content
版本:v2.0.0

ChatGPT (OpenAI) connector

Audience: operators bridging EventMesh with ChatGPT (OpenAI). OpenAI bridge. Source exposes an HTTP prompt endpoint: a client POSTs a prompt, the connector optionally completes it through the OpenAI REST API and emits both as a CloudEvent. Sink forwards events to a webhook (generic).


Classes

DirectionClassBehavior
Sourceorg.apache.eventmesh.connector.chatgpt.source.ChatgptSourceConnectorJDK HttpServer on connector.port+connector.path accepts {"prompt": ...}; with connector.openaiApiKey set it calls chat-completions (connector.model) and emits {prompt, answer}; without a key it emits the prompt only. poll() drains the buffer.
Sinkorg.apache.eventmesh.connector.chatgpt.sink.ChatgptSinkConnectorPOSTs each CloudEvent's payload to connector.webhookUrl.

Source configuration

KeyDefaultDescription
connector.port8090HTTP listen port
connector.path/chatgptHTTP listen path
connector.openaiApiKey``OpenAI API key (empty = no completion)
connector.modelgpt-3.5-turboChat-completion model
connector.pollTimeoutMs1000Buffer drain wait in ms

Sink configuration

KeyDefaultDescription
connector.webhookUrl``Webhook to POST events into

Running

curl -X POST http://worker:8090/chatgpt -d '{"prompt":"hi"}' then bin/start-connector.sh with -Dconnector.class=...ChatgptSourceConnector -Dconnector.mode=source -Dconnector.openaiApiKey=sk-...