Skip to content

Commit

Permalink
Merge pull request #855 from stanford-oval/wip/ha-demo
Browse files Browse the repository at this point in the history
Changes from Home Assistant demo
  • Loading branch information
gcampax committed Dec 20, 2021
2 parents eab8015 + b7b9ec3 commit 0d4b19d
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 10 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ lib/utils/template-string/grammar.js
node_modules
dist
coverage
scripts/
17 changes: 13 additions & 4 deletions data/builtins/org.thingpedia.builtin.thingengine.builtin/faq.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ about_almond_special:
- What makes you {special|unique|different}?
- What is {special|unique|different} about you?
a:
- I am open and hackable. I have a state-of-the-art conversational semantic parser.
- >-
I have a state-of-the-art conversational semantic parser. It supports both
context and composition. This means I can understand complicated questions
and help you with complex tasks in a more natural way.
about_almond_motivation:
q:
Expand All @@ -41,7 +44,9 @@ about_almond_motivation:
- What is important about you for {home assistant|ha} users?
- Why are you important for {home assistant|ha} users?
a:
- I respect the privacy of the user.
- >-
Trusting your assistant is essential. I am a free and open system that
respects your privacy.
about_almond_location:
q:
Expand Down Expand Up @@ -119,15 +124,19 @@ general_help:
- Can you give me another suggestion?
- Show skills
a:
- I'm a new virtual assistant. At the moment, I can help you with music, jokes, news, podcasts, weather, reminders, and managing IoT devices.
- >-
Anyone can create skills for Genie. So far, people have created skills
for music, news, weather, jokes and other services.
iot_help:
q:
- "What kind of IoT devices"
- "What IoT devices can you work with?"
- "What devices can I connect you to?"
a:
- At the moment, I can control lights, switches, as well as various sensors. Check the Thingpedia website for the full, up-to-date list, and check your My Skills page to see which of your devices I recognize.
- >-
At the moment, I can control lights, switches, vacuums, fans and air
conditioners, as well as a variety of sensors.
positive_emotion_thanks:
q:
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ export default class LanguagePack {
return replaced.chooseBest();
}

private _measureToString(value : number, unit : string, precision = 0) : string {
private _measureToString(value : number, unit : string, precision = Units.normalizeUnit(unit) === 'C' ? 0 : 1) : string {
const transformed = Units.transformFromBaseUnit(value, unit);
assert(Number.isFinite(transformed));

Expand Down
22 changes: 22 additions & 0 deletions scripts/say-faq-answer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const yaml = require("js-yaml");
const fs = require("fs");
const path = require("path");
const https = require("https");
const { spawn } = require("child_process");

const BASE_URL = "https://nlp-staging.almond.stanford.edu/en-US/voice/tts?text=";

const name = process.argv[2];
const filename = "data/builtins/org.thingpedia.builtin.thingengine.builtin/faq.yaml";
const data = yaml.load(fs.readFileSync(filename, { encoding: "utf-8" }));
// const key = `about_almond_${name}`;
const key = name;
const answer = data[key]["a"][0];

const url = BASE_URL + encodeURIComponent(answer);

const proc = spawn("ffplay", ["-nodisp", "-"]);

https.get(url, (res) => {
res.pipe(proc.stdin);
});
2 changes: 1 addition & 1 deletion test/agent/expected-log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ C: ]]
C: #[count=50]
C: #[more=true];
#! timestamp: XXXX-XX-XXTXX:XX:XX.XXXZ
A: The distance is 1 mile.
A: The distance is 1.3 miles.
AT: $dialogue @org.thingpedia.dialogue.transaction.sys_recommend_one;
#! vote: up
#! comment: test comment for dialogue turns
Expand Down
2 changes: 1 addition & 1 deletion test/agent/tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ A: >> expecting = null
U: \t $dialogue @org.thingpedia.dialogue.transaction.execute;
U: now => [distance(geo, $location.current_location)] of (@com.yelp.restaurant()) => notify;

A: The distance is 1 mile.
A: The distance is 1.3 miles.
A: >> context = $dialogue @org.thingpedia.dialogue.transaction . sys_recommend_one ; [ distance ( geo , LOCATION_0 ) ] of @com.yelp . restaurant ( ) #[ results = [ { id = GENERIC_ENTITY_com.yelp:restaurant_0 , distance = MEASURE_m_0 } ] ] #[ count = NUMBER_0 ] #[ more = true ] ; // {"LOCATION_0":{"latitude":37.4275,"longitude":-122.1697,"display":null},"GENERIC_ENTITY_com.yelp:restaurant_0":{"value":"vhfPni9pci29SEHrN1OtRg","display":"Ramen Nagi"},"MEASURE_m_0":{"unit":"m","value":2155.6170081160226},"NUMBER_0":50}
A: >> expecting = null

Expand Down
6 changes: 3 additions & 3 deletions test/unit/test_describe.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,10 @@ const TEST_CASES = [
@com.yelp.restaurant(), openingHours == new RecurrentTimeSpecification(
{ beginTime=new Time(8,0), endTime=new Time(18,0), dayOfWeek=enum monday },
{ beginTime=new Time(8,0), endTime=new Time(18,0), dayOfWeek=enum tuesday },
{ beginTime=new Time(15,0), endTime=new Time(18,0), dayOfWeek=enum monday, beginDate=new Date("2021-12-25"), endDate=new Date("2021-12-25") },
{ beginTime=new Time(15,0), endTime=new Time(18,0), dayOfWeek=enum tuesday, beginDate=new Date("2021-12-25"), endDate=new Date("2021-12-25") }
{ beginTime=new Time(15,0), endTime=new Time(18,0), dayOfWeek=enum monday, beginDate=new Date(2023,12,25), endDate=new Date(2023,12,25) },
{ beginTime=new Time(15,0), endTime=new Time(18,0), dayOfWeek=enum tuesday, beginDate=new Date(2023,12,25), endDate=new Date(2023,12,25) }
);`,
'Get restaurants such that the opening hours is equal to from 8:00 AM to 6:00 PM on Monday and Tuesday, from 3:00 PM to 6:00 PM on Monday between December 24 and December 24, and from 3:00 PM to 6:00 PM on Tuesday between December 24 and December 24.',
'Get restaurants such that the opening hours is equal to from 8:00 AM to 6:00 PM on Monday and Tuesday, from 3:00 PM to 6:00 PM on Monday between December 25, 2023 and December 25, 2023, and from 3:00 PM to 6:00 PM on Tuesday between December 25, 2023 and December 25, 2023.',
`Yelp`],

[` @org.thingpedia.builtin.test(id="org.thingpedia.builtin.test").eat_data(data="some data ");`,
Expand Down

0 comments on commit 0d4b19d

Please sign in to comment.