poetry install
poetry run codegen
poetry build
pip install whitehead_sdk
Given a question and a context, generates the answer to the question
fromwhitehead_sdkimportauthenticatedeveloper_id=<int># Check your profile on the dashboard for this.api_key="<64 letter api key available on your whitehead dashboard>"client=authenticate(api_key, developer_id)
result=client.answer("What color is the apple?", "The apple is red")
assertresult=="red"Given a phrase and a list of history messages, generates the corresponding bot response
fromwhitehead_sdkimportauthenticatedeveloper_id=<int># Check your profile on the dashboard for this.api_key="<64 letter api key available on your whitehead dashboard>"client=authenticate(api_key, developer_id)
result=client.chitchat(
"good bye", [{"bot": "hi"}, {"user": "hello"}, {"bot": "howdy?"}]
)
assertresult=="bye"Given a question, a context and a list of choices, returns the most likely choice from the list
fromwhitehead_sdkimportauthenticatedeveloper_id=<int># Check your profile on the dashboard for this.api_key="<64 letter api key available on your whitehead dashboard>"client=authenticate(api_key, developer_id)
result=client.choose("What color is the apple?", "The apple is red", ["big", "red", "blue"])
assertresult=="red"Given a phrase, returns a type of dialog act type for it.
fromwhitehead_sdkimportauthenticatedeveloper_id=<int># Check your profile on the dashboard for this.api_key="<64 letter api key available on your whitehead dashboard>"client=authenticate(api_key, developer_id)
result=client.dialogact("hi there")
assertresult=="Conventional-opening"Given a phrase, returns a list of paraphrases
fromwhitehead_sdkimportauthenticatedeveloper_id=<int># Check your profile on the dashboard for this.api_key="<64 letter api key available on your whitehead dashboard>"client=authenticate(api_key, developer_id)
result=client.paraphrase("I like pizza")
assertset(result) == {
"I like pizza.",
"I enjoy pizza.",
"I like to eat pizza.",
"I like eating pizza.",
"I like food.",
"I love pizza.",
}Given a word/phrase and a relation type, returns a list of related words/phrases, according to the relation type
fromwhitehead_sdkimportauthenticatedeveloper_id=<int># Check your profile on the dashboard for this.api_key="<64 letter api key available on your whitehead dashboard>"client=authenticate(api_key, developer_id)
result=client.relations("pizza", Relation.IsA)
assertset(result) == {
"food",
"pizza",
"fast food",
"italian food",
"usually",
"popular food",
"often",
"meal",
"sometimes",
"cook",
}Given a list of phrases and a history, ranks them according to how sensible they are in a given history context
fromwhitehead_sdkimportauthenticatedeveloper_id=<int># Check your profile on the dashboard for this.api_key="<64 letter api key available on your whitehead dashboard>"client=authenticate(api_key, developer_id)
result=client.sensibility(
["fine", "bye"], [{"user": "hi"}, {"bot": "hi there"}, {"user": "howdy?"}]
)
alts= {a["alternative"] forainresult}
scores= [a["score"] forainresult]
assertlen(alts) ==2assertalts== {"fine", "bye"}
assertall([isinstance(s, float) forsinscores])Given a phrase, returns a sentiment information represented as a floating point value
fromwhitehead_sdkimportauthenticatedeveloper_id=<int># Check your profile on the dashboard for this.api_key="<64 letter api key available on your whitehead dashboard>"client=authenticate(api_key, developer_id)
result=client.sentiment("I feel good")
assertlen(result) ==1assertresult[0]["label"] =="positive"assertresult[0]["score"] >=0.9Given a target sentence and a list of other sentences, returns an array of pairwise similarity scores
fromwhitehead_sdkimportauthenticatedeveloper_id=<int># Check your profile on the dashboard for this.api_key="<64 letter api key available on your whitehead dashboard>"client=authenticate(api_key, developer_id)
result=client.similarity(
"I want pizza",
["I would like to have a pie", "I don't want pizza", "I want taco"],
)
assertlen(result) ==3assertresult[0]["candidate"] =="I would like to have a pie"assertresult[0]["score"] >=0.9assertresult[1]["candidate"] =="I don't want pizza"assertresult[1]["score"] <=0.5assertresult[2]["candidate"] =="I want taco"assertresult[2]["score"] <=0.5Converts phrase to audio
importiofromwhitehead_sdkimportauthenticatedeveloper_id=<int># Check your profile on the dashboard for this.api_key="<64 letter api key available on your whitehead dashboard>"client=authenticate(api_key, developer_id)
stream=io.BytesIO()
# stream could be an open file as wellclient.speak("hi", stream)Given a phrase and a list of topics, returns how likely is each topic to be the good fit for the phrase
fromwhitehead_sdkimportauthenticatedeveloper_id=<int># Check your profile on the dashboard for this.api_key="<64 letter api key available on your whitehead dashboard>"client=authenticate(api_key, developer_id)
result=client.topics("hi", allow_multiple=True, topics=["greeting", "food"])
assertlen(result) ==2assertresult[0]["topic"] =="greeting"assertresult[0]["score"] >=0.5assertresult[1]["topic"] =="food"assertresult[1]["score"] <=0.5Converts audio to text
importiofromwhitehead_sdkimportauthenticatedeveloper_id=<int># Check your profile on the dashboard for this.api_key="<64 letter api key available on your whitehead dashboard>"client=authenticate(api_key, developer_id)
stream=io.BytesIO()
# ... write audio bytes to the stream ...# it could be an open file as wellresult=client.transcribe(stream)
assertisinstance(result, str)