Try Langchain

刚了解下langchain,简单写个 AI助手的langchain版本 Code 安装依赖 pip install langchain langchain-community pyjwt python-dotenv 申请大模型帐号 到这里申请一个智谱AI的帐号,注册就

Download Hugging Face Model

国内镜像 https://hf-mirror.com/ 具体步骤 创建conda环境,如果不记得,可以参考这里 conda create --name hfd python=3.12.5 conda activate hfd conda install huggingface_hub export HF_ENDPOINT=https://hf-mirror.com # bash $env:HF_ENDPOINT = "https://hf-mirror.com" # pwsh huggingface-cli download --resume-download gpt2 --local-dir gpt2 # 下载模型,gpt2为模型

Try LLM App

gpt4free pip install g4f code from typing import List, Any import sys from g4f.client import Client import asyncio if sys.platform == "win32": asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) def fetch_ai(client: Client, messages: List[Any]) -> str: chunks = [] print("AI: ", end="") stream = client.chat.completions.create( model="gpt-4", messages=messages, stream=True, ) for msg in stream: chunk = msg.choices[0].delta.content if chunk: chunks.append(chunk) print(chunk, end="", flush=True) else: print("") return "".join(chunks) def main(): client = Client() print

How to Create Blog Like This

git仓库准备 下载我的博客最新版 解压后,到代码根目录执行 git init 删除 themes/LoveIt 文件夹 git submodule add https://github.com/dillonzq/LoveIt.git themes/LoveIt 删除 content/posts 中的所有子文件和子文件夹,但要保留 content/posts 文件 修改 conf

Fnm Mirror

fnm env --use-on-cd | Out-String | Invoke-Expression fnm completions --shell power-shell | Out-String | Invoke-Expression $env:FNM_NODE_DIST_MIRROR="https://npmmirror.com/dist"

Conda

conda 使用指南 miniconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda 更改仓库地址: https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/ conda init conda config --set auto_activate_base false 环境管理 conda create --name myenv python=3.9 conda activate myenv conda deactivate conda env list conda remove --name myenv --all 包管理 conda install requests conda list conda update requests conda update all conda list --explicit > a.txt conda install --file a.txt

Windows Gitlab Ci

命令行切换到 system 用户 Windows上默认gitlab-runner是以 system 用户运行的,如果要更改 ci 的运行配置,那就必须要以 system 用户来完成这些设置。

Try Toga

Toga 是一个跨平台的Python GUI库, 支持Android和iOS,有一些简单的控件。它不像kivy那么复杂,kivy要求我们去学习 一种新的脚

C++ Constexpr Static Instances

下面这个代码是无法编译通过的 class A { public: A(val) : val{val} {} static constexpr A a1{0}; private: int val; }; 不过稍加修改就可以了,参考这里 7.1.5p9 The constexpr specifier [dcl.constexpr] (n3337) A constexpr specifier used in an object declaration declares the object as const. Such an object shall have literal

Cargo Feature

cargo add 确实挺好用,但是某个crate到底有多少个feature呢,经常连文档都说得不是很清楚。 幸好我们有 cargo feature 可以列出某个crate的所有fea

Rust minimize

rust默认的release版仍然挺大的,其实还有改进空间,这里有介绍, 这里有官方文档。简单来说可以在cargo.toml中添加以下内容 strip =

Elm 的一点想法

Elm 之前在了解rust的ui时,碰巧了解到了Elm,yew和iced都说参考了它, 而它也标榜自己是 A delightful language for reliable web applications. 昨天终于还是没有忍住,在空闲的

Crypto++ Tips

编译安装 说到加密,首先想到的当然是 openssl,但是当我想用mingw64的clang++编译时,发现还需要perl,下载perl发现还是

Nsis

一般的编译成release之后,找个地方一扔就可以运行了。但是有些时候,我们需要在用户机器上执行个脚本, 然后还要创建几个快捷方式。搞一个安装

Python Watch File Changes

说到用Python监控文件夹的变化,大家都是推荐 watchdog, 但是我发现这个工具有的时候会误报,我这里误报之后会执行编译,影响比较大。 然

Qt Get Rid of Console Window

Qt程序cmake编译出来,运行时会弹出控制台窗口,有人说这样 add_executable(TargetName WIN32 main.cpp) 就不会有。但是好像没有什么作用。 这个方法是可以的, target_link_options(TargetName PRIVATE -mwindows)

Simple Http Server

调试时,简单的http服务,以前一直使用 python -m http.server 但是有些脚本需要cors头, python默认就不行了,还得自己写。不过,幸好还有rust的si