3 unstable releases
0.2.0 | Feb 19, 2024 |
---|---|
0.1.1 | Feb 16, 2024 |
0.1.0 | Feb 16, 2024 |
#896 in Web programming
29 downloads per month
58KB
864 lines
wit_ai_rs
An unofficial Rust crate for interacting with the wit.ai API
This crate acts as a wrapper for the wit.ai HTTP API, containing functions and types for interacting with the API programmatically using Rust. The core type is the WitClient
struct, which must be initialized before any endpoint can be called.
Usage
To get started, instantiate a WitClient
--this has all the methods required for sending requests to the wit API:
let wit_client = WitClient::new("TOKEN".to_string(), "20240215".to_string());
Note that a token is required to interact with the wit API. This can be found under the Settings
page in the dashboard for your app on the wit site. A token is associated with one app, and the app the token belongs to will be the app that the client acts upon.
Functionality
This crate currently supports the following endpoints:
Audio
POST /dictation
- takes an audio stream of speech and returns a transcription with text
Entities
GET /entities
- fetches all entities associated with the current appPOST /entities
- creates a new entity with the given name and rolesGET /entities/:entity
- fetches the entity with the given namePUT /entities/:entity
- updates an entity with the given nameDELETE /entities/:entity
- deletes the entity with the given name
Wit has built in entities, which are listed here
Intents
GET /intents
- fetches all intents associated with the current appPOST /intents
- creates a new intent with the given nameGET /intents/:intent
- fetches the intent with the given nameDELETE /intents/:intent
- deletes the intent with the given name
Wit has built in intents, which are listed here
Language Detection
GET /language
- attempts to detect the language in a given piece of text
Supported languages are listed here
Message
GET /message
- analyzes a given piece of text for intent, entities, and traits
Traits
GET /traits
- fetches all traits associated with the current appPOST /traits
- creates a new trait with the given name and valuesGET /traits/:trait
- fetches all information about the trait with the given nameDELETE /traits/:trait
- deletes the trait with the given name
Wit has built in intents, which are listed here
Utterances
GET /utterances
- fetches all the utterances associated with the current appPOST /utterances
- creates a new utterance with the given text, intent, entities, and traitsDELETE /utterances
- deletes one or more utterances, given their text values
Tests
Some tests use mockito, while others interact with the actual wit.ai API. The tests that interact with the wit API are ignored by default--to run them, you must set the WIT_TOKEN
environment variable to a token that has read and write access.
Notes
The latest version of the wit.ai HTTP API docs can be found here
Dependencies
~4–19MB
~227K SLoC