CNC扩展板基本功能和步进驱动
- CNC扩展板基本功能
- A轴可以根据需求设定为独立工作模式或者同步XYZ中的一轴。
- A4988驱动:注意en引脚对应CNC扩展版上的en引脚,否则会烧毁驱动
2025年01月02日
CNC扩展板基本功能和步进驱动
2025年01月02日
由于最近在测试各种开源模型性能,在终端测试下载下来的ollama 模型交互较为不方便,搬运工基于Gradio 手撸一个可以启动各种大模型的聊天界面;聊天交互界实现效果如下:
现将实战代码分享如下:
# -*- coding: utf-8 -*-
import gradio as gr
import ollama
from typing import List, Tuple
model_name_dict = {
"qwen2.5:32b": "qwen2.5:32b",
"qwen2.5:72b": "qwen2.5:72b",
"qwen2.5-coder": "qwen2.5-coder:32b",
"qwq-32b": "qwq:32b-preview-q8_0",
}
# LLMAsServer 模型即服务, 启动聊天界面
class LLMAsServer:
def __init__(self, model_name: str = model_name_dict["qwen2.5:32b"], is_stream=False):
self.model_name = model_name
self.is_stream = is_stream
def generate(self, text: str):
stream = ollama.generate(
stream=self.is_stream,
model=self.model_name,
prompt=text,
)
response = ""
if self.is_stream:
for chunk in stream:
response += chunk["response"]
else:
response = stream["response"]
return response
# api_generate 流式输出
def _api_generate(self, chat_history: List):
text = chat_history[-1]["content"]
response = self.generate(text)
yield chat_history + [{"role": "assistant", "content": response}]
@staticmethod
def _handle_user_message(user_message: str, history: list):
"""Handle the user submitted message. Clear message box and append to the history."""
new_history = history + [{"role": "user", "content": user_message}]
return '', new_history
@staticmethod
def _reset_chat() -> tuple:
"""Reset the agent's chat history. And clear all dialogue boxes."""
return "", []
def run(self):
custom_css = """
#box {
height: 500px;
overflow-y: scroll !important;
}
#clear-button {
background-color: blue !important;
color: white !important; /* Optional: Set text color to white for better contrast */
border: none !important; /* Optional: Remove default border */
border-radius: 2px !important; /* Optional: Add rounded corners */
height: 150px !important; /* Set the height of the Textbox */
}
#message-input {
width: 100% !important; /* Make the Textbox take up the full available width */
max-width: calc(100% - 50px) !important; /* Adjust for the ClearButton's width */
height: 150px !important; /* Increase the height to 50px */
}
#submit-button {
background-color: green !important;
}
textarea{
height: 100px !important; /* Ensure the inner container takes up the full height */
border-radius: 5px !important; /* Optional: Add rounded corners */
border-color: red !important;
border-style: solid !important;
}
"""
demo = gr.Blocks(
theme=gr.themes.Default(
primary_hue="red",
secondary_hue="pink"),
# css="#box { height: 420px; overflow-y: scroll !important}",
css=custom_css,
)
with demo:
gr.Markdown(
"# AI Chat \n"
"### This Application is Powered by The LLM Model {} \n".format(self.model_name.upper()),
)
chat_window = gr.Chatbot(
label="Message History",
scale=5,
type='messages',
elem_id="chatbot-container"
)
with gr.Row():
message_input = gr.Textbox(label="Input", placeholder="Type your message here...", scale=5,
elem_id="message-input")
clear = gr.ClearButton(elem_id="clear-button")
submit_button = gr.Button("Submit", elem_id="submit-button")
submit_button.click(
fn=self._handle_user_message,
inputs=[message_input, chat_window],
outputs=[message_input, chat_window]
).then(
fn=self._api_generate,
inputs=chat_window,
outputs=chat_window
)
message_input.submit(
self._handle_user_message,
inputs=[message_input, chat_window],
outputs=[message_input, chat_window],
).then(
self._api_generate,
chat_window,
chat_window,
)
clear.click(self._reset_chat, None, [message_input, chat_window])
demo.launch(show_error=True, share=False, server_port=7861)
if __name__ == "__main__":
server = LLMAsServer(model_name=model_name_dict["qwen2.5-coder"])
server.run()
2025年01月02日
IT之家(www.ithome.com):免费办公软件LibreOffice 4.3.3正式版下载
IT之家10月30日消息,知名文档基金会TDF正式发布旗下免费办公软件LibreOffice 4.3.3正式版,带来多项新特性以及功能改进,推荐老用户升级安装体验。
软件简介:LibreOffice是一套功能强大,面向个人生产的免费开源办公软件,支持Windows、Macintosh以及Linux平台。本次套件为用户提供了6个特色功能的应用程序,用来处理日常的文档处理和数据管理,包括:Writer, Calc, Impress, Draw, Math和Base。该六款特色应用分别可以用来处理文档、电子表格、幻灯片演示、图像处理、数学公式编写以及数据库管理。
2025年01月02日
不是只有国人才不用正版的Ms Office,笔者最近在浏览英国政府官方网站的时候,发现公开的政府文件使用的并不是Ms word而是开源的Openoffice Writer.
如果你不想用Microsoft Word,那么你可能听说没听说过的如下也是非常流行的
WPS 这个不用说,都很熟悉,不过离生产力还有好大一截
http://www.wps.cn
OpenOffice Calc 开源软件,免费,Linux操作系统的默认选择,不过连英国政府都用,为什么不用
2025年01月02日
clamp() 函数的作用是把一个值限制在一个上限和下限之间,当这个值超过最小值和最大值的范围时,在最小值和最大值之间选择一个值使用(低于最小值就用最小值,高于最大值就用最大值,就如卡钳一样)。它接收三个参数:最小值、首选值、最大值,当属性值在最小值与最大值之间时,用首选值(即第二个参数)。
clamp() 允许被用在 <length>、<frequency>、<angle>、<time>、<percentage>、<number>、<integer> 中。
2025年01月02日
面试中常被问到的问题,此问题包含web开发中从前端到后端到运维的绝大多数知识,主要考察面试者知识的广度。本文会根据作者了解的程度增加不断更新,不足之处欢迎评论区补充。
2025年01月02日
目录
2025年01月02日
最近家里小朋友的口算题卡做完了,本想着再买一些,可转念一想,让Cursor帮我写一个不是更有乐趣吗?
说干就干,需求也不复杂,也不用漂亮的界面,能出题就行,那就用html+js实现吧。
打开cursor,随便选个目录,ctrl+i呼出composer,告诉它“生成一个calc.html,用js生成100以内,两个数字的加减乘除算式生成,每行生成三个算式,共200行,尽量随机,不要重复”
2025年01月02日
VIVO虽为众多知名手机中的一款,其一直被埋没。但是它作为一个品牌,肯定会有其他手机所不具备的一些特点,而这些往往较为冷门,那么你知道VIVO手机里面有哪些小众又逆天的隐藏功能呢?让我偷偷来告诉大家吧。
2025年01月02日
display:none和visibility:hidden都可以让一个div消失,那他们具体的区别在哪里呢: