Skip to content

Instantly share code, notes, and snippets.

@TimoGlastra
Created October 14, 2023 16:23
Show Gist options
  • Save TimoGlastra/26091e29567f5f7aced7fb5f2c2efe92 to your computer and use it in GitHub Desktop.
Save TimoGlastra/26091e29567f5f7aced7fb5f2c2efe92 to your computer and use it in GitHub Desktop.
Paradym - Chatbot over DIDComm using basic messaging and ChatGPT
name: Create connection and chat
trigger:
type: api
actions:
- id: createConnection
name: didcomm/createConnection@v1
attributes:
label: Ask me anything
- id: sendBasicMessage
name: didcomm/sendBasicMessage@v1
attributes:
connectionId: $.actions.createConnection.output.connection.connectionId
message: Hey there! 👋
- id: sendBasicMessage2
name: didcomm/sendBasicMessage@v1
attributes:
connectionId: $.actions.createConnection.output.connection.connectionId
message: >
It's good to be connected. As my name suggests, you can ask me anything.
I'll do my best to reply quickly.
name: Reply using chatGPT
trigger:
type: didcommBasicMessageReceived
input:
type: object
actions:
- id: getResponse
name: general/fetch@v1
attributes:
method: POST
url: https://api.openai.com/v1/chat/completions
headers:
"Content-Type": application/json
Authorization: Bearer <YOUR OPENAI API KEY>
payload:
{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "You are an \"Ask me anything\" chatbot. You are directly connected to an user, and are ready to answer questions. Try to be a bit funny, witty and use emojis . You can call yourself \"Paradym's Ask me anything chatbot\"."
},
{
"role": "user",
"content": $.input.basicMessage.message
}
],
"temperature": 1,
"max_tokens": 256,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0
}
- id: sendResponse
name: didcomm/sendBasicMessage@v1
attributes:
connectionId: $.input.basicMessage.connectionId
message: $.actions.getResponse.output.choices[0].message.content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment