feat(boards): micropython下添加对openai chat接口的支持

This commit is contained in:
王立帮
2025-04-22 01:53:11 +08:00
parent 7bf049fe3e
commit a1bfd806fa
11 changed files with 737 additions and 160 deletions

View File

@@ -619,7 +619,7 @@ export const iot_onenetdisconnect = iot_onenet_disconnect;
export const iot_checkonenet = iot_onenet_check;
export const iot_publish = iot_onenet_publish;
export const IOT_CONNECT_OLLAMA = {
export const iot_connect_ollama = {
init: function () {
this.setColour(IOT_HUE);
this.appendDummyInput()
@@ -638,6 +638,30 @@ export const IOT_CONNECT_OLLAMA = {
}
};
export const IOT_CONNECT_OLLAMA = iot_connect_ollama;
export const iot_connect_openai = {
init: function () {
this.setColour(IOT_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_CONNECT_OPENAI);
this.appendValueInput('SERVER')
.appendField(Blockly.Msg.MIXLY_EMQX_SERVER)
.setAlign(Blockly.inputs.Align.RIGHT);
this.appendValueInput('KEY')
.appendField(Blockly.Msg.MIXLY_API_PRIVATE_KEY)
.setAlign(Blockly.inputs.Align.RIGHT);
this.appendValueInput('NAME')
.appendField(Blockly.Msg.MODEL_NAME)
.setAlign(Blockly.inputs.Align.RIGHT);
this.appendValueInput('NUMBER')
.appendField(Blockly.Msg.MIXLY_SET_MAXIMUM_HISTORICAL_SESSIONS_NUM);
this.setInputsInline(false);
this.setPreviousStatement(true);
this.setNextStatement(true);
}
};
export const use_ollama_llm_to_chat = {
init: function () {
this.setColour(IOT_HUE);

View File

@@ -158,7 +158,7 @@ export const IOT_EMQX_INIT_AND_CONNECT_BY_SHARE_CODE = function (_, generator) {
// var mac_address = 'str(binascii.hexlify(wifi.radio.mac_address))[2:14]'
// var socket_pool = 'socketpool.SocketPool(wifi.radio)'
// var ssl_context = 'ssl.create_default_context()'
var code = 'sk = analyse_sharekey(\'http://'+server.substring(1, server.length-1)+'/mixio-php/sharekey.php?sk=' + share_code + '\')\n'+
var code = 'sk = analyse_sharekey(\'http://' + server.substring(1, server.length - 1) + '/mixio-php/sharekey.php?sk=' + share_code + '\')\n' +
'MQTT_USR_PRJ = sk[0]+\'/\'+sk[1]+\'/\'\n' +
'mqtt_client = mixiot.init_MQTT_client(' + server + ', sk[0], sk[2]' + ', MQTT_USR_PRJ)\n';
return code;
@@ -235,18 +235,28 @@ export const iot_mqtt_data = function (_, generator) {
return [code, generator.ORDER_ATOMIC];
}
export const IOT_CONNECT_OLLAMA = function(_,generator) {
generator.definitions_['import_Ollama'] = "from ollama import Ollama";
export const iot_connect_ollama = function (_, generator) {
generator.definitions_['import_ollama'] = "from ollama import Ollama";
var ser = generator.valueToCode(this, 'SERVER', generator.ORDER_ATOMIC);
var name = generator.valueToCode(this, 'NAME', generator.ORDER_ATOMIC);
var num = generator.valueToCode(this, 'NUMBER', generator.ORDER_ATOMIC);
var code = 'llm = Ollama(' + ser + ', ' + name + ', '+ num +')\n';
var code = 'llm = Ollama(' + ser + ', ' + name + ', ' + num + ')\n';
return code;
}
export const IOT_CONNECT_OLLAMA = iot_connect_ollama;
export const iot_connect_openai = function (_, generator) {
generator.definitions_['import_openai'] = "from openai import OpenAI";
var ser = generator.valueToCode(this, 'SERVER', generator.ORDER_ATOMIC);
var key = generator.valueToCode(this, 'KEY', generator.ORDER_ATOMIC);
var name = generator.valueToCode(this, 'NAME', generator.ORDER_ATOMIC);
var num = generator.valueToCode(this, 'NUMBER', generator.ORDER_ATOMIC);
var code = `llm = OpenAI(${ser}, ${key}, ${name}, ${num})\n`;
return code;
}
export const use_ollama_llm_to_chat = function (_, generator) {
generator.definitions_['import_Ollama'] = "from ollama import Ollama";
var topic = generator.valueToCode(this, 'TOPIC', generator.ORDER_ATOMIC);
var method = generator.valueToCode(this, 'METHOD', generator.ORDER_ATOMIC);
var code = 'llm.chat(' + topic + ', ' + method + ')\n';
@@ -254,48 +264,41 @@ export const use_ollama_llm_to_chat = function (_, generator) {
}
export const use_ollama_llm_to_chat_return = function (_, generator) {
generator.definitions_['import_Ollama'] = "from ollama import Ollama";
var topic = generator.valueToCode(this, 'TOPIC', generator.ORDER_ATOMIC);
var code = 'llm.chat(' + topic + ')';
return [code,generator.ORDER_ATOMIC];
return [code, generator.ORDER_ATOMIC];
}
// export const ollama_set_timeout = function (_,generator) {
// generator.definitions_['import_Ollama'] = "from ollama import Ollama";
// var t = generator.valueToCode(this, 'VAR', generator.ORDER_ATOMIC);
// var code = 'llm.set_timeout(' + t + ')\n';
// return code;
// }
// export const ollama_set_max_retries = function (_,generator) {
// generator.definitions_['import_Ollama'] = "from ollama import Ollama";
// var t = generator.valueToCode(this, 'VAR', generator.ORDER_ATOMIC);
// var code = 'llm.set_max_retries(' + t + ')\n';
// return code;
// }
// export const ollama_set_custom_url = function (_,generator) {
// generator.definitions_['import_Ollama'] = "from ollama import Ollama";
// var t = generator.valueToCode(this, 'TEXT', generator.ORDER_ATOMIC);
// var code = 'llm.set_custom_url(' + t + ')\n';
// return code;
// }
// export const ollama_select_model = function (_,generator) {
// generator.definitions_['import_Ollama'] = "from ollama import Ollama";
// var t = generator.valueToCode(this, 'TEXT', generator.ORDER_ATOMIC);
// var code = 'llm.select_model(' + t + ')\n';
// return code;
// }
// export const ollama_clear_user_history = function (_,generator) {
// generator.definitions_['import_Ollama'] = "from ollama import Ollama";
// var code = 'llm.clear_user_history()\n';
// return code;
// }
export const ollama_empty_history = function (_,generator) {
generator.definitions_['import_Ollama'] = "from ollama import Ollama";
export const ollama_empty_history = function () {
var code = 'llm.empty_history()\n';
return code;
}

View File

@@ -60,7 +60,7 @@ class Ollama():
self._url, headers=self._heads, data=data)
if response.status_code == 200:
break
time.slee(1)
time.sleep(1)
output = ""
@@ -101,7 +101,7 @@ class Ollama():
self.add_history("assistant", content)
messages_len = len(self._messages)
history_num = 2 * self._max_history_num
while history_num < len(self._messages):
while history_num < messages_len:
del self._messages[0]
else:
self.clear_user_history()

View File

@@ -0,0 +1,53 @@
import urequests
import time
import json
import ollama
class OpenAI(ollama.Ollama):
def __init__(self, url="", api_key="", model="", max_history_num=0, max_tokens=1024):
super().__init__(url, model, max_history_num)
self._heads["Authorization"] = "Bearer {}".format(api_key)
self._data["max_tokens"] = max_tokens
self._chat_url = "{}/chat/completions".format(self._url)
def _post(self, content_callback=None):
response = None
data = json.dumps(self._data).encode('utf-8')
for i in range(0, self._max_retries):
response = urequests.post(
self._chat_url, headers=self._heads, data=data)
if response.status_code == 200:
break
time.sleep(1)
output = ""
if response.status_code != 200:
output = response.text
if content_callback:
content_callback(output)
return output
if not content_callback:
output = json.loads(response.text)[
"choices"][0]["message"]["content"]
response.close()
return output
try:
while True:
line = response.raw.readline()
if line[:5] != b"data:":
continue
if line[-7:-1] == b"[DONE]":
break
line = line[6:-1]
line = line.decode('utf-8').strip()
data = json.loads(line)
content = data["choices"][0]["delta"]["content"]
content_callback(content)
output += content
finally:
response.close()
return output

View File

@@ -7241,6 +7241,85 @@
</shadow>
</value>
</block>
<block type="iot_connect_ollama">
<value name="SERVER">
<shadow type="text">
<field name="TEXT">192.168.1.1</field>
</shadow>
</value>
<value name="NAME">
<shadow type="text">
<field name="TEXT">qwen2.5-coder:0.5b</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
</block>
<block type="iot_connect_openai">
<value name="SERVER">
<shadow type="text">
<field name="TEXT">https://api.deepseek.com</field>
</shadow>
</value>
<value name="KEY">
<shadow type="text">
<field name="TEXT">API Key</field>
</shadow>
</value>
<value name="NAME">
<shadow type="text">
<field name="TEXT">deepseek-chat</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
</block>
<block type="use_ollama_llm_to_chat">
<value name="TOPIC">
<shadow type="text">
<field name="TEXT">请介绍一下米思齐?</field>
</shadow>
</value>
<value name="METHOD">
<shadow type="factory_block_return">
<field name="VALUE">content_callback</field>
</shadow>
</value>
</block>
<block type="procedures_defnoreturn">
<mutation>
<arg name="content"></arg>
</mutation>
<field name="NAME">content_callback</field>
<statement name="STACK">
<block type="system_print_end">
<value name="VAR">
<block type="variables_get">
<field name="VAR">content</field>
</block>
</value>
<value name="END">
<shadow type="text">
<field name="TEXT"></field>
</shadow>
</value>
</block>
</statement>
</block>
<block type="use_ollama_llm_to_chat_return">
<value name="TOPIC">
<shadow type="text">
<field name="TEXT">请介绍一下米思齐?</field>
</shadow>
</value>
</block>
<block type="ollama_empty_history"></block>
</category>
<category id="catFactory" name="Factory" colour="#777777">

View File

@@ -481,7 +481,7 @@
</shadow>
</value>
</block>
<block type="math_degree_to_radian">
<block type="math_degree_to_radian">
<value name="VAR">
<shadow type="math_number">
<field name="NUM">1</field>
@@ -2929,7 +2929,7 @@
</statement>
</block>
</category>
<category id ="catBLEC" colour="140">
<category id="catBLEC" colour="140">
<block type="communicate_bluetooth_handle">
<value name="VAR">
<shadow type="variables_get">
@@ -3051,11 +3051,11 @@
</value>
</block> -->
<block type="analog_ble_keyboard_mouse_init">
<value name="kname">
<shadow type="text">
<field name="TEXT">ble_keyboard_mouse</field>
</shadow>
</value>
<value name="kname">
<shadow type="text">
<field name="TEXT">ble_keyboard_mouse</field>
</shadow>
</value>
</block>
<block type="ble_keyboard_mouse_get_mac"></block>
<block type="ble_keyboard_mouse_connect"></block>
@@ -3066,10 +3066,10 @@
</shadow>
</value>
</block>
<block type="analog_ble_keyboard_mouse_input" >
<block type="analog_ble_keyboard_mouse_input">
<value name="special">
<block type="special_key">
</block>
<block type="special_key">
</block>
</value>
<value name="general">
<block type="general_key">
@@ -3088,7 +3088,7 @@
</shadow>
</value>
</block>
<block type="analog_ble_mouse_keyboard_input" >
<block type="analog_ble_mouse_keyboard_input">
<value name="key">
<block type="mouse_key">
</block>
@@ -3972,12 +3972,12 @@
<value name="NUM">
<block type="logic_null"></block>
</value>
</block>
<block type = "CI130X_SET_SYSTEM_CMD">
</block>
<block type="CI130X_SET_SYSTEM_CMD">
<value name="SUB">
<shadow type="variables_get">
<field name="VAR">xsensor</field>
</shadow>
<shadow type="variables_get">
<field name="VAR">xsensor</field>
</shadow>
</block>
<block type="communicate_spi_init">
<value name="VAR">
@@ -4312,7 +4312,7 @@
</shadow>
</value>
<value name="pc">
<shadow type="math_number">
<shadow type="math_number">
<field name="NUM">500</field>
</shadow>
</value>
@@ -7070,6 +7070,85 @@
</shadow>
</value>
</block>
<block type="iot_connect_ollama">
<value name="SERVER">
<shadow type="text">
<field name="TEXT">192.168.1.1</field>
</shadow>
</value>
<value name="NAME">
<shadow type="text">
<field name="TEXT">qwen2.5-coder:0.5b</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
</block>
<block type="iot_connect_openai">
<value name="SERVER">
<shadow type="text">
<field name="TEXT">https://api.deepseek.com</field>
</shadow>
</value>
<value name="KEY">
<shadow type="text">
<field name="TEXT">API Key</field>
</shadow>
</value>
<value name="NAME">
<shadow type="text">
<field name="TEXT">deepseek-chat</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
</block>
<block type="use_ollama_llm_to_chat">
<value name="TOPIC">
<shadow type="text">
<field name="TEXT">请介绍一下米思齐?</field>
</shadow>
</value>
<value name="METHOD">
<shadow type="factory_block_return">
<field name="VALUE">content_callback</field>
</shadow>
</value>
</block>
<block type="procedures_defnoreturn">
<mutation>
<arg name="content"></arg>
</mutation>
<field name="NAME">content_callback</field>
<statement name="STACK">
<block type="system_print_end">
<value name="VAR">
<block type="variables_get">
<field name="VAR">content</field>
</block>
</value>
<value name="END">
<shadow type="text">
<field name="TEXT"></field>
</shadow>
</value>
</block>
</statement>
</block>
<block type="use_ollama_llm_to_chat_return">
<value name="TOPIC">
<shadow type="text">
<field name="TEXT">请介绍一下米思齐?</field>
</shadow>
</value>
</block>
<block type="ollama_empty_history"></block>
</category>
<category id="catFactory" name="Factory" colour="#777777">
<block type="factory_import"></block>

View File

@@ -455,7 +455,7 @@
</shadow>
</value>
</block>
<block type="math_degree_to_radian">
<block type="math_degree_to_radian">
<value name="VAR">
<shadow type="math_number">
<field name="NUM">1</field>
@@ -1714,7 +1714,7 @@
</shadow>
</value>
</block>
<block type="analog_keyboard_input" m-show="micropython:esp32c2:mixgo_mini">
<value name="special">
<block type="special_key">
@@ -1751,7 +1751,7 @@
</value>
</block>
<block type="analog_keyboard_str" m-show="micropython:esp32c2:mixgo_mini">
<value name="str">
<value name="str">
<shadow type="text">
<field name="TEXT">Hello, Mixly!</field>
</shadow>
@@ -1830,7 +1830,7 @@
<block type="image_arithmetic">
<value name="A">
<shadow type="pins_builtinimg"></shadow>
</value>
</value>
<value name="B">
<shadow type="pins_builtinimg"></shadow>
</value>
@@ -2061,8 +2061,8 @@
<value name="NUM">
<block type="logic_null"></block>
</value>
</block>
<block type = "CI130X_SET_SYSTEM_CMD_SANT"></block>
</block>
<block type="CI130X_SET_SYSTEM_CMD_SANT"></block>
</category>
<category id="catIot" colour="#2FAD7A">
<category id="catBlynk" colour="#2FAD7A">
@@ -2817,7 +2817,7 @@
</statement>
</block>
</category>
<category id ="catBLEC" colour="140">
<category id="catBLEC" colour="140">
<block type="communicate_bluetooth_handle">
<value name="VAR">
<shadow type="variables_get">
@@ -2939,11 +2939,11 @@
</value>
</block> -->
<block type="analog_ble_keyboard_mouse_init">
<value name="kname">
<shadow type="text">
<field name="TEXT">ble_keyboard_mouse</field>
</shadow>
</value>
<value name="kname">
<shadow type="text">
<field name="TEXT">ble_keyboard_mouse</field>
</shadow>
</value>
</block>
<block type="ble_keyboard_mouse_get_mac"></block>
<block type="ble_keyboard_mouse_connect"></block>
@@ -2954,10 +2954,10 @@
</shadow>
</value>
</block>
<block type="analog_ble_keyboard_mouse_input" >
<block type="analog_ble_keyboard_mouse_input">
<value name="special">
<block type="special_key">
</block>
<block type="special_key">
</block>
</value>
<value name="general">
<block type="general_key">
@@ -2976,7 +2976,7 @@
</shadow>
</value>
</block>
<block type="analog_ble_mouse_keyboard_input" >
<block type="analog_ble_mouse_keyboard_input">
<value name="key">
<block type="mouse_key">
</block>
@@ -3657,7 +3657,7 @@
</block>
</next>
</block>
<block type="sensor_mpu9250_get_acceleration">
<block type="sensor_mpu9250_get_acceleration">
<value name="SUB">
<shadow type="variables_get">
<field name="VAR">xsensor</field>
@@ -3863,13 +3863,13 @@
<value name="NUM">
<block type="logic_null"></block>
</value>
</block>
<block type = "CI130X_SET_SYSTEM_CMD">
</block>
<block type="CI130X_SET_SYSTEM_CMD">
<value name="SUB">
<shadow type="variables_get">
<field name="VAR">xsensor</field>
</shadow>
</block>
<shadow type="variables_get">
<field name="VAR">xsensor</field>
</shadow>
</block>
<block type="communicate_spi_init">
<value name="VAR">
<shadow type="variables_get">
@@ -4206,7 +4206,7 @@
</shadow>
</value>
<value name="pc">
<shadow type="math_number">
<shadow type="math_number">
<field name="NUM">500</field>
</shadow>
</value>
@@ -4217,7 +4217,7 @@
<field name="VAR">weight</field>
</shadow>
</value>
</block>
</block>
</category>
<category id="catExternActuator" colour='#74A55B'>
<block type="servo_move" m-show='micropython:esp32c3:mixgocar_c3'>
@@ -6961,63 +6961,85 @@
</shadow>
</value>
</block>
<block type="IOT_CONNECT_OLLAMA">
<value name="SERVER">
<shadow type="text">
<field name="TEXT">192.168.1.1</field>
</shadow>
</value>
<value name="NAME">
<shadow type="text">
<field name="TEXT">qwen2.5-coder:0.5b</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
</block>
<block type="use_ollama_llm_to_chat">
<value name="TOPIC">
<shadow type="text">
<field name="TEXT">请介绍一下米思齐?</field>
</shadow>
</value>
<value name="METHOD">
<shadow type="factory_block_return">
<field name="VALUE">content_callback</field>
</shadow>
</value>
</block>
<block type="procedures_defnoreturn">
<mutation>
<arg name="content"></arg>
</mutation>
<field name="NAME">content_callback</field>
<statement name="STACK">
<block type="system_print_end">
<value name="VAR">
<block type="variables_get">
<field name="VAR">content</field>
</block>
</value>
<value name="END">
<shadow type="text">
<field name="TEXT"></field>
</shadow>
</value>
</block>
</statement>
</block>
<block type="use_ollama_llm_to_chat_return">
<value name="TOPIC">
<shadow type="text">
<field name="TEXT">请介绍一下米思齐?</field>
</shadow>
</value>
</block>
<block type="ollama_empty_history"></block>
<block type="iot_connect_ollama">
<value name="SERVER">
<shadow type="text">
<field name="TEXT">192.168.1.1</field>
</shadow>
</value>
<value name="NAME">
<shadow type="text">
<field name="TEXT">qwen2.5-coder:0.5b</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
</block>
<block type="iot_connect_openai">
<value name="SERVER">
<shadow type="text">
<field name="TEXT">https://api.deepseek.com</field>
</shadow>
</value>
<value name="KEY">
<shadow type="text">
<field name="TEXT">API Key</field>
</shadow>
</value>
<value name="NAME">
<shadow type="text">
<field name="TEXT">deepseek-chat</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
</block>
<block type="use_ollama_llm_to_chat">
<value name="TOPIC">
<shadow type="text">
<field name="TEXT">请介绍一下米思齐?</field>
</shadow>
</value>
<value name="METHOD">
<shadow type="factory_block_return">
<field name="VALUE">content_callback</field>
</shadow>
</value>
</block>
<block type="procedures_defnoreturn">
<mutation>
<arg name="content"></arg>
</mutation>
<field name="NAME">content_callback</field>
<statement name="STACK">
<block type="system_print_end">
<value name="VAR">
<block type="variables_get">
<field name="VAR">content</field>
</block>
</value>
<value name="END">
<shadow type="text">
<field name="TEXT"></field>
</shadow>
</value>
</block>
</statement>
</block>
<block type="use_ollama_llm_to_chat_return">
<value name="TOPIC">
<shadow type="text">
<field name="TEXT">请介绍一下米思齐?</field>
</shadow>
</value>
</block>
<block type="ollama_empty_history"></block>
</category>
<category id="catFactory" name="Factory" colour="#777777">

View File

@@ -455,7 +455,7 @@
</shadow>
</value>
</block>
<block type="math_degree_to_radian">
<block type="math_degree_to_radian">
<value name="VAR">
<shadow type="math_number">
<field name="NUM">1</field>
@@ -1771,7 +1771,8 @@
<block type="image_arithmetic">
<value name="A">
<shadow type="pins_builtinimg"></shadow>
</value> <value name="B">
</value>
<value name="B">
<shadow type="pins_builtinimg"></shadow>
</value>
</block>
@@ -2718,7 +2719,7 @@
</statement>
</block>
</category>
<category id ="catBLEC" colour="140">
<category id="catBLEC" colour="140">
<block type="communicate_bluetooth_handle">
<value name="VAR">
<shadow type="variables_get">
@@ -2840,11 +2841,11 @@
</value>
</block> -->
<block type="analog_ble_keyboard_mouse_init">
<value name="kname">
<shadow type="text">
<field name="TEXT">ble_keyboard_mouse</field>
</shadow>
</value>
<value name="kname">
<shadow type="text">
<field name="TEXT">ble_keyboard_mouse</field>
</shadow>
</value>
</block>
<block type="ble_keyboard_mouse_get_mac"></block>
<block type="ble_keyboard_mouse_connect"></block>
@@ -2855,10 +2856,10 @@
</shadow>
</value>
</block>
<block type="analog_ble_keyboard_mouse_input" >
<block type="analog_ble_keyboard_mouse_input">
<value name="special">
<block type="special_key">
</block>
<block type="special_key">
</block>
</value>
<value name="general">
<block type="general_key">
@@ -2877,7 +2878,7 @@
</shadow>
</value>
</block>
<block type="analog_ble_mouse_keyboard_input" >
<block type="analog_ble_mouse_keyboard_input">
<value name="key">
<block type="mouse_key">
</block>
@@ -3764,12 +3765,12 @@
<value name="NUM">
<block type="logic_null"></block>
</value>
</block>
<block type = "CI130X_SET_SYSTEM_CMD">
</block>
<block type="CI130X_SET_SYSTEM_CMD">
<value name="SUB">
<shadow type="variables_get">
<field name="VAR">xsensor</field>
</shadow>
<shadow type="variables_get">
<field name="VAR">xsensor</field>
</shadow>
</block>
<block type="communicate_spi_init" m-hide='micropython:esp32c3:mixgocar_c3'>
<value name="VAR">
@@ -4107,7 +4108,7 @@
</shadow>
</value>
<value name="pc">
<shadow type="math_number">
<shadow type="math_number">
<field name="NUM">500</field>
</shadow>
</value>
@@ -6874,6 +6875,85 @@
</shadow>
</value>
</block>
<block type="iot_connect_ollama">
<value name="SERVER">
<shadow type="text">
<field name="TEXT">192.168.1.1</field>
</shadow>
</value>
<value name="NAME">
<shadow type="text">
<field name="TEXT">qwen2.5-coder:0.5b</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
</block>
<block type="iot_connect_openai">
<value name="SERVER">
<shadow type="text">
<field name="TEXT">https://api.deepseek.com</field>
</shadow>
</value>
<value name="KEY">
<shadow type="text">
<field name="TEXT">API Key</field>
</shadow>
</value>
<value name="NAME">
<shadow type="text">
<field name="TEXT">deepseek-chat</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
</block>
<block type="use_ollama_llm_to_chat">
<value name="TOPIC">
<shadow type="text">
<field name="TEXT">请介绍一下米思齐?</field>
</shadow>
</value>
<value name="METHOD">
<shadow type="factory_block_return">
<field name="VALUE">content_callback</field>
</shadow>
</value>
</block>
<block type="procedures_defnoreturn">
<mutation>
<arg name="content"></arg>
</mutation>
<field name="NAME">content_callback</field>
<statement name="STACK">
<block type="system_print_end">
<value name="VAR">
<block type="variables_get">
<field name="VAR">content</field>
</block>
</value>
<value name="END">
<shadow type="text">
<field name="TEXT"></field>
</shadow>
</value>
</block>
</statement>
</block>
<block type="use_ollama_llm_to_chat_return">
<value name="TOPIC">
<shadow type="text">
<field name="TEXT">请介绍一下米思齐?</field>
</shadow>
</value>
</block>
<block type="ollama_empty_history"></block>
</category>
<category id="catFactory" name="Factory" colour="#777777">
<block type="factory_import"></block>

View File

@@ -481,7 +481,7 @@
</shadow>
</value>
</block>
<block type="math_degree_to_radian">
<block type="math_degree_to_radian">
<value name="VAR">
<shadow type="math_number">
<field name="NUM">1</field>
@@ -3507,12 +3507,12 @@
<value name="NUM">
<block type="logic_null"></block>
</value>
</block>
<block type = "CI130X_SET_SYSTEM_CMD">
</block>
<block type="CI130X_SET_SYSTEM_CMD">
<value name="SUB">
<shadow type="variables_get">
<field name="VAR">xsensor</field>
</shadow>
<shadow type="variables_get">
<field name="VAR">xsensor</field>
</shadow>
</block>
<block type="communicate_spi_init">
<value name="VAR">
@@ -3849,7 +3849,7 @@
</shadow>
</value>
<value name="pc">
<shadow type="math_number">
<shadow type="math_number">
<field name="NUM">500</field>
</shadow>
</value>
@@ -6605,6 +6605,85 @@
</shadow>
</value>
</block>
<block type="iot_connect_ollama">
<value name="SERVER">
<shadow type="text">
<field name="TEXT">192.168.1.1</field>
</shadow>
</value>
<value name="NAME">
<shadow type="text">
<field name="TEXT">qwen2.5-coder:0.5b</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
</block>
<block type="iot_connect_openai">
<value name="SERVER">
<shadow type="text">
<field name="TEXT">https://api.deepseek.com</field>
</shadow>
</value>
<value name="KEY">
<shadow type="text">
<field name="TEXT">API Key</field>
</shadow>
</value>
<value name="NAME">
<shadow type="text">
<field name="TEXT">deepseek-chat</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
</block>
<block type="use_ollama_llm_to_chat">
<value name="TOPIC">
<shadow type="text">
<field name="TEXT">请介绍一下米思齐?</field>
</shadow>
</value>
<value name="METHOD">
<shadow type="factory_block_return">
<field name="VALUE">content_callback</field>
</shadow>
</value>
</block>
<block type="procedures_defnoreturn">
<mutation>
<arg name="content"></arg>
</mutation>
<field name="NAME">content_callback</field>
<statement name="STACK">
<block type="system_print_end">
<value name="VAR">
<block type="variables_get">
<field name="VAR">content</field>
</block>
</value>
<value name="END">
<shadow type="text">
<field name="TEXT"></field>
</shadow>
</value>
</block>
</statement>
</block>
<block type="use_ollama_llm_to_chat_return">
<value name="TOPIC">
<shadow type="text">
<field name="TEXT">请介绍一下米思齐?</field>
</shadow>
</value>
</block>
<block type="ollama_empty_history"></block>
</category>
<category id="catFactory" name="Factory" colour="#777777">
<block type="factory_import"></block>

View File

@@ -481,7 +481,7 @@
</shadow>
</value>
</block>
<block type="math_degree_to_radian">
<block type="math_degree_to_radian">
<value name="VAR">
<shadow type="math_number">
<field name="NUM">1</field>
@@ -1486,8 +1486,8 @@
<value name="NUM">
<block type="logic_null"></block>
</value>
</block>
<block type = "CI130X_SET_SYSTEM_CMD_SANT" m-show='micropython:esp32s3:mixgo_sant'></block>
</block>
<block type="CI130X_SET_SYSTEM_CMD_SANT" m-show='micropython:esp32s3:mixgo_sant'></block>
<block type="onboard_RTC_set_datetime">
<value name="year">
<shadow type="math_number">
@@ -1789,7 +1789,7 @@
</shadow>
</value>
</block>
<block type = "get_keyboard_light" m-show="micropython:esp32s3:mixgo_sant"></block>
<block type="get_keyboard_light" m-show="micropython:esp32s3:mixgo_sant"></block>
<block type="analog_keyboard_input" m-show="micropython:esp32s3:mixgo_sant">
<value name="special">
<block type="special_key">
@@ -3086,7 +3086,7 @@
</statement>
</block>
</category>
<category id ="catBLEC" colour="140">
<category id="catBLEC" colour="140">
<block type="communicate_bluetooth_handle">
<value name="VAR">
<shadow type="variables_get">
@@ -3134,7 +3134,7 @@
</statement>
</block>
</category>
<category id="catBLEKM" colour="140">
<category id="catBLEKM" colour="140">
<!-- <block type="analog_ble_keyboard_init">
<value name="kname">
<shadow type="text">
@@ -3208,11 +3208,11 @@
</value>
</block> -->
<block type="analog_ble_keyboard_mouse_init">
<value name="kname">
<shadow type="text">
<field name="TEXT">ble_keyboard_mouse</field>
</shadow>
</value>
<value name="kname">
<shadow type="text">
<field name="TEXT">ble_keyboard_mouse</field>
</shadow>
</value>
</block>
<block type="ble_keyboard_mouse_get_mac"></block>
<block type="ble_keyboard_mouse_connect"></block>
@@ -3223,10 +3223,10 @@
</shadow>
</value>
</block>
<block type="analog_ble_keyboard_mouse_input" >
<block type="analog_ble_keyboard_mouse_input">
<value name="special">
<block type="special_key">
</block>
<block type="special_key">
</block>
</value>
<value name="general">
<block type="general_key">
@@ -3245,7 +3245,7 @@
</shadow>
</value>
</block>
<block type="analog_ble_mouse_keyboard_input" >
<block type="analog_ble_mouse_keyboard_input">
<value name="key">
<block type="mouse_key">
</block>
@@ -4133,8 +4133,8 @@
<value name="NUM">
<block type="logic_null"></block>
</value>
</block>
<block type = "CI130X_SET_SYSTEM_CMD" m-hide='micropython:esp32s3:mixgo_sant'>
</block>
<block type="CI130X_SET_SYSTEM_CMD" m-hide='micropython:esp32s3:mixgo_sant'>
<value name="SUB">
<shadow type="variables_get">
<field name="VAR">xsensor</field>
@@ -4476,7 +4476,7 @@
</shadow>
</value>
<value name="pc">
<shadow type="math_number">
<shadow type="math_number">
<field name="NUM">500</field>
</shadow>
</value>
@@ -7290,6 +7290,85 @@
</shadow>
</value>
</block>
<block type="iot_connect_ollama">
<value name="SERVER">
<shadow type="text">
<field name="TEXT">192.168.1.1</field>
</shadow>
</value>
<value name="NAME">
<shadow type="text">
<field name="TEXT">qwen2.5-coder:0.5b</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
</block>
<block type="iot_connect_openai">
<value name="SERVER">
<shadow type="text">
<field name="TEXT">https://api.deepseek.com</field>
</shadow>
</value>
<value name="KEY">
<shadow type="text">
<field name="TEXT">API Key</field>
</shadow>
</value>
<value name="NAME">
<shadow type="text">
<field name="TEXT">deepseek-chat</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
</block>
<block type="use_ollama_llm_to_chat">
<value name="TOPIC">
<shadow type="text">
<field name="TEXT">请介绍一下米思齐?</field>
</shadow>
</value>
<value name="METHOD">
<shadow type="factory_block_return">
<field name="VALUE">content_callback</field>
</shadow>
</value>
</block>
<block type="procedures_defnoreturn">
<mutation>
<arg name="content"></arg>
</mutation>
<field name="NAME">content_callback</field>
<statement name="STACK">
<block type="system_print_end">
<value name="VAR">
<block type="variables_get">
<field name="VAR">content</field>
</block>
</value>
<value name="END">
<shadow type="text">
<field name="TEXT"></field>
</shadow>
</value>
</block>
</statement>
</block>
<block type="use_ollama_llm_to_chat_return">
<value name="TOPIC">
<shadow type="text">
<field name="TEXT">请介绍一下米思齐?</field>
</shadow>
</value>
</block>
<block type="ollama_empty_history"></block>
</category>
<category id="catFactory" name="Factory" colour="#777777">
<block type="factory_import"></block>

View File

@@ -468,7 +468,7 @@
</shadow>
</value>
</block>
<block type="math_degree_to_radian">
<block type="math_degree_to_radian">
<value name="VAR">
<shadow type="math_number">
<field name="NUM">1</field>
@@ -5675,6 +5675,85 @@
</shadow>
</value>
</block>
<block type="iot_connect_ollama">
<value name="SERVER">
<shadow type="text">
<field name="TEXT">192.168.1.1</field>
</shadow>
</value>
<value name="NAME">
<shadow type="text">
<field name="TEXT">qwen2.5-coder:0.5b</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
</block>
<block type="iot_connect_openai">
<value name="SERVER">
<shadow type="text">
<field name="TEXT">https://api.deepseek.com</field>
</shadow>
</value>
<value name="KEY">
<shadow type="text">
<field name="TEXT">API Key</field>
</shadow>
</value>
<value name="NAME">
<shadow type="text">
<field name="TEXT">deepseek-chat</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
</block>
<block type="use_ollama_llm_to_chat">
<value name="TOPIC">
<shadow type="text">
<field name="TEXT">请介绍一下米思齐?</field>
</shadow>
</value>
<value name="METHOD">
<shadow type="factory_block_return">
<field name="VALUE">content_callback</field>
</shadow>
</value>
</block>
<block type="procedures_defnoreturn">
<mutation>
<arg name="content"></arg>
</mutation>
<field name="NAME">content_callback</field>
<statement name="STACK">
<block type="system_print_end">
<value name="VAR">
<block type="variables_get">
<field name="VAR">content</field>
</block>
</value>
<value name="END">
<shadow type="text">
<field name="TEXT"></field>
</shadow>
</value>
</block>
</statement>
</block>
<block type="use_ollama_llm_to_chat_return">
<value name="TOPIC">
<shadow type="text">
<field name="TEXT">请介绍一下米思齐?</field>
</shadow>
</value>
</block>
<block type="ollama_empty_history"></block>
</category>
<category id="catFactory" name="Factory" colour="#777777">
<block type="factory_import"></block>