#nlp #wit #ai-api #api-wrapper #wit-ai #witai

wit_ai_rs

An unofficial Rust crate for interacting with the wit.ai API

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

MIT license

58KB
864 lines

wit_ai_rs

An unofficial Rust crate for interacting with the wit.ai API

crates.io Documentation MIT licensed

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 app
  • POST /entities - creates a new entity with the given name and roles
  • GET /entities/:entity - fetches the entity with the given name
  • PUT /entities/:entity - updates an entity with the given name
  • DELETE /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 app
  • POST /intents - creates a new intent with the given name
  • GET /intents/:intent - fetches the intent with the given name
  • DELETE /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 app
  • POST /traits - creates a new trait with the given name and values
  • GET /traits/:trait - fetches all information about the trait with the given name
  • DELETE /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 app
  • POST /utterances - creates a new utterance with the given text, intent, entities, and traits
  • DELETE /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