Crates.io | typed-dialogflow |
lib.rs | typed-dialogflow |
version | 0.1.0 |
source | src |
created_at | 2022-03-29 17:05:22.552645 |
updated_at | 2022-03-29 17:05:22.552645 |
description | An easy-to-use typed Google Dialogflow client |
homepage | |
repository | https://github.com/edgarogh/typed-dialogflow |
max_upload_size | |
id | 558643 |
size | 54,958 |
An easy-to-use typed Google Dialogflow client for Rust
This library was extracted from a personal project. As a result, it may still be very basic and quite rigid. However, I'm all for this library growing and becoming more capable.
The concept of this library is to provide a relatively type-safe interface to Dialogflow. Intents are modelled as a single Rust enum
that you can pattern-match on.
Take the following Dialogflow intents:
You can then query and deserialize intents with this code :
#[derive(Debug, Eq, PartialEq, serde::Deserialize)]
#[serde(rename_all = "snake_case")]
enum Intent {
Hello,
Weather {
location: String,
},
ThankYou,
}
let intent = dialogflow.detect_intent_serde::<Intent>("What's the weather like in Antarctica ?").await.unwrap();
match intent {
Intent::Weather { location } => println!("The user asked for the weather in/at {location}"),
...
}
Due to the private / proprietary / externally-hosted nature of Dialogflow, testing this library isn't as easy as any other library. In addition to that, because Dialogflow relies on AI, there's always a small probability that a text may be interpreted differently if the model is re-trained, making tests undeterministic. I could eventually try to make the Google Backend mockable to test the deserialization part of the library. Besides that, I'm running tests locally on a private Dialogflow model, but having tests run on only one computer makes it impossible to enforce rules about having the code pass tests before being commited.
MIT OR APACHE-2.0