mini板增加讯飞语音
This commit is contained in:
@@ -18,7 +18,7 @@ export const init_xunfei_vi = {
|
||||
this.appendValueInput('APIKey')
|
||||
.setCheck(String)
|
||||
.appendField('APIKey');
|
||||
this.setInputsInline(false);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
}
|
||||
@@ -32,7 +32,7 @@ export const init_xunfei_Spark_Ultra = {
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP + Blockly.Msg.MIXLY_AS + Blockly.Msg.MIXLY_XUFEI + 'Spark Ultra' +Blockly.Msg.MIXLY_LARGE_LANGUAGE_MODEL );
|
||||
.appendField(Blockly.Msg.MIXLY_SETUP + Blockly.Msg.MIXLY_AS + Blockly.Msg.MIXLY_XUFEI +Blockly.Msg.MIXLY_LARGE_LANGUAGE_MODEL );
|
||||
this.appendValueInput('APPID')
|
||||
.setCheck(String)
|
||||
.appendField('APPID');
|
||||
@@ -42,13 +42,29 @@ export const init_xunfei_Spark_Ultra = {
|
||||
this.appendValueInput('APIKey')
|
||||
.setCheck(String)
|
||||
.appendField('APIKey');
|
||||
this.setInputsInline(false);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_SELECT_MODEL)
|
||||
.appendField(new Blockly.FieldDropdown([
|
||||
["Spark-X1-32K","Spark X1-32K"],
|
||||
["Spark-Lite","Spark Lite"],
|
||||
["Spark-Pro","Spark Pro"],
|
||||
["Spark-Pro-128K","Spark Pro-128K"],
|
||||
["Spark-Max, " + Blockly.Msg.MIXLY_SUPPORT + Blockly.Msg.MIXLY_DIALOGUE_BACKGROUND + "、" + Blockly.Msg.MIXLY_ESP32_ONENET_SUB, "Spark Max"],
|
||||
["Spark-Max-32K, "+ Blockly.Msg.MIXLY_SUPPORT + Blockly.Msg.MIXLY_DIALOGUE_BACKGROUND + "、" + Blockly.Msg.MIXLY_ESP32_ONENET_SUB, "Spark Max-32K"],
|
||||
["Spark-Ultra-32K, "+ Blockly.Msg.MIXLY_SUPPORT + Blockly.Msg.MIXLY_DIALOGUE_BACKGROUND + "、" + Blockly.Msg.MIXLY_ESP32_ONENET_SUB, "Spark Ultra-32K"],
|
||||
[Blockly.Msg.MIXLY_KJWX, "Spark kjwx"],
|
||||
[Blockly.Msg.MIXLY_CUSTOMIZE_MODEL + "," + Blockly.Msg.MIXLY_SUPPORT + Blockly.Msg.MIXLY_ESP32_ONENET_SUB, "Spark Customize"]
|
||||
]),"model");
|
||||
this.appendValueInput('DBG')
|
||||
.setCheck(String)
|
||||
.appendField(Blockly.Msg.MIXLY_DIALOGUE_BACKGROUND);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
}
|
||||
};
|
||||
|
||||
export const init_xunfei_vi_run = {
|
||||
export const xunfei_vi_run = {
|
||||
init: function () {
|
||||
this.setColour(AI_CLOUD_VOICE_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
@@ -64,7 +80,7 @@ export const init_xunfei_vi_run = {
|
||||
}
|
||||
};
|
||||
|
||||
export const init_xunfei_Spark_Ultra_run = {
|
||||
export const xunfei_Spark_Ultra_run = {
|
||||
init: function () {
|
||||
this.setColour(AI_CLOUD_VOICE_HUE);
|
||||
this.appendValueInput('VAR')
|
||||
@@ -95,14 +111,122 @@ export const llm_set_callback = {
|
||||
init: function () {
|
||||
this.setColour(AI_CLOUD_VOICE_HUE);
|
||||
this.appendValueInput('VAR1')
|
||||
.appendField(Blockly.Msg.MIXLY_LARGE_LANGUAGE_MODEL)
|
||||
this.appendValueInput('callback')
|
||||
.appendField(Blockly.Msg.MIXLY_PYTHON_CONTROLS_THREAD_USE)
|
||||
this.appendValueInput('VAR')
|
||||
.appendField(Blockly.Msg.MIXLY_PARAMS);
|
||||
this.appendValueInput('VAR2')
|
||||
.appendField(Blockly.Msg.MIXLY_FUNCTION_NAME);
|
||||
this.appendValueInput('VAR3')
|
||||
.appendField(Blockly.Msg.MIXLY_FUNCTION_DESCRIPTION)
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_PARAMS + Blockly.Msg.OLED_STRING);
|
||||
|
||||
this.itemCount_ = 2;
|
||||
this.updateShape_();
|
||||
|
||||
this.setMutator(new Blockly.icons.MutatorIcon(['llm_set_callback_item'], this));
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setInputsInline(true);
|
||||
this.setTooltip(Blockly.Msg.llm_set_callback_tooltip);
|
||||
},
|
||||
|
||||
mutationToDom: function () {
|
||||
var container = document.createElement('mutation');
|
||||
container.setAttribute('items', this.itemCount_);
|
||||
return container;
|
||||
},
|
||||
domToMutation: function (xmlElement) {
|
||||
this.itemCount_ = parseInt(xmlElement.getAttribute('items'), 10);
|
||||
this.updateShape_();
|
||||
},
|
||||
decompose: function (workspace) {
|
||||
var containerBlock =
|
||||
workspace.newBlock('llm_set_callback_container');
|
||||
containerBlock.initSvg();
|
||||
var connection = containerBlock.getInput('STACK').connection;
|
||||
for (var i = 0; i < this.itemCount_; i++) {
|
||||
var itemBlock = workspace.newBlock('llm_set_callback_item');
|
||||
itemBlock.initSvg();
|
||||
connection.connect(itemBlock.previousConnection);
|
||||
connection = itemBlock.nextConnection;
|
||||
}
|
||||
return containerBlock;
|
||||
},
|
||||
compose: function (containerBlock) {
|
||||
var itemBlock = containerBlock.getInputTargetBlock('STACK');
|
||||
// Count number of inputs.
|
||||
var connections = [];
|
||||
var i = 0;
|
||||
while (itemBlock) {
|
||||
connections[i] = itemBlock.valueConnection_;
|
||||
itemBlock = itemBlock.nextConnection &&
|
||||
itemBlock.nextConnection.targetBlock();
|
||||
i++;
|
||||
}
|
||||
this.itemCount_ = i;
|
||||
this.updateShape_();
|
||||
// Reconnect any child blocks.
|
||||
for (var i = 0; i < this.itemCount_; i++) {
|
||||
if (connections[i]) {
|
||||
this.getInput('ADD' + i)
|
||||
.connection.connect(connections[i]);
|
||||
}
|
||||
}
|
||||
},
|
||||
saveConnections: function (containerBlock) {
|
||||
var itemBlock = containerBlock.getInputTargetBlock('STACK');
|
||||
var i = 0;
|
||||
while (itemBlock) {
|
||||
var input = this.getInput('ADD' + i);
|
||||
itemBlock.valueConnection_ = input && input.connection.targetConnection;
|
||||
i++;
|
||||
itemBlock = itemBlock.nextConnection &&
|
||||
itemBlock.nextConnection.targetBlock();
|
||||
}
|
||||
},
|
||||
updateShape_: function () {
|
||||
// Delete everything.
|
||||
if (this.getInput('EMPTY')) {
|
||||
this.removeInput('EMPTY');
|
||||
} else {
|
||||
var i = 0;
|
||||
while (this.getInput('ADD' + i)) {
|
||||
this.removeInput('ADD' + i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
// Rebuild block.
|
||||
if (this.itemCount_ == 0) {
|
||||
this.appendDummyInput('EMPTY')
|
||||
// .appendField(Blockly.Msg.MIXLY_PARAMS);
|
||||
} else {
|
||||
for (var i = 0; i < this.itemCount_; i++) {
|
||||
var input = this.appendValueInput('ADD' + i);
|
||||
if (i == 0) {
|
||||
// input.appendField(Blockly.MIXLY_PARAMS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const llm_set_callback_container = {
|
||||
init: function () {
|
||||
this.setColour(AI_CLOUD_VOICE_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.MIXLY_SETTING + Blockly.Msg.MIXLY_PARAMS);
|
||||
this.appendStatementInput('STACK');
|
||||
this.contextMenu = false;
|
||||
}
|
||||
};
|
||||
|
||||
export const llm_set_callback_item = {
|
||||
init: function () {
|
||||
this.setColour(AI_CLOUD_VOICE_HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TITLE);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.contextMenu = false;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user