@fosterai/api
v1.0.5
Published
Lightweight browser SDK for Foster AI integration
Readme
Package Documentation
This package provides several functions for working with Foster AI API functions.
1. fetchTranscription(IDToken, audio, vocab, statusCallback)
Description:
Transcribes the given audio file by calling the fosterTranscriptionAPI function.
Parameters:
- IDToken (
string): The authentication token required for the API call. - audio (
File): The audio file to be transcribed. This should be a JavaScript File object (commonly produced using the MediaRecorder API) with an appropriate MIME type. - vocab (
Object, optional, default:{}): A vocabulary object to improve transcription accuracy. Each key should represent an incorrect word with its corresponding value being the correct word. - statusCallback (
Function, optional, default:() => {}): A callback function to receive status updates during the transcription process.
Returns:
A Promise<string> that resolves with the transcription text.
Throws:
An Error if the transcription fails after the maximum number of retries.
Usage Example:
fetchTranscription(token, audioFile)
.then(transcription => {
console.log("Transcription:", transcription);
})
.catch(err => console.error("Transcription error:", err));2. fetchNote(IDToken, transcription, noteType, customNoteTemplate)
Description:
Generates a clinical note from the provided transcription by calling the fosterNoteAPI function.
Parameters:
- IDToken (
string): The authentication token required for the API call. - transcription (
string): The transcription text to base the note on. - noteType (
string, optional, default:'SOAP'): The type of clinical note to generate (e.g.,'SOAP','clinical', or'custom'). - customNoteTemplate (
Object, optional, default:{}): An optional custom template object to format the note.
Returns:
A Promise<Object> that resolves with the generated clinical note.
Throws:
An Error if note generation fails.
Usage Example:
fetchNote(token, transcription)
.then(note => console.log("Clinical Note:", note))
.catch(err => console.error("Note generation error:", err));3. createEmailSignIn(email, password, enterpriseAPIKey)
Description:
Initiates the email sign-in process after verifying a shared enterprise API key.
Parameters:
- email (
string): The user's email address. - password (
string): The user's password. - enterpriseAPIKey (
string): The shared enterprise key to be verified via a backend call.
Returns:
A Promise<Object> that resolves with a user object containing user details and a getIdToken function to retrieve the ID token.
Throws:
An Error if the shared secret key is invalid.
Usage Example:
createEmailSignIn('[email protected]', 'password123', 'enterpriseKey')
.then(user => console.log("Signed in user:", user))
.catch(err => console.error("Sign-in error:", err));4. emailSignIn(email, password, enterpriseAPIKey)
Description:
Signs in a user with their email after verifying the shared enterprise API key.
Parameters:
- email (
string): The user's email address. - password (
string): The user's password. - enterpriseAPIKey (
string): The shared enterprise key to be verified via a backend call.
Returns:
A Promise<Object> that resolves with a user object containing user details and a getIdToken function.
Throws:
An Error if the shared secret key is invalid.
Usage Example:
emailSignIn('[email protected]', 'password123', 'enterpriseKey')
.then(user => console.log("Signed in user:", user))
.catch(err => console.error("Sign-in error:", err));