summaryrefslogtreecommitdiff
path: root/Content
diff options
context:
space:
mode:
Diffstat (limited to 'Content')
-rw-r--r--Content/posts/2021-06-27-Crude-ML-AI-Powered-Chatbot-Swift.md24
1 files changed, 18 insertions, 6 deletions
diff --git a/Content/posts/2021-06-27-Crude-ML-AI-Powered-Chatbot-Swift.md b/Content/posts/2021-06-27-Crude-ML-AI-Powered-Chatbot-Swift.md
index 0dcabec..804ad97 100644
--- a/Content/posts/2021-06-27-Crude-ML-AI-Powered-Chatbot-Swift.md
+++ b/Content/posts/2021-06-27-Crude-ML-AI-Powered-Chatbot-Swift.md
@@ -105,14 +105,26 @@ Otherwise, it calls the custom action.
![Screenshot](/assets/posts/swift-chatbot/carbon-4.png)
```swift
-let defaultResponses = [
- "greetings": "Hello",
- "banter": "no, plix no"
+let sampleMessages = [
+ "Hey there, how is it going",
+ "hello, there",
+ "Who let the dogs out",
+ "can you tell me about the compound Geraniin",
+ "what do you know about the compound Ibuprofen",
+ "please, tell me more about the compound",
+ "please, tell me more about the molecule dihydrogen-monoxide"
]
-let customActions = [
- "deez-drug": customAction
-]
+for sampleMessage in sampleMessages {
+ User.message = sampleMessage
+ let prediction = intentPredictor.predictedLabel(for: sampleMessage)
+
+ if (defaultResponses[prediction!] != nil) {
+ print(defaultResponses[prediction!]!)
+ } else if (customActions[prediction!] != nil) {
+ print(customActions[prediction!]!())
+ }
+}
```
![Output](/assets/posts/swift-chatbot/output.png)