Skip to content

Commit 5bd7996

Browse files
committed
Allow OpenAI voice with English, add Delete Saved Chats function, fix the knowledge graph interrupter
1 parent e984386 commit 5bd7996

File tree

7 files changed

+65
-23
lines changed

7 files changed

+65
-23
lines changed

chipper/pkg/vars/config.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,19 @@ type apiConfig struct {
2121
Unit string `json:"unit"`
2222
} `json:"weather"`
2323
Knowledge struct {
24-
Enable bool `json:"enable"`
25-
Provider string `json:"provider"`
26-
Key string `json:"key"`
27-
ID string `json:"id"`
28-
Model string `json:"model"`
29-
IntentGraph bool `json:"intentgraph"`
30-
RobotName string `json:"robotName"`
31-
OpenAIPrompt string `json:"openai_prompt"`
32-
OpenAIVoice string `json:"openai_voice"`
33-
SaveChat bool `json:"save_chat"`
34-
CommandsEnable bool `json:"commands_enable"`
35-
Endpoint string `json:"endpoint"`
24+
Enable bool `json:"enable"`
25+
Provider string `json:"provider"`
26+
Key string `json:"key"`
27+
ID string `json:"id"`
28+
Model string `json:"model"`
29+
IntentGraph bool `json:"intentgraph"`
30+
RobotName string `json:"robotName"`
31+
OpenAIPrompt string `json:"openai_prompt"`
32+
OpenAIVoice string `json:"openai_voice"`
33+
OpenAIVoiceWithEnglish bool `json:"openai_voice_with_english"`
34+
SaveChat bool `json:"save_chat"`
35+
CommandsEnable bool `json:"commands_enable"`
36+
Endpoint string `json:"endpoint"`
3637
} `json:"knowledge"`
3738
STT struct {
3839
Service string `json:"provider"`

chipper/pkg/wirepod/preqs/knowledgegraph.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ func streamingKG(req *vtt.KnowledgeGraphRequest, speechReq sr.SpeechRequest) str
7979
SpokenText: "bla bla bla bla bla bla bla bla bla bla",
8080
}
8181
req.Stream.Send(&kg)
82-
ttr.StreamingKGSim(req, req.Device, transcribedText, true)
82+
_, err = ttr.StreamingKGSim(req, req.Device, transcribedText, true)
83+
if err != nil {
84+
logger.Println("LLM error: " + err.Error())
85+
}
8386
logger.Println("(KG) Bot " + speechReq.Device + " request served.")
8487
return ""
8588
}

chipper/pkg/wirepod/ttr/kgsim.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,15 @@ func StreamingKGSim(req interface{}, esn string, transcribedText string, isKG bo
255255
return "", err
256256
}
257257
} else {
258+
if isKG {
259+
kgStopLooping = true
260+
for range kgReadyToAnswer {
261+
break
262+
}
263+
stop <- true
264+
time.Sleep(time.Second / 3)
265+
KGSim(esn, "There was an error getting data from the L. L. M.")
266+
}
258267
return "", err
259268
}
260269
}
@@ -271,6 +280,15 @@ func StreamingKGSim(req interface{}, esn string, transcribedText string, isKG bo
271280
if len(fullRespSlice) == 0 {
272281
logger.Println("LLM returned no response")
273282
successIntent <- false
283+
if isKG {
284+
kgStopLooping = true
285+
for range kgReadyToAnswer {
286+
break
287+
}
288+
stop <- true
289+
time.Sleep(time.Second / 3)
290+
KGSim(esn, "There was an error getting data from the L. L. M.")
291+
}
274292
break
275293
}
276294
isDone = true
@@ -453,6 +471,7 @@ func StreamingKGSim(req interface{}, esn string, transcribedText string, isKG bo
453471
// time.Sleep(time.Millisecond * 3300)
454472
// }
455473
if !interrupted {
474+
stopStop <- true
456475
stop <- true
457476
}
458477
}

chipper/pkg/wirepod/ttr/kgsim_cmds.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,7 @@ func DoSayText(input string, robot *vector.Vector) error {
290290
// just before vector speaks
291291
removeSpecialCharacters(input)
292292

293-
// TODO
294-
if (vars.APIConfig.STT.Language != "en-US" && vars.APIConfig.Knowledge.Provider == "openai") || os.Getenv("USE_OPENAI_VOICE") == "true" {
293+
if (vars.APIConfig.STT.Language != "en-US" && vars.APIConfig.Knowledge.Provider == "openai") || vars.APIConfig.Knowledge.OpenAIVoiceWithEnglish {
295294
err := DoSayText_OpenAI(robot, input)
296295
return err
297296
}

chipper/pkg/wirepod/ttr/kgsim_interrupt.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func InterruptKGSimWhenTouchedOrWaked(rob *vector.Vector, stop chan bool, stopSt
2727
var stopFunc bool
2828
go func() {
2929
for range stopStop {
30+
logger.Println("KG Interrupter has been stopped")
3031
stopFunc = true
3132
break
3233
}
@@ -82,6 +83,7 @@ func InterruptKGSimWhenTouchedOrWaked(rob *vector.Vector, stop chan bool, stopSt
8283
return true
8384
}
8485
if stopFunc {
86+
strm.CloseSend()
8587
return false
8688
}
8789
}

chipper/webroot/js/main.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ function checkKG() {
247247
"openAIInput",
248248
"saveChatInput",
249249
"llmCommandInput",
250+
"openAIVoiceForEnglishInput",
250251
];
251252

252253
elements.forEach((el) => (getE(el).style.display = "none"));
@@ -259,6 +260,7 @@ function checkKG() {
259260
getE("openAIInput").style.display = "block";
260261
getE("saveChatInput").style.display = "block";
261262
getE("llmCommandInput").style.display = "block";
263+
getE("openAIVoiceForEnglishInput").style.display = "block";
262264
} else if (provider === "together") {
263265
getE("intentGraphInput").style.display = "block";
264266
getE("togetherInput").style.display = "block";
@@ -285,6 +287,7 @@ function sendKGAPIKey() {
285287
robotName: "",
286288
openai_prompt: "",
287289
openai_voice: "",
290+
openai_voice_with_english: false,
288291
save_chat: false,
289292
commands_enable: false,
290293
endpoint: "",
@@ -296,6 +299,7 @@ function sendKGAPIKey() {
296299
data.save_chat = getE("saveChatYes").checked
297300
data.commands_enable = getE("commandYes").checked
298301
data.openai_voice = getE("openaiVoice").value
302+
data.openai_voice_with_english = getE("voiceEnglishYes").checked
299303
} else if (provider === "custom") {
300304
data.key = getE("customKey").value;
301305
data.model = getE("customModel").value;
@@ -354,6 +358,7 @@ function updateKGAPI() {
354358
getE("commandYes").checked = data.commands_enable
355359
getE("intentyes").checked = data.intentgraph
356360
getE("saveChatYes").checked = data.save_chat
361+
getE("voiceEnglishYes").checked = data.openai_voice_with_english
357362
} else if (data.provider === "together") {
358363
getE("togetherKey").value = data.key;
359364
getE("togetherModel").value = data.model;

chipper/webroot/setup.html

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,12 @@ <h3>Knowledge Graph Setup</h3>
9898
a free domain, and enter the Model Name and Together Key
9999
here.</small><br />
100100
<label for="togetherModel">Together Model Name: <small class="desc">(leave blank for default
101-
meta-llama/Llama-3-70b-chat-hf)</small></label>
101+
meta-llama/Llama-3-70b-chat-hf)</small></label>
102102
<input type="text" name="togetherModel" id="togetherModel" /><br />
103103
<label for="togetherKey">Together Key:</label>
104104
<input type="text" name="togetherKey" id="togetherKey" /><br />
105-
<label for="togetherAIPrompt">GPT Prompt <small class="desc">(leave blank for default):</small></label><br />
105+
<label for="togetherAIPrompt">GPT Prompt <small class="desc">(leave blank for
106+
default):</small></label><br />
106107
<small><label class="desc" for="togetherAIPrompt">(default: "You are a helpful, animated robot called
107108
Vector. Keep the response concise yet
108109
informative.")</label></small>
@@ -116,8 +117,10 @@ <h3>Knowledge Graph Setup</h3>
116117
Vector. Keep the response concise yet
117118
informative.")</label></small>
118119
<input type="text" name="openAIPrompt" id="openAIPrompt" /><br />
119-
<label for="openaiVoice">OpenAI TTS voice for non-English languages:</label><br/>
120-
<small class="desc">See <a target="_blank" href="https://platform.openai.com/docs/guides/text-to-speech/voice-options">OpenAI's TTS site</a> to demo each voice.</small><br/>
120+
<label for="openaiVoice">OpenAI TTS voice for non-English languages:</label><br />
121+
<small class="desc">See <a target="_blank"
122+
href="https://platform.openai.com/docs/guides/text-to-speech/voice-options">OpenAI's TTS site</a> to
123+
demo each voice.</small><br />
121124
<select name="openaiVoice" id="openaiVoice">
122125
<option value="fable" selected>Fable</option>
123126
<option value="alloy">Alloy</option>
@@ -133,11 +136,13 @@ <h3>Knowledge Graph Setup</h3>
133136
users.</small><br />
134137
<label for="customKey">API Key <small class="desc">(for ollama, this is just 'ollama')</small>:</label>
135138
<input type="text" name="customKey" id="customKey" /><br />
136-
<label for="customAIEndpoint">API Endpoint <small class="desc">(i.e. http://localhost:11434/v1)</small>:</label>
139+
<label for="customAIEndpoint">API Endpoint <small class="desc">(i.e.
140+
http://localhost:11434/v1)</small>:</label>
137141
<input type="text" name="customAIEndpoint" id="customAIEndpoint" /><br />
138142
<label for="customModel">LLM Model Name <small class="desc">(i.e. 'llama3')</small>:</label>
139143
<input type="text" name="customModel" id="customModel" /><br />
140-
<label for="customAIPrompt">LLM Prompt <small class="desc">(leave blank for default)</small>:</label><br />
144+
<label for="customAIPrompt">LLM Prompt <small class="desc">(leave blank for
145+
default)</small>:</label><br />
141146
<small><label class="desc" for="customAIPrompt">(default: "You are a helpful, animated robot called
142147
Vector. Keep the response concise yet
143148
informative.")</label></small>
@@ -156,13 +161,21 @@ <h3>Knowledge Graph Setup</h3>
156161
<span id="llmCommandInput" style="display: none">
157162
<input type="checkbox" id="commandYes" name="commandDoselect" />
158163
<label class="checkbox-label" for="commandYes">
159-
Allow the LLM to run commands on the robot, such as play animations.
164+
Allow the LLM to make the robot perform animations and other actions during the response.
160165
</label>
161166
</span>
162167
<span id="saveChatInput" style="display: none">
163168
<input type="checkbox" id="saveChatYes" name="saveChatselect" />
164169
<label class="checkbox-label" for="saveChatYes">
165-
Enable conversations via "I have a question". This also allows previous chats to be used in the context of future responses.
170+
Enable conversations via "I have a question". This also allows previous chats to be used in the
171+
context of future responses.
172+
</label></br>
173+
<a href="#" onclick="deleteSavedChats()">Delete Saved Chats</a>
174+
</span>
175+
<span id="openAIVoiceForEnglishInput" style="display: none">
176+
<input type="checkbox" id="voiceEnglishYes" name="voiceEnglishselect" />
177+
<label class="checkbox-label" for="voiceEnglishYes">
178+
Use the OpenAI TTS voice for English as well.
166179
</label>
167180
</span>
168181
</div>

0 commit comments

Comments
 (0)