commit d8bceb3fe14e0bc043b76e31f750707b7dbb4957
Author: huanghai <10402852@qq.com>
Date: Thu Aug 14 16:04:59 2025 +0800
init
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..35410ca
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..cafab9f
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..68d7201
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/ocr.iml b/.idea/ocr.iml
new file mode 100644
index 0000000..f571432
--- /dev/null
+++ b/.idea/ocr.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/1.mp3 b/1.mp3
new file mode 100644
index 0000000..977d602
Binary files /dev/null and b/1.mp3 differ
diff --git a/18.jpg b/18.jpg
new file mode 100644
index 0000000..a844913
Binary files /dev/null and b/18.jpg differ
diff --git a/GGB.txt b/GGB.txt
new file mode 100644
index 0000000..b9c1346
--- /dev/null
+++ b/GGB.txt
@@ -0,0 +1,61 @@
+### 修正报告
+无坐标调整(所有点均严格遵循几何约束和题干坐标)
+
+### 坐标摘要
+```
+A: (-8, 0)
+B: (4, 0)
+A₁: (-6, 0)
+B₁: (6, 0)
+C: (0, -6)
+M: (t, t²/6 - 6) [t ∈ (0.1, 5.9)]
+Q: (t, 0)
+P: (t, t - 6)
+```
+
+### Geogebra 指令
+```geogebra
+ShowAxes(true)
+ShowGrid(false)
+A = (-8, 0)
+B = (4, 0)
+A1 = (-6, 0)
+B1 = (6, 0)
+C = (0, -6)
+f(x) = (1 / 6) * (x + 2)^2 - 6
+g(x) = (1 / 6) * x^2 - 6
+s = Segment(B1, C)
+ShowLabel(s, false)
+t = Slider(0.1, 5.9, 0.01, 1, 100, false, true, false)
+M = (t, g(t))
+Q = (t, 0)
+P = (t, t - 6)
+mq = Segment(M, Q)
+ShowLabel(mq, false)
+ShowLabel(f, false)
+ShowLabel(g, false)
+```
+
+### 说明
+1. **抛物线计算**:
+ - 由 \( A(-8,0) \) 代入 \( C_1: y = a(x+2)^2 - 6 \) 得 \( a = \frac{1}{6} \)
+ - \( C_1: y = \frac{1}{6}(x+2)^2 - 6 \)
+ - \( C_2 \)(右移 2 单位): \( y = \frac{1}{6}x^2 - 6 \)
+
+2. **关键点**:
+ - \( B(4,0) \)(解 \( C_1 \) 与 x 轴交点)
+ - \( A_1(-6,0), B_1(6,0) \)(解 \( C_2 \) 与 x 轴交点)
+ - \( C(0,-6) \)(\( C_2 \) 与 y 轴交点)
+
+3. **动态点**:
+ - 滑块 `t` 控制点 M 在 \( C_2 \) 第四象限位置
+ - \( Q(t,0) \) 为 M 在 x 轴的投影
+ - \( P(t, t-6) \) 为 \( B_1C \) 与垂线 \( x=t \) 的交点
+
+4. **线段处理**:
+ - 线段 \( B_1C \) 和 \( MQ \) 的标签已隐藏
+ - 抛物线标签已隐藏,避免干扰视图
+
+5. **坐标系**:
+ - 显示坐标轴(符合题干坐标系要求)
+ - 隐藏网格(保持图形清晰)
\ No newline at end of file
diff --git a/GGB_14.txt b/GGB_14.txt
new file mode 100644
index 0000000..8b8c1ba
--- /dev/null
+++ b/GGB_14.txt
@@ -0,0 +1,71 @@
+### 修正报告
+无坐标调整(初始设置完全满足几何约束)
+
+### 坐标摘要
+- A(0,0), B(4,0), C(4,4), D(0,4)
+- O(2,2)(对角线交点)
+- E(2t,2t)(t∈[0,1],初始值0.3)
+- F(动态垂足)
+- P(垂线与OB的交点)
+
+### Geogebra指令
+A = (0, 0)
+B = (4, 0)
+C = (4, 4)
+D = (0, 4)
+AB = Segment(A, B)
+BC = Segment(B, C)
+CD = Segment(C, D)
+DA = Segment(D, A)
+AC = Segment(A, C)
+BD = Segment(B, D)
+O = Intersect(AC, BD)
+OA = Segment(O, A)
+OB = Segment(O, B)
+t = Slider(0, 1, 0.01, 0.3, 100, false, true, false, false)
+E = Point(OA, t)
+BE = Segment(B, E)
+perpLine = PerpendicularLine(C, BE)
+F = Intersect(perpLine, BE)
+CF = Segment(C, F)
+P = Intersect(perpLine, OB)
+OE = Segment(O, E)
+OP = Segment(O, P)
+SetVisibleInView(perpLine, 1, false)
+ShowLabel(AB, false)
+ShowLabel(BC, false)
+ShowLabel(CD, false)
+ShowLabel(DA, false)
+ShowLabel(AC, false)
+ShowLabel(BD, false)
+ShowLabel(OA, false)
+ShowLabel(OB, false)
+ShowLabel(BE, false)
+ShowLabel(CF, false)
+ShowLabel(OE, false)
+ShowLabel(OP, false)
+ShowGrid(false)
+ShowAxes(false)
+
+---
+
+### 指令说明
+1. **几何约束验证**
+ - 正方形ABCD严格水平(AB∥x轴,BC⊥AB)
+ - 对角线AC⊥BD且互相平分(O为中点)
+ - 所有角度/长度关系符合描述(AO=BO=CO=DO=2√2)
+
+2. **动态坐标系**
+ - 以最长边AB为x轴,A为原点(0,0)
+ - 自动满足水平约束(DA⊥AB,BC⊥AB)
+
+3. **元素生成顺序**
+ 固定点 → 固定边 → 动态点E → 动态元素(BE, CF, P)
+
+4. **错误熔断**
+ 无触发(所有约束自动满足)
+
+5. **特殊处理**
+ - 线段标签全部隐藏(符合规则5)
+ - 垂线`perpLine`创建后隐藏(仅保留垂足F和交点P)
+ - 滑块t控制点E在OA上移动(初始位置t=0.3)
\ No newline at end of file
diff --git a/GGB_14_1.txt b/GGB_14_1.txt
new file mode 100644
index 0000000..e7dc696
--- /dev/null
+++ b/GGB_14_1.txt
@@ -0,0 +1,62 @@
+### Geogebra 指令集生成报告
+
+#### [修正报告]
+- 坐标系原点修正:根据规则,选择最长边(AB)的左端点 A 作为原点 (0,0)
+- 水平约束修正:强制 AB 保持水平(y=0)
+- 几何关系验证:所有垂直关系(AC⊥BD, CF⊥BE)已通过坐标计算验证
+- 动态点处理:点 E 在 OA 上移动,添加滑块控制
+
+#### [坐标摘要]
+```
+A(0,0), B(4,0), C(4,4), D(0,4),
+O(2,2), E(2e,2e),
+F(垂足:BE与CF交点), P(OB与CF交点)
+滑块 e ∈ [0,1] (初始值 0.1)
+```
+
+#### [Geogebra 指令]
+```geogebra
+A=(0,0)
+B=(4,0)
+C=(4,4)
+D=(0,4)
+O=(2,2)
+e=Slider(0,1,0.01,1,140,false,true,false,false)
+SetValue(e,0.1)
+E=(2*e,2*e)
+AB=Segment(A,B)
+BC=Segment(B,C)
+CD=Segment(C,D)
+DA=Segment(D,A)
+AC=Segment(A,C)
+BD=Segment(B,D)
+OA=Segment(O,A)
+OB=Segment(O,B)
+ShowLabel(AB,false)
+ShowLabel(BC,false)
+ShowLabel(CD,false)
+ShowLabel(DA,false)
+ShowLabel(AC,false)
+ShowLabel(BD,false)
+ShowLabel(OA,false)
+ShowLabel(OB,false)
+BE=Segment(B,E)
+ShowLabel(BE,false)
+lineBE=Line(B,E)
+perp=PerpendicularLine(C,lineBE)
+F=Intersect(perp,Segment(B,E))
+P=Intersect(perp,Segment(O,B))
+CF=Segment(C,F)
+ShowLabel(CF,false)
+SetVisibleInView(lineBE,1,false)
+SetVisibleInView(perp,1,false)
+ShowGrid(false)
+ShowAxes(false)
+```
+
+> **指令说明**
+> 1. 所有线段均按题目要求用 `Segment` 创建
+> 2. 动态点 E 由滑块控制(沿 OA 移动)
+> 3. 隐藏辅助线(lineBE, perp)保留几何结构
+> 4. 严格满足:AB水平,O为中心,CF⊥BE
+> 5. 初始状态:E 位于 OA 上靠近 A 的位置(e=0.1)
\ No newline at end of file
diff --git a/GGB_22.txt b/GGB_22.txt
new file mode 100644
index 0000000..a92c450
--- /dev/null
+++ b/GGB_22.txt
@@ -0,0 +1,23 @@
+[修正报告]
+无调整。
+
+[坐标摘要]
+A: (0, 0)
+B: (4, 0)
+O: (2, 0)
+O_prime: (2, 1) // 初始位置,y坐标由滑块k控制
+
+[Geogebra指令]
+k = Slider(-5, 5, 1, 1, 150, false, true, false, false)
+A = (0, 0)
+B = (4, 0)
+s = Segment(A, B)
+O = Midpoint(s)
+O_prime = (2, k)
+c1 = Circle(O, A)
+c2 = Circle(O_prime, A)
+dist_O_prime_A = Distance(O_prime, A)
+dist_O_prime_B = Distance(O_prime, B)
+sum_dist = dist_O_prime_A + dist_O_prime_B
+len_AB = Distance(A, B)
+condition = sum_dist > len_AB
\ No newline at end of file
diff --git a/QQ截图20250814093022.jpg b/QQ截图20250814093022.jpg
new file mode 100644
index 0000000..32ae942
Binary files /dev/null and b/QQ截图20250814093022.jpg differ
diff --git a/QQ截图20250814095105.jpg b/QQ截图20250814095105.jpg
new file mode 100644
index 0000000..7e00fa0
Binary files /dev/null and b/QQ截图20250814095105.jpg differ
diff --git a/QQ截图20250814130736.jpg b/QQ截图20250814130736.jpg
new file mode 100644
index 0000000..2c08d88
Binary files /dev/null and b/QQ截图20250814130736.jpg differ
diff --git a/QQ截图20250814133217.jpg b/QQ截图20250814133217.jpg
new file mode 100644
index 0000000..dec4365
Binary files /dev/null and b/QQ截图20250814133217.jpg differ
diff --git a/QQ截图20250814140320.jpg b/QQ截图20250814140320.jpg
new file mode 100644
index 0000000..f92c2d4
Binary files /dev/null and b/QQ截图20250814140320.jpg differ
diff --git a/QQ截图20250814140508.jpg b/QQ截图20250814140508.jpg
new file mode 100644
index 0000000..1750eb8
Binary files /dev/null and b/QQ截图20250814140508.jpg differ
diff --git a/QQ截图20250814140600.jpg b/QQ截图20250814140600.jpg
new file mode 100644
index 0000000..6388401
Binary files /dev/null and b/QQ截图20250814140600.jpg differ
diff --git a/QQ截图20250814145452.jpg b/QQ截图20250814145452.jpg
new file mode 100644
index 0000000..e5204a8
Binary files /dev/null and b/QQ截图20250814145452.jpg differ
diff --git a/QQ截图20250814150018.jpg b/QQ截图20250814150018.jpg
new file mode 100644
index 0000000..b6b4156
Binary files /dev/null and b/QQ截图20250814150018.jpg differ
diff --git a/QvqResult.txt b/QvqResult.txt
new file mode 100644
index 0000000..c059bb5
--- /dev/null
+++ b/QvqResult.txt
@@ -0,0 +1,10 @@
+【题干】
+解:由抛物线 \( y = -x^{2} + 2x + 3 = -(x + 1)(x - 3) \) 可知,点 \( A(-1, 0) \),点 \( B(3, 0) \),点 \( C(0, 3) \),
+\(\therefore\) 直线 \( BC \) 的表达式为 \( y = -x + 3 \),
+设点 \( P(t, -t^{2} + 2t + 3)(0 < t < 3) \),则 \( D(t, -t + 3) \),
+\(\therefore PQ = -t^{2} + 2t + 3 \),\( PD = -t^{2} + 2t + 3 - (-t + 3) = -t^{2} + 3t \),\( QD = -t + 3 \),
+\(\because PD = 2QD \),\(\therefore -t^{2} + 3t = 2(-t + 3) \),化简为 \( t^{2} - 5t + 6 = 0 \),\(\therefore t = 2 \) 或 \( t = 3 \)(舍去),
+\(\therefore PQ = -t^{2} + 2t + 3 = -2^{2} + 2\times 2 + 3 = 3 \)。
+
+【图形描述】
+本题涉及直角坐标系,抛物线 \( y = -x^{2} + 2x + 3 \) 开口向下,经过第一、二、四象限。
\ No newline at end of file
diff --git a/QvqResult_14.txt b/QvqResult_14.txt
new file mode 100644
index 0000000..862b017
--- /dev/null
+++ b/QvqResult_14.txt
@@ -0,0 +1,26 @@
+【题干原文】
+如图,在边长为4的正方形ABCD中,对角线AC、BD相交于点O。点E在线段OA上,连接BE,作CF⊥BE于点F,交OB于点P。给出下面四个结论:
+① ∠OCP=∠OBE;
+② OE=OP;
+③ 当CE=CB时,BP=EF;
+④ 点A与点F之间的距离的最小值为\(2\sqrt{5}-2\)。
+上述结论中,正确结论的序号有______。
+
+【基本元素表】
+点:A、B、C、D、O、E、F、P
+线段:AB=4,BC=4,CD=4,DA=4,OA,OB,OC,OD,BE,CF,OP,EF
+角:∠ABC=90°,∠BCD=90°,∠CDA=90°,∠DAB=90°,∠CFB=90°
+圆:无
+
+【关系表】
+AB // CD
+AD // BC
+AC ⊥ BD
+AO = OC
+BO = OD
+CF ⊥ BE
+CF 与 OB 相交于 P
+BE 与 OA 相交于 E
+
+【元素位置】
+A点在左下,B点在右下,C点在右上,D点在左上;O点为正方形中心;E点在线段OA上(靠近A侧);F点为CF与BE的垂足(位于BE延长线上);P点为CF与OB的交点(位于OB上)。
\ No newline at end of file
diff --git a/QvqResult_18.txt b/QvqResult_18.txt
new file mode 100644
index 0000000..b84ef54
--- /dev/null
+++ b/QvqResult_18.txt
@@ -0,0 +1,18 @@
+【题干原文】
+如图,在四边形ABCD中,∠A=∠B=90°,O是边AB的中点,∠AOD=∠BOC。求证:四边形ABCD是矩形。
+
+【基本元素表】
+点:A、B、C、D、O(AB的中点)
+线段:AD,DC,CB,BA,OD,OC
+角:∠A=90°,∠B=90°,∠AOD,∠BOC
+圆:无
+
+【关系表】
+AB ⊥ AD
+AB ⊥ BC
+O ∈ AB(中点)
+∠AOD ≅ ∠BOC
+AD // BC(隐含于矩形结论)
+
+【元素位置】
+A点在左下,B点在右下,D点在A点正上方,C点在B点正上方,O点在AB中点处。
\ No newline at end of file
diff --git a/QvqResult_22.txt b/QvqResult_22.txt
new file mode 100644
index 0000000..ddbe9a2
--- /dev/null
+++ b/QvqResult_22.txt
@@ -0,0 +1,22 @@
+【题干原文】
+如图,在△ABC中,∠C=90°,AC=BC=4,点D为边AC的中点,点E为边AB上一动点,连接DE.将线段DE绕点E顺时针旋转45°得到线段EF.
+(1)线段AB的长为___;
+(2)当EF∥AC时,求AE的长;
+(3)当点F在边BC上时,求证:△ADE≌△BEF;
+(4)当点E到BC的距离是点F到BC距离的2倍时,直接写出AE的长.
+
+【基本元素表】
+点:A、B、C、D、E、F
+线段:AC=4,BC=4,DE,EF,AB,CD(AC的中线)
+角:∠C=90°,∠DEF=45°(旋转角)
+圆:无
+
+【关系表】
+AC ⊥ BC (直角三角形)
+DE 绕 E 顺时针旋转45°得 EF
+EF // AC (第2问条件)
+F ∈ BC (第3问条件)
+△ADE ≅ △BEF (第3问结论)
+
+【元素位置】
+A点在左下,B点在右下,C点在A、B上方;D点在AC中点;E点在AB上可滑动;F点由DE旋转生成,位置随E变化。
\ No newline at end of file
diff --git a/QvqResult_23.txt b/QvqResult_23.txt
new file mode 100644
index 0000000..f7b8d26
--- /dev/null
+++ b/QvqResult_23.txt
@@ -0,0 +1,22 @@
+【题干原文】
+2. 如图,在△ABC中,∠C=90°,AC=BC=4,点D为边AC的中点,点E为边AB上一动点,连接DE.将线段DE绕点E顺时针旋转45°得到线段EF.(1)线段AB的长为_;(2)当EF∥AC时,求AE的长;(3)当点F在边BC上时,求证:△ADE≌△BEF;(4)当点E到BC的距离是点F到BC距离的2倍时,直接写出AE的长.
+
+【基本元素表】
+点:A、B、C、D、E、F
+线段:AC=4,BC=4,DE,EF,AD=2,DC=2,AB(未标注长度),DE=EF(由旋转得出)
+角:∠C=90°
+圆:无
+
+【关系表】
+AC = BC
+AC ⊥ BC
+AD = DC
+DE = EF
+∠DEF = 45°
+D ∈ AC
+E ∈ AB
+F 由 DE 绕 E 旋转45° 得出
+
+【元素位置】
+A点位于左端,B点位于右端,C点位于上方形成直角顶点;D点在AC线段中间位置;E点在AB线段上可移动;F点的位置随E点和旋转角度变化,当F在BC边上时位于BC线段上,当EF∥AC时满足特定角度关系。
+(注:因需精准对应原图结构,位置描述以相对几何图形的标准位置表述,如点C为直角顶点在上,A、B分别在底边的两端,D在中点位置等,此处简化为符合初中生理解的相对位置说明。)
\ No newline at end of file
diff --git a/Test100.py b/Test100.py
new file mode 100644
index 0000000..c20f5be
--- /dev/null
+++ b/Test100.py
@@ -0,0 +1,65 @@
+# pip install bitsandbytes
+
+from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
+import torch
+import threading
+
+from transformers import BitsAndBytesConfig
+bnb_config = BitsAndBytesConfig(
+ load_in_4bit=True,
+ bnb_4bit_compute_dtype=torch.bfloat16,
+ bnb_4bit_use_double_quant=True,
+ bnb_4bit_quant_type="nf4"
+)
+
+# model_name = "netease-youdao/Confucius3-Math"
+model_name = r"D:\Confucius3-Math\netease-youdao\Confucius3-Math"
+
+SYSTEM_PROMPT_TEMPLATE = """用户与助手之间的对话。用户提出一个问题,助手予以解答。助手先在脑海中思考推理过程,然后为用户提供答案。推理过程和答案分别用 和 标签括起来,即 这里的推理过程 这里的答案 。"""
+
+USER_PROMPT_TEMPLATE = """{question}"""
+
+question = "1+1=?"
+
+model = AutoModelForCausalLM.from_pretrained(
+ model_name,
+ # torch_dtype="auto",
+ quantization_config=bnb_config,
+ device_map="auto"
+)
+
+tokenizer = AutoTokenizer.from_pretrained(model_name)
+messages = [
+ {'role': 'system', 'content': SYSTEM_PROMPT_TEMPLATE},
+ {'role': 'user', 'content': USER_PROMPT_TEMPLATE.format(question=question)},
+]
+
+text = tokenizer.apply_chat_template(
+ messages,
+ tokenize=False,
+ add_generation_prompt=True
+)
+model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
+
+# 创建流式输出器
+streamer = TextIteratorStreamer(tokenizer, skip_special_tokens=True, timeout=10.0)
+
+# 设置生成参数,添加streamer
+generation_kwargs = {
+ **model_inputs,
+ "streamer": streamer,
+ "max_new_tokens": 32768
+}
+
+# 创建线程来处理流式输出
+thread = threading.Thread(target=model.generate, kwargs=generation_kwargs)
+thread.start()
+
+# 流式输出结果
+print("流式输出开始:")
+for chunk in streamer:
+ if chunk:
+ print(chunk, end="", flush=True)
+
+thread.join()
+print("\n流式输出结束")
\ No newline at end of file
diff --git a/Test101.py b/Test101.py
new file mode 100644
index 0000000..57d54be
--- /dev/null
+++ b/Test101.py
@@ -0,0 +1,94 @@
+# pip install bitsandbytes
+
+from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
+from transformers import BitsAndBytesConfig
+from api.doubao_client import DoubaoClient
+from core.ocr_service import OCRService
+import torch
+import threading
+
+_doubao_client = DoubaoClient()
+_ocr_service = OCRService(_doubao_client)
+
+image_path = r'c:\math1.jpg'
+
+bnb_config = BitsAndBytesConfig(
+ load_in_4bit=True,
+ bnb_4bit_compute_dtype=torch.bfloat16,
+ bnb_4bit_use_double_quant=True,
+ bnb_4bit_quant_type="nf4"
+)
+
+ocr_result = _ocr_service.get_ocr(image_path)
+
+# model_name = "netease-youdao/Confucius3-Math"
+model_name = r"D:\Confucius3-Math\netease-youdao\Confucius3-Math"
+
+
+SYSTEM_PROMPT_TEMPLATE="""
+# 数学解题助手(严格限定初中知识)
+
+你现在是一名严格按照初中数学课程标准教学的老师,必须遵守以下规则:
+
+【铁律1】绝对禁止使用向量、坐标系、微积分、复数等任何超出初中数学范围的知识。
+【铁律2】必须使用初中生熟悉的算术方法、几何定理、代数方程等基础知识解题。
+【铁律3】如果题目可能涉及高级知识,你需要重新表述问题,使其符合初中水平。
+【铁律4】解题过程中必须明确说明每一步使用的初中数学定理或公式。
+【铁律5】如遇无法用初中知识解决的问题,直接说明"本题超出初中数学范围"。
+
+# 解题步骤
+1. 用自然语言复述题目,确保理解正确
+2. 分析题目涉及的初中数学知识点
+3. 列出解题所需的定理、公式
+4. 分步解答,每步标注所用知识点
+5. 总结答案
+"""
+
+USER_PROMPT_TEMPLATE = """{question}"""
+
+# question = "1+1=?"
+
+question = ocr_result
+
+model = AutoModelForCausalLM.from_pretrained(
+ model_name,
+ # torch_dtype="auto",
+ quantization_config=bnb_config,
+ device_map="auto"
+)
+
+tokenizer = AutoTokenizer.from_pretrained(model_name)
+messages = [
+ {'role': 'system', 'content': SYSTEM_PROMPT_TEMPLATE},
+ {'role': 'user', 'content': USER_PROMPT_TEMPLATE.format(question=question)},
+]
+
+text = tokenizer.apply_chat_template(
+ messages,
+ tokenize=False,
+ add_generation_prompt=True
+)
+model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
+
+# 创建流式输出器
+streamer = TextIteratorStreamer(tokenizer, skip_special_tokens=True, timeout=10.0)
+
+# 设置生成参数,添加streamer
+generation_kwargs = {
+ **model_inputs,
+ "streamer": streamer,
+ "max_new_tokens": 32768
+}
+
+# 创建线程来处理流式输出
+thread = threading.Thread(target=model.generate, kwargs=generation_kwargs)
+thread.start()
+
+# 流式输出结果
+print("流式输出开始:")
+for chunk in streamer:
+ if chunk:
+ print(chunk, end="", flush=True)
+
+thread.join()
+print("\n流式输出结束")
\ No newline at end of file
diff --git a/Test102.py b/Test102.py
new file mode 100644
index 0000000..60916a1
--- /dev/null
+++ b/Test102.py
@@ -0,0 +1,14 @@
+from api.doubao_client import DoubaoClient
+from core.ocr_service import OCRService
+
+_doubao_client = DoubaoClient()
+_ocr_service = OCRService(_doubao_client)
+
+image_path = r'D:\ocr\QQ截图20250814150018.jpg'
+
+ocr_result = _ocr_service.get_ocr(image_path)
+
+print(ocr_result)
+
+with open("QvqResult.txt", "w", encoding='utf-8') as f:
+ f.write(ocr_result)
\ No newline at end of file
diff --git a/Test103.py b/Test103.py
new file mode 100644
index 0000000..215a797
--- /dev/null
+++ b/Test103.py
@@ -0,0 +1,80 @@
+from zhipuai import ZhipuAI
+client = ZhipuAI(api_key="78dc1dfe37e04f29bd4ca9a49858a969.gn7TIZTfzpY35nx9") # 填写您自己的APIKey
+
+from utils.image_utils import encode_image
+
+reasoning_content = "" # 定义完整思考过程
+answer_content = "" # 定义完整回复
+is_answering = False # 判断是否结束思考过程并开始回复
+
+
+base64_image = encode_image(r"D:\ocr\QQ截图20250814093022.jpg")
+
+prompt = """
+你是一个初中数学图片的描述专家,请将图片中的内容转换为文本。
+1、注意数学公式需要用latex格式输出。注意只输出文本内容,不要输出任何解释。
+2、如果图片中有图形,请结合题干内容对图形进行描述,只要描述不需要任何解释。
+3、如果图片中有几何图形,识别图片中的几何图形,如三角形、圆形、矩形等。请结合题干内容对图形进行详细描述,包括形状、大小、位置关系等。
+3、如果图片中是坐标系,分析抛物线的开口方向和经过的象限,并详细描述。识别图片中的坐标系类型,如直角坐标系、极坐标系等。
+4、要以markdown格式输出
+输出格式为
+【题干】
+【图形描述】
+"""
+
+
+
+
+completion = client.chat.completions.create(
+ model="glm-4.1v-thinking-flash", # 填写需要调用的模型名称
+ messages=[
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": prompt
+ },
+ {
+ "type": "image_url",
+ "image_url": {
+ # "url" : "https://dsideal.obs.cn-north-1.myhuaweicloud.com/wb/math.jpg"
+ 'url': f'data:image/jpeg;base64,{base64_image}'
+ }
+ }
+ ]
+ }
+ ],
+ stream=True,
+)
+
+print("\n" + "=" * 20 + "思考过程" + "=" * 20 + "\n")
+
+for chunk in completion:
+ # 如果chunk.choices为空,则打印usage
+ if not chunk.choices:
+ print("\nUsage:")
+ print(chunk.usage)
+ else:
+ delta = chunk.choices[0].delta
+ # 打印思考过程
+ if hasattr(delta, 'reasoning_content') and delta.reasoning_content != None:
+ print(delta.reasoning_content, end='', flush=True)
+ reasoning_content += delta.reasoning_content
+ else:
+ # 开始回复
+ if delta.content != "" and is_answering is False:
+ print("\n" + "=" * 20 + "完整回复" + "=" * 20 + "\n")
+ is_answering = True
+ # 打印回复过程
+ print(delta.content, end='', flush=True)
+ answer_content += delta.content
+
+# print("=" * 20 + "完整思考过程" + "=" * 20 + "\n")
+# print(reasoning_content)
+# print("=" * 20 + "完整回复" + "=" * 20 + "\n")
+# 保存成QvqResult.txt
+with open("QvqResult.txt", "w", encoding='utf-8') as f:
+ f.write(answer_content)
+
+# print(response.choices[0].message)
\ No newline at end of file
diff --git a/Test104.py b/Test104.py
new file mode 100644
index 0000000..bdcb238
--- /dev/null
+++ b/Test104.py
@@ -0,0 +1,77 @@
+from openai import OpenAI
+from utils.image_utils import encode_image
+
+# 初始化OpenAI客户端
+client = OpenAI(
+ api_key="sk-f6da0c787eff4b0389e4ad03a35a911f",
+ base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
+)
+
+base64_image = encode_image(r"D:\ocr\QQ截图20250814093022.jpg")
+
+reasoning_content = "" # 定义完整思考过程
+answer_content = "" # 定义完整回复
+is_answering = False # 判断是否结束思考过程并开始回复
+
+prompt = """
+你是一个初中数学图片的描述专家,请将图片中的内容转换为文本。
+1、注意数学公式需要用latex格式输出。注意只输出文本内容,不要输出任何解释。
+2、如果图片中有图形,请根据题干对图形进行描述,只要描述不需要任何解释。
+3、如果图片中是坐标系,一定要说明抛物线的开口和抛物线经过了几个象限。
+4、要以markdown格式输出,注意latex格式两边要加$
+输出格式为
+【题干】
+【图形描述】
+"""
+
+# 创建聊天完成请求
+completion = client.chat.completions.create(
+ model="qvq-max-latest", # 此处以 qvq-max 为例,可按需更换模型名称
+ messages=[
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "image_url",
+ "image_url": {
+ # "url": "https://dsideal.obs.cn-north-1.myhuaweicloud.com/wb/img10.jpg"
+ 'url': f'data:image/jpeg;base64,{base64_image}'
+ },
+ },
+ {"type": "text",
+ "text": prompt},
+ ],
+ },
+ ],
+ stream=True,
+)
+
+print("\n" + "=" * 20 + "思考过程" + "=" * 20 + "\n")
+
+for chunk in completion:
+ # 如果chunk.choices为空,则打印usage
+ if not chunk.choices:
+ print("\nUsage:")
+ print(chunk.usage)
+ else:
+ delta = chunk.choices[0].delta
+ # 打印思考过程
+ if hasattr(delta, 'reasoning_content') and delta.reasoning_content != None:
+ print(delta.reasoning_content, end='', flush=True)
+ reasoning_content += delta.reasoning_content
+ else:
+ # 开始回复
+ if delta.content != "" and is_answering is False:
+ print("\n" + "=" * 20 + "完整回复" + "=" * 20 + "\n")
+ is_answering = True
+ # 打印回复过程
+ print(delta.content, end='', flush=True)
+ answer_content += delta.content
+
+# print("=" * 20 + "完整思考过程" + "=" * 20 + "\n")
+# print(reasoning_content)
+# print("=" * 20 + "完整回复" + "=" * 20 + "\n")
+# 保存成QvqResult.txt
+with open("QvqResult.txt", "w", encoding='utf-8') as f:
+ f.write(answer_content)
+print("试题解析文本保存成功!")
diff --git a/api/__pycache__/doubao_client.cpython-312.pyc b/api/__pycache__/doubao_client.cpython-312.pyc
new file mode 100644
index 0000000..c7b8b2e
Binary files /dev/null and b/api/__pycache__/doubao_client.cpython-312.pyc differ
diff --git a/api/doubao_client.py b/api/doubao_client.py
new file mode 100644
index 0000000..cdaf5c1
--- /dev/null
+++ b/api/doubao_client.py
@@ -0,0 +1,36 @@
+import os
+import logging
+from openai import OpenAI
+from typing import Optional, Dict, Any
+from dotenv import load_dotenv
+
+load_dotenv()
+
+
+class DoubaoClient():
+ def __init__(self, api_key: str = None):
+ self.api_key="f6150e6c-422a-4265-8b63-4d941b271220"
+ self.model="doubao-1.5-vision-pro-250328"
+ self.api_url="https://ark.cn-beijing.volces.com/api/v3"
+ self.client = OpenAI(
+ base_url=self.api_url,
+ api_key=self.api_key,
+ )
+ logging.info("DoubaoClient initialized.")
+
+ def chat_completion(self, messages: list, **kwargs) -> Optional[str]:
+ """Specific chat completion method for Doubao using OpenAI client."""
+ try:
+ response = self.client.chat.completions.create(
+ model=self.model,
+ messages=messages,
+ **kwargs
+ )
+ if response.choices and len(response.choices) > 0:
+ return response.choices[0].message.content
+ else:
+ logging.error("Failed to get content from Doubao API response.")
+ return None
+ except Exception as e:
+ logging.error(f"Doubao API call failed: {e}")
+ return None
\ No newline at end of file
diff --git a/audio.mp3 b/audio.mp3
new file mode 100644
index 0000000..18b2c7c
Binary files /dev/null and b/audio.mp3 differ
diff --git a/audio1.mp4 b/audio1.mp4
new file mode 100644
index 0000000..8d6cecf
Binary files /dev/null and b/audio1.mp4 differ
diff --git a/audio2.mp4 b/audio2.mp4
new file mode 100644
index 0000000..ec62adb
Binary files /dev/null and b/audio2.mp4 differ
diff --git a/bm.jpg b/bm.jpg
new file mode 100644
index 0000000..076bc41
Binary files /dev/null and b/bm.jpg differ
diff --git a/core/__pycache__/ocr_service.cpython-312.pyc b/core/__pycache__/ocr_service.cpython-312.pyc
new file mode 100644
index 0000000..82f4fac
Binary files /dev/null and b/core/__pycache__/ocr_service.cpython-312.pyc differ
diff --git a/core/ocr_service.py b/core/ocr_service.py
new file mode 100644
index 0000000..d1f5b47
--- /dev/null
+++ b/core/ocr_service.py
@@ -0,0 +1,68 @@
+import logging
+from api.doubao_client import DoubaoClient
+from utils.image_utils import encode_image # 更新导入语句以反映新位置
+
+prompt = """
+你是一个初中数学图片的描述专家,请将图片中的内容转换为文本。
+1、注意数学公式需要用latex格式输出。注意只输出文本内容,不要输出任何解释。
+2、如果图片中有图形,请结合题干内容对图形进行描述,只要描述不需要任何解释。
+3、如果图片中是坐标系,分析抛物线的开口方向和经过的象限,并详细描述。识别图片中的坐标系类型,如直角坐标系、极坐标系等。
+4、要以markdown格式输出
+输出格式为
+【题干】
+【图形描述】
+"""
+
+class OCRService:
+ def __init__(self, api_client: DoubaoClient):
+ """
+ 初始化OCRService
+
+ Args:
+ api_client: ApiClient的实例
+ """
+ self.api_client = api_client
+ logging.info("OCRService initialized.")
+
+ def get_ocr(self, problem: str) -> str:
+ """
+ 获得问题的ocr。
+
+ Args:
+ problem: 需要解答的问题图片。
+
+ Returns:
+ 问题的ocr结果。
+ """
+ # 将图片转换为base64编码
+ base64_image = encode_image(problem)
+
+ # 构建请求消息,包含图片
+ messages = [
+ {
+ 'role': 'user',
+ 'content': [
+ {
+ 'type': 'image_url',
+ 'image_url': {
+ 'url': f'data:image/jpeg;base64,{base64_image}'
+ }
+ },
+ {
+ 'type': 'text',
+ # 'text': '请将图片中的内容转换为文本。\n注意数学公式需要用latex格式输出。\n注意只输出文本内容,不要输出任何解释。'
+ 'text': prompt
+ }
+ ]
+ }
+ ]
+
+ logging.info(f"Calling API for ocr for problem: {problem[:50]}...") # Log first 50 chars
+ solution = self.api_client.chat_completion(messages, temperature=0.6, max_tokens=2048)
+
+ if solution is None:
+ logging.error("Failed to get ocr from API.")
+ return "ocr出现错误,请检查输入或稍后重试。"
+
+ logging.info("Successfully got ocr.")
+ return solution
\ No newline at end of file
diff --git a/img01.png b/img01.png
new file mode 100644
index 0000000..9d4065f
Binary files /dev/null and b/img01.png differ
diff --git a/img02.png b/img02.png
new file mode 100644
index 0000000..ebb5565
Binary files /dev/null and b/img02.png differ
diff --git a/img03.jpg b/img03.jpg
new file mode 100644
index 0000000..db6cf9f
Binary files /dev/null and b/img03.jpg differ
diff --git a/img04.jpg b/img04.jpg
new file mode 100644
index 0000000..95eb3dd
Binary files /dev/null and b/img04.jpg differ
diff --git a/img05.jpg b/img05.jpg
new file mode 100644
index 0000000..524834c
Binary files /dev/null and b/img05.jpg differ
diff --git a/img09.jpg b/img09.jpg
new file mode 100644
index 0000000..c6c096f
Binary files /dev/null and b/img09.jpg differ
diff --git a/output/bm.md b/output/bm.md
new file mode 100644
index 0000000..6f3d6d7
--- /dev/null
+++ b/output/bm.md
@@ -0,0 +1,46 @@
+

+
+
+义卖,筹集基
+
+考点名称
+
+班级考号考点分布考点编号1301长春市第五十三中学长春市第五十三中学
+
+112513091122报名序号董俊博姓名1130006071301长春市第五十三中学
+
+112513091125吴贺辰1130011211301长春市第五十三中学
+
+112513091127邱玛潼1130016171301长春市第五十三中学
+
+112513091105杨馨淇1130018101301长春市第五十三中学ng the May
+
+112513091106刘妍希1130019281301长春市第五十三中学
+
+111111112513091108251309114925130911382513091128徐紫乔李旭尧王梓丞张新春1130022081130027231130035141130038211130038131301130213021302长春市二道区东盛小学长春市二道区东盛小学长春市二道区东盛小学长春市二道区东盛小学
+
+111125130911092513091133宋予涵丁继卿11300461011300481013021302长春市二道区东盛小学长春市第一O八学校
+
+112513091116丁梓轩1130052301303长春市第一O八学校
+
+112513091134刘想1130055231303长春市第一O八学校
+
+112513091147张菲函1130055161303长春市第一O八学校
+
+112513091112丁梓涵1130061261303长春市第一O八学校
+
+111125130911182513091132郑重九张可硕11300610811300652213031303长春市第一O八学校长春市第一〇八学校
+
+112513091145张欣彤1130068211303长春五十二中赫行实验学校B栋
+
+1111111111111111111111111125130911012513091104251309114425130911142513091135251309115025130911112513091129251309112625130911462513091123251309113925130911402513091103白沅程武诗霖葛睿琪李子淇王艺燃吴泓锐王睿瞳谢傲宣魏汐羽冯柳涵吕牧瑾郭星佐韩语轩刘毅11300802811300821511300841211300862111300891411300912511300940111300950611300950311300961111300991611301001411301050313041304130413041304130413041305130513051305130513051305长春五十二中赫行实验学校小学部长春五十二中赫行实验学校小学部长春五十二中赫行实验学校B栋长春五十二中赫行实验学校B栋长春五十二中赫行实验学校小学部长春五十二中赫行实验学校B栋长春五十二中赫行实验学校小学部长春五十二中赫行实验学校小学部长春五十二中赫行实验学校小学部长春五十二中赫行实验学校B栋长春五十二中赫行实验学校B栋长春五十二中赫行实验学校B栋长春五十二中赫行实验学校小学部
+
+112513091137朴雨涵1130106111305长春五十二中赫行实验学校小学部
+
+112513091120王钰涵1130106061305长春五十二中赫行实验学校小学部
+
+11111111111111111111111111111111112513091141251309113025130911212513091119251309111525130911482513091124251309111025130911362513091142251309113125130911072513091117251309114325130911132513091102李毕果儿曹茜然张悦祖徐圣然王彦博闫佳琦何欣寰赵威晓李梓暄张谕浩赵子涵张贺然曹祎朔王艺冰董宇鑫宋歌113011301113011428113012721113012824113013020113013019113013807113014324113014402113014624113015305113015129113015908113016028113016415113016516130513051305130513051306130613061306130613061306130613061306长春五十二中赫行实验学校小学部长春五十二中赫行实验学校小学部长春五十二中赫行实验学校小学部长春五十二中赫行实验学校小学部长春五十二中赫行实验学校小学部长春市第五十二中学长春市第五十二中学长春市第五十二中学长春市第五十二中学长春市第五十二中学长春市第五十二中学长春市第五十二中学长春市第五十二中学长春市第五十二中学长春市第五十二中学
+
+
+
+
diff --git a/output/general_ocr_002_ocr_res_img.png b/output/general_ocr_002_ocr_res_img.png
new file mode 100644
index 0000000..324d915
Binary files /dev/null and b/output/general_ocr_002_ocr_res_img.png differ
diff --git a/output/general_ocr_002_preprocessed_img.png b/output/general_ocr_002_preprocessed_img.png
new file mode 100644
index 0000000..4022251
Binary files /dev/null and b/output/general_ocr_002_preprocessed_img.png differ
diff --git a/output/general_ocr_002_res.json b/output/general_ocr_002_res.json
new file mode 100644
index 0000000..33e85b8
--- /dev/null
+++ b/output/general_ocr_002_res.json
@@ -0,0 +1,1524 @@
+{
+ "input_path": "C:/Users/Administrator/.paddlex/predict_input/general_ocr_002.png",
+ "page_index": null,
+ "model_settings": {
+ "use_doc_preprocessor": true,
+ "use_textline_orientation": false
+ },
+ "doc_preprocessor_res": {
+ "input_path": null,
+ "page_index": null,
+ "model_settings": {
+ "use_doc_orientation_classify": false,
+ "use_doc_unwarping": false
+ },
+ "angle": -1
+ },
+ "dt_polys": [
+ [
+ [
+ 152,
+ 22
+ ],
+ [
+ 357,
+ 16
+ ],
+ [
+ 358,
+ 71
+ ],
+ [
+ 153,
+ 77
+ ]
+ ],
+ [
+ [
+ 419,
+ 20
+ ],
+ [
+ 659,
+ 14
+ ],
+ [
+ 660,
+ 61
+ ],
+ [
+ 420,
+ 66
+ ]
+ ],
+ [
+ [
+ 702,
+ 14
+ ],
+ [
+ 822,
+ 11
+ ],
+ [
+ 823,
+ 56
+ ],
+ [
+ 703,
+ 59
+ ]
+ ],
+ [
+ [
+ 212,
+ 105
+ ],
+ [
+ 317,
+ 102
+ ],
+ [
+ 318,
+ 128
+ ],
+ [
+ 213,
+ 131
+ ]
+ ],
+ [
+ [
+ 339,
+ 102
+ ],
+ [
+ 386,
+ 102
+ ],
+ [
+ 386,
+ 129
+ ],
+ [
+ 339,
+ 129
+ ]
+ ],
+ [
+ [
+ 398,
+ 103
+ ],
+ [
+ 456,
+ 101
+ ],
+ [
+ 457,
+ 123
+ ],
+ [
+ 399,
+ 126
+ ]
+ ],
+ [
+ [
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 101,
+ 311
+ ],
+ [
+ 209,
+ 307
+ ],
+ [
+ 210,
+ 336
+ ],
+ [
+ 102,
+ 340
+ ]
+ ],
+ [
+ [
+ 68,
+ 342
+ ],
+ [
+ 165,
+ 337
+ ],
+ [
+ 166,
+ 363
+ ],
+ [
+ 69,
+ 367
+ ]
+ ],
+ [
+ [
+ 344,
+ 347
+ ],
+ [
+ 662,
+ 343
+ ],
+ [
+ 662,
+ 367
+ ],
+ [
+ 344,
+ 370
+ ]
+ ],
+ [
+ [
+ 99,
+ 455
+ ],
+ [
+ 832,
+ 439
+ ],
+ [
+ 832,
+ 464
+ ],
+ [
+ 99,
+ 480
+ ]
+ ]
+ ],
+ "text_det_params": {
+ "limit_side_len": 64,
+ "limit_type": "min",
+ "thresh": 0.3,
+ "max_side_limit": 4000,
+ "box_thresh": 0.6,
+ "unclip_ratio": 1.5
+ },
+ "text_type": "general",
+ "textline_orientation_angles": [
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1
+ ],
+ "text_rec_score_thresh": 0.0,
+ "rec_texts": [
+ "登机牌",
+ "BOARDING",
+ "PASS",
+ "日期DATE",
+ "舱位",
+ "CLASS",
+ "序号",
+ "SERIALNO.",
+ "座位号",
+ "SEAT NO.",
+ "航班FLIGHT",
+ "MU 2379 03DEC",
+ "W",
+ "035",
+ "始发地",
+ "FROM",
+ "登机口",
+ "GATE",
+ "登机时间",
+ "BDT",
+ "目的地TO",
+ "福州",
+ "TAIYUAN",
+ "G11",
+ "FUZHOU",
+ "身份识别IDNO.",
+ "姓名NAME",
+ "ZHANGQIWEI",
+ "票号TKTNO.",
+ "张祺伟",
+ "票价FARE",
+ "ETKT7813699238489/1",
+ "登机口于起飞前1O分钟关闭GATESCLOSE1OMINUTESBEFORE DEPARTURETIME"
+ ],
+ "rec_scores": [
+ 0.997112512588501,
+ 0.9802998304367065,
+ 0.9757187366485596,
+ 0.998284101486206,
+ 0.9992738366127014,
+ 0.9847012758255005,
+ 0.9991599321365356,
+ 0.984332799911499,
+ 0.9987489581108093,
+ 0.9555855989456177,
+ 0.9915244579315186,
+ 0.9323411583900452,
+ 0.7954522371292114,
+ 0.9984045028686523,
+ 0.998708963394165,
+ 0.9900082349777222,
+ 0.9853600859642029,
+ 0.9967124462127686,
+ 0.9984562397003174,
+ 0.9965361952781677,
+ 0.9474632143974304,
+ 0.9983562231063843,
+ 0.9896405935287476,
+ 0.997016429901123,
+ 0.9870738983154297,
+ 0.9862650632858276,
+ 0.9981915354728699,
+ 0.9889874458312988,
+ 0.9749695658683777,
+ 0.9971926212310791,
+ 0.997547447681427,
+ 0.9928194284439087,
+ 0.973278284072876
+ ],
+ "rec_polys": [
+ [
+ [
+ 152,
+ 22
+ ],
+ [
+ 357,
+ 16
+ ],
+ [
+ 358,
+ 71
+ ],
+ [
+ 153,
+ 77
+ ]
+ ],
+ [
+ [
+ 419,
+ 20
+ ],
+ [
+ 659,
+ 14
+ ],
+ [
+ 660,
+ 61
+ ],
+ [
+ 420,
+ 66
+ ]
+ ],
+ [
+ [
+ 702,
+ 14
+ ],
+ [
+ 822,
+ 11
+ ],
+ [
+ 823,
+ 56
+ ],
+ [
+ 703,
+ 59
+ ]
+ ],
+ [
+ [
+ 212,
+ 105
+ ],
+ [
+ 317,
+ 102
+ ],
+ [
+ 318,
+ 128
+ ],
+ [
+ 213,
+ 131
+ ]
+ ],
+ [
+ [
+ 339,
+ 102
+ ],
+ [
+ 386,
+ 102
+ ],
+ [
+ 386,
+ 129
+ ],
+ [
+ 339,
+ 129
+ ]
+ ],
+ [
+ [
+ 398,
+ 103
+ ],
+ [
+ 456,
+ 101
+ ],
+ [
+ 457,
+ 123
+ ],
+ [
+ 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
+ ],
+ [
+ 64,
+ 174,
+ 170,
+ 205
+ ],
+ [
+ 96,
+ 203,
+ 171,
+ 231
+ ],
+ [
+ 335,
+ 212,
+ 476,
+ 242
+ ],
+ [
+ 507,
+ 212,
+ 554,
+ 236
+ ],
+ [
+ 87,
+ 224,
+ 204,
+ 253
+ ],
+ [
+ 344,
+ 234,
+ 485,
+ 259
+ ],
+ [
+ 64,
+ 245,
+ 174,
+ 274
+ ],
+ [
+ 75,
+ 271,
+ 265,
+ 300
+ ],
+ [
+ 460,
+ 292,
+ 581,
+ 319
+ ],
+ [
+ 101,
+ 307,
+ 210,
+ 340
+ ],
+ [
+ 68,
+ 337,
+ 166,
+ 367
+ ],
+ [
+ 344,
+ 343,
+ 662,
+ 370
+ ],
+ [
+ 99,
+ 439,
+ 832,
+ 480
+ ]
+ ]
+}
\ No newline at end of file
diff --git a/output/img03.md b/output/img03.md
new file mode 100644
index 0000000..f9c23f0
--- /dev/null
+++ b/output/img03.md
@@ -0,0 +1,45 @@
+# 一、单选题:本题共8小题,每小题5分,共40分,每小题只有一个选项符合要求 1.样本数据2.8,14,16.20的平均数为
+
+( )
+
+A.8B.9C.12D.18
+
+2已知$z=1+i$ ,则$\frac{1}{z-1}=$
+
+( )
+
+A.-i B.i C.-1D.1
+
+3.已知集合$A=\{-4,0,1,2,8\}$ 上,$B=\left\{x\mid x^{3}=x\right\}$ ,则$A\cap B=$
+
+( )
+
+A.{0.1.2}B.{1,2.8}C.{2.8}D.{0.1}
+
+4.不等式$\frac{x-4}{x-1}\geq2$ 的解集是
+
+( )
+
+A.$\left\{x\mid-2\leqslant x\leqslant1\right\}$ B.$\{x|x\leqslant-2\}$ C.$\left\{x\mid-2\leqslant x<1\right\}$ D.$\{x\mid x>1\}$
+
+5.在△ABC中,$BC=2,AC=1+\sqrt{3},AB=\sqrt{6}$ ,则$A=$
+
+( )
+
+A.$45^{\circ}$ B.$60^{\circ}$ C.$120^{\circ}$ D.$135^{\circ}$
+
+6.设抛物线$C:y^{2}=2px(P>0)$ 的焦点为F,点A在C上,过A作C准线的垂线,垂足为B.若直线BF的方程为$y=-2x+2$ ,则$|AF|=$ ( )
+
+A.3B.4C.5D. 6
+
+7记$S_{n}$ 为等差数列$\{a_{n}\}$ 的前n项和,若$S_{3}=6.S_{5}=-5$ ,则$S_{6}=$
+
+( )
+
+A.$-20$ B.-15C.-10D.-5
+
+8.已知$0<\alpha<\pi,\cos\frac{\alpha}{2}=\frac{\sqrt{5}}{5}$ ,则$\sin(a-\frac{\pi}{4})=$
+
+( )
+
+A.$\frac{\sqrt{2}}{10}$ B.$\frac{\sqrt{2}}{5}$ C.$\frac{3\sqrt{2}}{10}$ D.$\frac{7\sqrt{2}}{10}$
\ No newline at end of file
diff --git a/output/imgs/img_in_image_box_0_0_1079_507.jpg b/output/imgs/img_in_image_box_0_0_1079_507.jpg
new file mode 100644
index 0000000..c85f3a6
Binary files /dev/null and b/output/imgs/img_in_image_box_0_0_1079_507.jpg differ
diff --git a/output/imgs/img_in_image_box_0_1913_1079_2396.jpg b/output/imgs/img_in_image_box_0_1913_1079_2396.jpg
new file mode 100644
index 0000000..e9dac72
Binary files /dev/null and b/output/imgs/img_in_image_box_0_1913_1079_2396.jpg differ
diff --git a/test.py b/test.py
new file mode 100644
index 0000000..9dca373
--- /dev/null
+++ b/test.py
@@ -0,0 +1,5 @@
+import uuid
+
+# 生成一个随机的UUID
+guid = uuid.uuid4()
+print(guid)
\ No newline at end of file
diff --git a/test001.py b/test001.py
new file mode 100644
index 0000000..563adcf
--- /dev/null
+++ b/test001.py
@@ -0,0 +1,14 @@
+from paddleocr import PaddleOCR
+# 初始化 PaddleOCR 实例
+ocr = PaddleOCR(
+ use_doc_orientation_classify=False,
+ use_doc_unwarping=False,
+ use_textline_orientation=False)
+# 对示例图像执行 OCR 推理
+result = ocr.predict(
+ input="https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_002.png")
+# 可视化结果并保存 json 结果
+for res in result:
+ res.print()
+ res.save_to_img("output")
+ res.save_to_json("output")
\ No newline at end of file
diff --git a/test002.py b/test002.py
new file mode 100644
index 0000000..06ae56e
--- /dev/null
+++ b/test002.py
@@ -0,0 +1,16 @@
+from paddleocr import PPStructureV3
+
+pipeline = PPStructureV3(
+ use_doc_orientation_classify=False,
+ # use_table_recognition=True,
+ use_doc_unwarping=False
+)
+
+# For Image
+output = pipeline.predict(
+ input="./bm.jpg",
+ )
+
+# 可视化结果并保存 json 结果
+for res in output:
+ res.save_to_markdown(save_path="output")
\ No newline at end of file
diff --git a/test003.py b/test003.py
new file mode 100644
index 0000000..25cad6b
--- /dev/null
+++ b/test003.py
@@ -0,0 +1,19 @@
+import whisper
+
+model = whisper.load_model("turbo", device="cuda")
+result = model.transcribe("audio2.mp4", word_timestamps=False, initial_prompt="这是小学四年级习作问题诊断及指导的视频。", verbose=False, language='zh')
+
+# result = model.transcribe("audio.mp3", word_timestamps=False, initial_prompt="这是一段小说。", verbose=False, language='zh')
+
+
+def seconds_to_min_sec(total_seconds: int) -> str:
+ minutes, seconds = divmod(total_seconds, 60)
+ return f"{minutes}分{seconds:02d}秒"
+
+
+for item in result['segments']:
+ print('时间:' + str(seconds_to_min_sec(int(item['start']))) + ' ~ ' + str(
+ seconds_to_min_sec(int(item['end']))) + ';' + '文本:' + str(
+ item['text']))
+
+print('所有文本内容:' + result['text'])
diff --git a/test004.py b/test004.py
new file mode 100644
index 0000000..b69a997
--- /dev/null
+++ b/test004.py
@@ -0,0 +1,20 @@
+from faster_whisper import WhisperModel
+
+model_size = "turbo"
+
+# Run on GPU with FP16
+model = WhisperModel(model_size, device="cuda", compute_type="float16")
+
+# or run on GPU with INT8
+# model = WhisperModel(model_size, device="cuda", compute_type="int8_float16")
+# or run on CPU with INT8
+# model = WhisperModel(model_size, device="cpu", compute_type="int8")
+
+segments, info = model.transcribe("audio.mp3", beam_size=5, language="zh", initial_prompt="这是一段小说。")
+
+print(info)
+
+print("Detected language '%s' with probability %f" % (info.language, info.language_probability))
+
+for segment in segments:
+ print("[%.2fs -> %.2fs] %s" % (segment.start, segment.end, segment.text))
diff --git a/test005.py b/test005.py
new file mode 100644
index 0000000..ab24c3b
--- /dev/null
+++ b/test005.py
@@ -0,0 +1,82 @@
+import whisper
+import math
+from pydub import AudioSegment # pip install pydub
+
+# --------- 参数 ----------
+MODEL_NAME = "turbo"
+DEVICE = "cuda"
+AUDIO_PATH = "audio.mp3"
+SEGMENT_SEC = 10 # 每段 10 秒,越小粒度越细
+OVERLAP_SEC = 0
+LANGUAGE = "zh"
+INITIAL_PROMPT = "这是一段小说。"
+# -------------------------
+
+# 1. 把音频切成小段
+audio = AudioSegment.from_file(AUDIO_PATH)
+total_ms = len(audio) # 总时长(毫秒)
+segment_ms = SEGMENT_SEC * 1000
+step_ms = (SEGMENT_SEC - OVERLAP_SEC) * 1000
+
+segments = [
+ audio[i:i + segment_ms] # pydub 切片
+ for i in range(0, total_ms, step_ms)
+]
+
+total_chunks = len(segments)
+print(f"音频共 {total_ms / 1000:.1f} 秒,切成 {total_chunks} 段处理")
+
+# 2. 加载模型
+model = whisper.load_model(MODEL_NAME, device=DEVICE)
+
+# 3. 逐段转录 + 打印进度
+all_segments = []
+
+
+def percentage_of(total: int, part: int) -> int:
+ if total <= 0:
+ raise ValueError("第一个参数(总数)必须大于 0")
+ if part >= total:
+ return 100
+ return int(round((part / total) * 100))
+
+
+for idx, seg in enumerate(segments, 1):
+ # 临时保存为 wav,让 Whisper 读取
+ tmp_wav = f"_tmp_{idx}.wav"
+ seg.export(tmp_wav, format="wav")
+
+ result = model.transcribe(
+ tmp_wav,
+ language=LANGUAGE,
+ initial_prompt=INITIAL_PROMPT,
+ verbose=False,
+ word_timestamps=False
+ )
+ all_segments.append(result)
+
+ # 计算并打印进度
+ progress = idx / total_chunks * 100
+ print(str(percentage_of(total_chunks, idx)) + "%")
+
+ # 删除临时文件
+ import os;
+
+ os.remove(tmp_wav)
+
+print("\n转录完成!")
+
+
+# 4. 合并结果,按时间轴输出
+def seconds_to_min_sec(total_seconds: int) -> str:
+ minutes, seconds = divmod(total_seconds, 60)
+ return f"{minutes}分{seconds:02d}秒"
+
+
+current_start = 0
+for chunk_result in all_segments:
+ for seg in chunk_result["segments"]:
+ start = current_start + seg["start"]
+ end = current_start + seg["end"]
+ print(f"时间:{seconds_to_min_sec(int(start))} ~ {seconds_to_min_sec(int(end))};文本:{seg['text'].strip()}")
+ current_start += SEGMENT_SEC - OVERLAP_SEC
diff --git a/test006.py b/test006.py
new file mode 100644
index 0000000..d534d68
--- /dev/null
+++ b/test006.py
@@ -0,0 +1,27 @@
+import os
+from openai import OpenAI
+
+client = OpenAI(
+ # 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx",
+ api_key="sk-01d13a39e09844038322108ecdbd1bbc",
+ base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
+)
+
+system_content="""
+要求:使用可以让小学一年级的学生能懂的方式方法去解答
+"""
+
+user_content = """
+鸡和兔在一个笼子里,从上面数,有8个头,从下面数,有26只脚。问鸡和兔各有几只?
+要求:使用大学生层次的方法去解答
+"""
+completion = client.chat.completions.create(
+ model="qwen2.5-math-72b-instruct",
+ # 此处以qwen-vl-plus为例,可按需更换模型名称。模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
+ messages=[
+ # {"role": "system", "content": system_content},
+ {"role": "user",
+ "content": user_content}
+ ]
+)
+print(completion.model_dump_json())
diff --git a/test007.py b/test007.py
new file mode 100644
index 0000000..ba3684e
--- /dev/null
+++ b/test007.py
@@ -0,0 +1,82 @@
+import os
+from openai import OpenAI
+import json
+
+client = OpenAI(
+ # 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx",
+ api_key="sk-01d13a39e09844038322108ecdbd1bbc",
+ base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
+)
+
+system_content="""# Role: 思维导图解析专家
+
+## Profile
+- language: 中文
+- description: 思维导图解析专家是一个专业的角色,专门负责分析、解读和优化思维导图,帮助用户更有效地理解和利用思维导图进行思考、学习和工作。
+- background: 拥有多年思维导图使用和研究的经验,对各种思维导图软件和技巧有深入的了解。
+- personality: 分析能力强,善于发现问题和提出解决方案,具有良好的沟通能力和团队协作精神。
+- expertise: 思维导图分析、解读和优化
+- target_audience: 需要使用思维导图进行学习、工作和管理的人群
+
+## Skills
+
+1. 思维导图分析
+ - 结构分析: 能够分析思维导图的结构,识别其主要组成部分和逻辑关系。
+ - 内容分析: 能够深入解读思维导图的内容,提取关键信息和要点。
+ - 模式识别: 能够识别思维导图中的模式和趋势,帮助用户更好地理解信息。
+
+2. 思维导图解读
+ - 意图解读: 能够解读思维导图的设计意图,帮助用户理解其背后的思考和逻辑。
+ - 关系解读: 能够解读思维导图中的各种关系,如因果关系、层次关系等。
+ - 概念解读: 能够解读思维导图中的各种概念,帮助用户更好地理解其含义和作用。
+
+3. 思维导图优化
+ - 逻辑优化: 能够优化思维导图的结构和逻辑,使其更加清晰和合理。
+ - 内容优化: 能够优化思维导图的内容,去除冗余信息,突出关键要点。
+ - 视觉优化: 能够优化思维导图的外观,使其更加美观和易读。
+
+## Rules
+
+1. 基本原则:
+ - 客观分析: 在分析思维导图时,必须保持客观和公正的态度,避免主观偏见。
+ - 全面解读: 在解读思维导图时,必须全面考虑其各个方面,避免遗漏重要信息。
+ - 有效优化: 在优化思维导图时,必须确保优化措施的有效性,避免无效或负面影响。
+
+2. 行为准则:
+ - 保密原则: 必须对用户的思维导图内容保密,不得泄露给任何第三方。
+ - 诚实原则: 必须诚实地反馈思维导图的分析结果,不得故意隐瞒或歪曲信息。
+ - 协作原则: 必须与用户保持良好的沟通和协作,共同完成思维导图的优化工作。
+
+3. 限制条件:
+ - 法律法规: 必须遵守相关的法律法规,不得进行任何违法或违规行为。
+ - 道德规范: 必须遵守职业道德规范,不得进行任何不道德或有害的行为。
+ - 用户隐私: 必须尊重用户的隐私,不得随意获取或泄露用户的个人信息。
+ - 不要思维导图内容中未提供的信息,不要随意发挥。
+
+## Workflows
+
+- 目标: 帮助用户更好地理解和利用思维导图进行思考、学习和工作。
+- 步骤 1: 收集和审查思维导图: 收集用户提供的思维导图,并进行初步的审查,了解其内容和结构。
+- 步骤 2: 分析和解读思维导图: 对思维导图进行深入的分析和解读,识别其主要组成部分、逻辑关系和潜在问题。
+- 步骤 3: 提出优化建议: 根据分析和解读的结果,提出具体的优化建议,包括结构优化、内容优化和视觉优化等方面。
+- 步骤 4: 实施优化措施: 与用户合作,实施优化措施,并对优化后的思维导图进行评估和反馈。
+- 预期结果: 用户能够更好地理解和利用思维导图,提高思考、学习和工作的效率。
+
+## Initialization
+作为思维导图解析专家,你必须遵守上述Rules,按照Workflows执行任务。"""
+
+
+completion = client.chat.completions.create(
+ model="qwen-vl-plus",
+ messages=[
+ {"role": "system", "content": "只要思维导图内容,不得添加任何未提供的信息,不得随意发挥或进行主观解读、解析。"},
+ {"role": "user", "content": [
+ {"type": "image_url",
+ "image_url": {"url": "https://dsideal.obs.cn-north-1.myhuaweicloud.com/wb/img05.jpg"}},
+ {"type": "text", "text": "图片内容是一个知识导图,帮我解析出来并且要保留关系。"},
+ ]}]
+)
+
+jsonObj = json.loads(completion.model_dump_json())
+
+print(jsonObj['choices'][0]['message']['content'])
diff --git a/test008.py b/test008.py
new file mode 100644
index 0000000..0760aaf
--- /dev/null
+++ b/test008.py
@@ -0,0 +1,28 @@
+import uuid
+from obs import ObsClient
+import os
+import traceback
+
+ak = "HZDE30KAN5C5OLJ9JCCF"
+sk = "3QO1IJNRrFZyER1e1NBBu4qSyqDfZ8Xup0YPzDFW"
+
+server = "https://obs.cn-north-1.myhuaweicloud.com"
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+ bucketName = "dsideal"
+ # 对象名,即上传后的文件名
+ objectKey = str(uuid.uuid4()) + ".jpg"
+ # 待上传文件的完整路径,如aa/bb.txt
+ file_path = "./img04.jpg"
+ # 文件上传
+ resp = obsClient.putFile(bucketName, objectKey, file_path)
+
+ # 返回码为2xx时,接口调用成功,否则接口调用失败
+ if resp.status < 300:
+ print('Put File Succeeded')
+ print('文件地址:', resp.body.objectUrl)
+ else:
+ print('Put File Failed')
+except:
+ print('Put File Failed')
+ print(traceback.format_exc())
diff --git a/test009.py b/test009.py
new file mode 100644
index 0000000..f379838
--- /dev/null
+++ b/test009.py
@@ -0,0 +1,36 @@
+import uuid
+import json
+from obs import ObsClient
+import traceback
+
+from openai import OpenAI
+
+ak = "HZDE30KAN5C5OLJ9JCCF"
+sk = "3QO1IJNRrFZyER1e1NBBu4qSyqDfZ8Xup0YPzDFW"
+
+client = OpenAI(
+ # 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx",
+ api_key="sk-01d13a39e09844038322108ecdbd1bbc",
+ base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
+)
+
+server = "https://obs.cn-north-1.myhuaweicloud.com"
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+ bucketName = "dsideal"
+ # 对象名,即上传后的文件名
+ objectKey = str(uuid.uuid4()) + ".jpg"
+ # 待上传文件的完整路径,如aa/bb.txt
+ file_path = "./img04.jpg"
+ # 文件上传
+ resp = obsClient.putFile(bucketName, objectKey, file_path)
+
+ # 返回码为2xx时,接口调用成功,否则接口调用失败
+ if resp.status < 300:
+ print('Put File Succeeded')
+ print('文件地址:', resp.body.objectUrl)
+ else:
+ print('Put File Failed')
+except:
+ print('Put File Failed')
+ print(traceback.format_exc())
diff --git a/test010.py b/test010.py
new file mode 100644
index 0000000..ba70492
--- /dev/null
+++ b/test010.py
@@ -0,0 +1,64 @@
+from openai import OpenAI
+import os
+
+# 初始化OpenAI客户端
+client = OpenAI(
+ # 如果没有配置环境变量,请用百炼API Key替换:api_key="sk-xxx"
+ api_key = "sk-01d13a39e09844038322108ecdbd1bbc",
+ base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
+)
+
+reasoning_content = "" # 定义完整思考过程
+answer_content = "" # 定义完整回复
+is_answering = False # 判断是否结束思考过程并开始回复
+
+# 创建聊天完成请求
+completion = client.chat.completions.create(
+ model="qvq-max", # 此处以 qvq-max 为例,可按需更换模型名称
+ messages=[
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "image_url",
+ "image_url": {
+ "url": "https://dsideal.obs.cn-north-1.myhuaweicloud.com/wb/math.jpg"
+ },
+ },
+ {"type": "text", "text": "这道题怎么解答?注意:这道题是初中中考题,使用初中生的层次进行解答。"},
+ ],
+ },
+ ],
+ stream=True,
+ # 解除以下注释会在最后一个chunk返回Token使用量
+ # stream_options={
+ # "include_usage": True
+ # }
+)
+
+print("\n" + "=" * 20 + "思考过程" + "=" * 20 + "\n")
+
+for chunk in completion:
+ # 如果chunk.choices为空,则打印usage
+ if not chunk.choices:
+ print("\nUsage:")
+ print(chunk.usage)
+ else:
+ delta = chunk.choices[0].delta
+ # 打印思考过程
+ if hasattr(delta, 'reasoning_content') and delta.reasoning_content != None:
+ print(delta.reasoning_content, end='', flush=True)
+ reasoning_content += delta.reasoning_content
+ else:
+ # 开始回复
+ if delta.content != "" and is_answering is False:
+ print("\n" + "=" * 20 + "完整回复" + "=" * 20 + "\n")
+ is_answering = True
+ # 打印回复过程
+ print(delta.content, end='', flush=True)
+ answer_content += delta.content
+
+# print("=" * 20 + "完整思考过程" + "=" * 20 + "\n")
+# print(reasoning_content)
+# print("=" * 20 + "完整回复" + "=" * 20 + "\n")
+# print(answer_content)
\ No newline at end of file
diff --git a/test11.py b/test11.py
new file mode 100644
index 0000000..2b23334
--- /dev/null
+++ b/test11.py
@@ -0,0 +1,145 @@
+from zhipuai import ZhipuAI
+client = ZhipuAI(api_key="78dc1dfe37e04f29bd4ca9a49858a969.gn7TIZTfzpY35nx9") # 填写您自己的APIKey
+
+reasoning_content = "" # 定义完整思考过程
+answer_content = "" # 定义完整回复
+is_answering = False # 判断是否结束思考过程并开始回复
+
+prompt = """
+# Role: 数学可视化描述专家
+
+## Profile
+- language: 中文
+- description: 专注于初中几何图形的结构化解析,具备扎实的几何理论知识和严谨的逻辑分析能力,能够清晰、准确地描述图形的各个元素及其关系。
+- background: 拥有数学教育背景,多年从事初中几何教学与研究,熟悉各类几何定理和判定方法。
+- personality: 严谨、细致、耐心,善于逻辑推理和空间想象。
+- expertise: 几何图形解析、几何定理应用、几何关系验证。
+- target_audience: 初中数学学生、教师及几何学习爱好者。
+
+## Skills
+
+1. 几何图形解析
+ - 图形分类: 能够准确识别并分类各类几何图形。
+ - 特征描述: 详细描述图形的具体特征,包括边长、角度、对称性等。
+ - 关系分析: 分析图形内部及图形之间的关系,如全等、相似、位置关系等。
+
+2. 几何定理应用
+ - 定理选择: 根据题目条件选择合适的几何定理进行解析。
+ - 推理验证: 通过定理进行逻辑推理,验证图形的隐含特征。
+ - 结论得出: 基于推理结果,得出准确的几何结论。
+
+## Rules
+
+1. 基本原则:
+ - 准确性: 所有描述和解析必须基于准确的数据和定理。
+ - 完整性: 不遗漏任何关键几何信息,确保解析的全面性。
+ - 逻辑性: 解析过程需逻辑清晰,步骤明确。
+
+2. 行为准则:
+ - 客观性: 描述必须客观,不包含主观臆断。
+ - 严谨性: 解析过程需严谨,每一步都有据可依。
+ - 清晰性: 语言表达清晰,易于理解。
+
+3. 限制条件:
+ - 不接受模糊条件: 题目条件必须明确,不接受模糊或不确定的条件。
+ - 不推导未知定理: 仅基于已知定理进行解析,不推导新的定理。
+ - 不使用复杂符号: 使用初中生能够理解的符号和术语。
+
+## 1. 主体元素清单(按包含关系排序)
+- [主要图形类型]:[具体特征描述](如:直角等腰三角形ABC,∠C=90°,AC=BC)
+- [次要图形类型]:[具体特征描述](位于[父图形名称]的[位置描述])
+(注:所有几何类型判断需满足:①题目明确给出的直接特征 ②可通过SSS/SAS/ASA等定理严格推导的隐含特征)
+
+## 2. 基准边选择优先级
+- 从左向右,从下向上,第一个看到的点做为坐标原点,此点向右水平的边视为X轴。
+
+## 3. 坐标验证机制
+必须包含以下校验步骤:
+1. 计算所有边的长度(使用两点间距离公式:√[(x2-x1)²+(y2-y1)²])
+2. 输出边长比较表:[边标识]:[长度数值](如:AB:5, AC:4, BC:3)
+3. 明确说明基准边选择依据:"选择AB边作为基准,因其长度5为最长(AC=4, BC=3)"
+
+## 4. 特殊图形处理
+- 直角三角形:强制校验斜边是否为最长边(c²=a²+b²)
+- 等腰/等边三角形:标注对称轴与基准边关系
+
+## 5. 辅助元素详细说明
+- [元素类型]:[数量]个,分别为[具体标识],作用是[几何功能描述]
+- 特殊点:[点标识]([几何意义],如:△ABC的重心/外心/垂足)
+- 连接线:[线段标识](连接[起点]与[终点],是否为中线/垂线/角平分线)
+
+## 6. 关键几何关系验证
+- 全等关系:△[标识] ≌ △[标识](依据[判定定理])
+- 相似关系:△[标识] ~ △[标识](相似比为[数值])
+- 位置约束:[图形A]在[图形B]的[方位描述],相距[距离描述]
+
+## Workflows
+
+- 目标: 对初中几何图形进行结构化解析,输出详细的解析报告。
+- 步骤 1: 识别并分类图形,列出主体元素清单。
+- 步骤 2: 选择基准边,进行坐标验证,计算并验证边长。
+- 步骤 3: 处理特殊图形,如直角三角形、等腰/等边三角形。
+- 步骤 4: 描述辅助元素,如特殊点、连接线的类型和作用。
+- 步骤 5: 验证关键几何关系,如全等、相似、位置约束。
+- 预期结果: 输出一份详细的几何图形解析报告,包含所有关键信息。
+
+## Initialization
+作为数学可视化描述专家,你必须遵守上述Rules,按照Workflows执行任务。
+"""
+
+
+
+
+completion = client.chat.completions.create(
+ model="glm-4.1v-thinking-flash", # 填写需要调用的模型名称
+ messages=[
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": prompt
+ },
+ {
+ "type": "image_url",
+ "image_url": {
+ "url" : "https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/Backup/23.jpg"
+ }
+ }
+ ]
+ }
+ ],
+ stream=True,
+)
+
+print("\n" + "=" * 20 + "思考过程" + "=" * 20 + "\n")
+
+for chunk in completion:
+ # 如果chunk.choices为空,则打印usage
+ if not chunk.choices:
+ print("\nUsage:")
+ print(chunk.usage)
+ else:
+ delta = chunk.choices[0].delta
+ # 打印思考过程
+ if hasattr(delta, 'reasoning_content') and delta.reasoning_content != None:
+ print(delta.reasoning_content, end='', flush=True)
+ reasoning_content += delta.reasoning_content
+ else:
+ # 开始回复
+ if delta.content != "" and is_answering is False:
+ print("\n" + "=" * 20 + "完整回复" + "=" * 20 + "\n")
+ is_answering = True
+ # 打印回复过程
+ print(delta.content, end='', flush=True)
+ answer_content += delta.content
+
+# print("=" * 20 + "完整思考过程" + "=" * 20 + "\n")
+# print(reasoning_content)
+# print("=" * 20 + "完整回复" + "=" * 20 + "\n")
+# 保存成QvqResult.txt
+with open("QvqResult.txt", "w", encoding='utf-8') as f:
+ f.write(answer_content)
+print("试题解析文本保存成功!")
+
+# print(response.choices[0].message)
\ No newline at end of file
diff --git a/test12.py b/test12.py
new file mode 100644
index 0000000..a6ab38c
--- /dev/null
+++ b/test12.py
@@ -0,0 +1,143 @@
+import json
+
+import requests
+
+reasoning_content = "" # 定义完整思考过程
+answer_content = "" # 定义完整回复
+is_answering = False # 判断是否结束思考过程并开始回复
+
+"""
+【1】GLM会有错误的信息输出,比如说:
+等腰直角三角形△DEF(由线段DE绕点E顺时针旋转45°得到线段EF后形成的三角形,满足DE=EF且夹角∠DEF=45°,是旋转生成的辅助主体小三角形)。
+这很明显是错误的,因为顶角是 45°的等边三角形不是等腰直角三角形!
+
+【2】响应速度
+对于阿里QVQ秒回的响应速度,此模型响应的速度在10秒以上。
+"""
+
+prompt = """
+# Role: 数学可视化描述专家
+
+## Profile
+- language: 中文
+- description: 专注于初中几何图形的结构化解析,具备扎实的几何理论知识和严谨的逻辑分析能力,能够清晰、准确地描述图形的各个元素及其关系。
+- background: 拥有数学教育背景,多年从事初中几何教学与研究,熟悉各类几何定理和判定方法。
+- personality: 严谨、细致、耐心,善于逻辑推理和空间想象。
+- expertise: 几何图形解析、几何定理应用、几何关系验证。
+- target_audience: 初中数学学生、教师及几何学习爱好者。
+
+## Skills
+
+1. 几何图形解析
+ - 图形分类: 能够准确识别并分类各类几何图形。
+ - 特征描述: 详细描述图形的具体特征,包括边长、角度、对称性等。
+ - 关系分析: 分析图形内部及图形之间的关系,如全等、相似、位置关系等。
+
+2. 几何定理应用
+ - 定理选择: 根据题目条件选择合适的几何定理进行解析。
+ - 推理验证: 通过定理进行逻辑推理,验证图形的隐含特征。
+ - 结论得出: 基于推理结果,得出准确的几何结论。
+
+## Rules
+
+1. 基本原则:
+ - 准确性: 所有描述和解析必须基于准确的数据和定理。
+ - 完整性: 不遗漏任何关键几何信息,确保解析的全面性。
+ - 逻辑性: 解析过程需逻辑清晰,步骤明确。
+
+2. 行为准则:
+ - 客观性: 描述必须客观,不包含主观臆断。
+ - 严谨性: 解析过程需严谨,每一步都有据可依。
+ - 清晰性: 语言表达清晰,易于理解。
+
+3. 限制条件:
+ - 不接受模糊条件: 题目条件必须明确,不接受模糊或不确定的条件。
+ - 不推导未知定理: 仅基于已知定理进行解析,不推导新的定理。
+ - 不使用复杂符号: 使用初中生能够理解的符号和术语。
+
+## 1. 主体元素清单(按包含关系排序)
+- [主要图形类型]:[具体特征描述](如:直角等腰三角形ABC,∠C=90°,AC=BC)
+- [次要图形类型]:[具体特征描述](位于[父图形名称]的[位置描述])
+(注:所有几何类型判断需满足:①题目明确给出的直接特征 ②可通过SSS/SAS/ASA等定理严格推导的隐含特征)
+
+## 2. 基准边选择优先级
+- 从左向右,从下向上,第一个看到的点做为坐标原点,此点向右水平的边视为X轴。
+
+## 3. 坐标验证机制
+必须包含以下校验步骤:
+1. 计算所有边的长度(使用两点间距离公式:√[(x2-x1)²+(y2-y1)²])
+2. 输出边长比较表:[边标识]:[长度数值](如:AB:5, AC:4, BC:3)
+3. 明确说明基准边选择依据:"选择AB边作为基准,因其长度5为最长(AC=4, BC=3)"
+
+## 4. 特殊图形处理
+- 直角三角形:强制校验斜边是否为最长边(c²=a²+b²)
+- 等腰/等边三角形:标注对称轴与基准边关系
+
+## 5. 辅助元素详细说明
+- [元素类型]:[数量]个,分别为[具体标识],作用是[几何功能描述]
+- 特殊点:[点标识]([几何意义],如:△ABC的重心/外心/垂足)
+- 连接线:[线段标识](连接[起点]与[终点],是否为中线/垂线/角平分线)
+
+## 6. 关键几何关系验证
+- 全等关系:△[标识] ≌ △[标识](依据[判定定理])
+- 相似关系:△[标识] ~ △[标识](相似比为[数值])
+- 位置约束:[图形A]在[图形B]的[方位描述],相距[距离描述]
+
+## Workflows
+
+- 目标: 对初中几何图形进行结构化解析,输出详细的解析报告。
+- 步骤 1: 识别并分类图形,列出主体元素清单。
+- 步骤 2: 选择基准边,进行坐标验证,计算并验证边长。
+- 步骤 3: 处理特殊图形,如直角三角形、等腰/等边三角形。
+- 步骤 4: 描述辅助元素,如特殊点、连接线的类型和作用。
+- 步骤 5: 验证关键几何关系,如全等、相似、位置约束。
+- 预期结果: 输出一份详细的几何图形解析报告,包含所有关键信息。
+
+## Initialization
+作为数学可视化描述专家,你必须遵守上述Rules,按照Workflows执行任务。
+"""
+
+url = "https://api.siliconflow.cn/v1/chat/completions"
+headers = {
+ "Authorization": "Bearer " + "sk-pbqibyjwhrgmnlsmdygplahextfaclgnedetybccknxojlyl",
+ "Content-Type": "application/json"
+}
+data = {
+ "model": "THUDM/GLM-4.1V-9B-Thinking",
+ "messages": [
+ {
+ "role": "user",
+ # "content": "做水煮鱼一般用什么鱼"
+ "content":
+ [
+ {
+ "type": "text",
+ "text": prompt
+ },
+ {
+ "type": "image_url",
+ "image_url": {
+ "url": "https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/Backup/23.jpg"
+ }
+ }
+ ]
+ }
+ ],
+ "stream": True # 启用流式调用
+}
+
+with requests.post(url, headers=headers, json=data, stream=True) as response:
+ for chunk in response.iter_lines():
+ if chunk:
+ decoded = chunk.decode('utf-8')
+ if decoded.startswith('data: [DONE]'):
+ print("完成!")
+ break
+ try:
+ decoded = decoded[5:]
+ json_data = json.loads(decoded)
+ content = json_data["choices"][0]["delta"]['content']
+ if content and len(content) > 0:
+ print(content, end="")
+ except Exception as e:
+ print(e)
diff --git a/test13.py b/test13.py
new file mode 100644
index 0000000..2cd25ba
--- /dev/null
+++ b/test13.py
@@ -0,0 +1,98 @@
+from openai import OpenAI
+
+# 初始化OpenAI客户端
+client = OpenAI(
+ api_key="sk-f6da0c787eff4b0389e4ad03a35a911f",
+ base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
+)
+
+reasoning_content = "" # 定义完整思考过程
+answer_content = "" # 定义完整回复
+is_answering = False # 判断是否结束思考过程并开始回复
+
+prompt = """
+你是“初中几何题-图像结构提取器”,专为初中生设计。任务只有一项:
+看到几何题图片后,用中文输出“完整的题干原文 + 图形客观结构描述”,绝口不提解题思路或答案。
+目标:
+ 让后续 GeoGebra 生成器仅凭你的输出即可复刻原图,同时让初中生一眼看懂图形。
+ 输出格式(固定四段)
+ 题干原文(OCR 结果,逐字照录)
+ 基本元素表(点、线、圆、角、标注长度/角度,按出现顺序编号)
+ 关系表(平行、垂直、相切、全等、相似、共线、共点等)
+ 给出各元素大概位置或坐标
+写作规范:
+ 一律用中文,术语用课本标准词。
+ 描述顺序:先整体外形(如“梯形 ABCD”),再局部细节(如“AB∥CD”)。
+ 长度、角度直接写数值并带单位;若图中仅给符号,则照抄符号。
+ 位置关系用“//、⊥、≅、∼、∈”等符号,后接括号说明。
+ 注意几何图形的形状和线段的长度
+ 不使用“可能、大约”等模糊词。
+ 不解释题意,不提示解法。
+示例模板:
+【题干原文】
+如图,梯形 ABCD 中,AB∥CD …(以下略)
+【基本元素表】
+点:A、B、C、D、E(对角线交点)
+线段:AB=6 cm,CD=10 cm,AD=4 cm,BC=4 cm,AC,BD
+角:∠DAB=60°,∠ABC=120°
+圆:无
+【关系表】
+AB // CD
+AD = BC
+AC 与 BD 交于 E
+∠DAB 与 ∠ABC 互补
+【元素位置】
+A点在左上,B点在右上,C点在A点和B点的下方
+——请严格按以上格式输出,不要省略任何字段。
+"""
+
+# 创建聊天完成请求
+completion = client.chat.completions.create(
+ model="qvq-max-latest", # 此处以 qvq-max 为例,可按需更换模型名称
+ messages=[
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "image_url",
+ "image_url": {
+ "url": "https://dsideal.obs.cn-north-1.myhuaweicloud.com/wb/img10.jpg"
+ },
+ },
+ {"type": "text",
+ "text": prompt},
+ ],
+ },
+ ],
+ stream=True,
+)
+
+print("\n" + "=" * 20 + "思考过程" + "=" * 20 + "\n")
+
+for chunk in completion:
+ # 如果chunk.choices为空,则打印usage
+ if not chunk.choices:
+ print("\nUsage:")
+ print(chunk.usage)
+ else:
+ delta = chunk.choices[0].delta
+ # 打印思考过程
+ if hasattr(delta, 'reasoning_content') and delta.reasoning_content != None:
+ print(delta.reasoning_content, end='', flush=True)
+ reasoning_content += delta.reasoning_content
+ else:
+ # 开始回复
+ if delta.content != "" and is_answering is False:
+ print("\n" + "=" * 20 + "完整回复" + "=" * 20 + "\n")
+ is_answering = True
+ # 打印回复过程
+ print(delta.content, end='', flush=True)
+ answer_content += delta.content
+
+# print("=" * 20 + "完整思考过程" + "=" * 20 + "\n")
+# print(reasoning_content)
+# print("=" * 20 + "完整回复" + "=" * 20 + "\n")
+# 保存成QvqResult.txt
+with open("QvqResult.txt", "w", encoding='utf-8') as f:
+ f.write(answer_content)
+print("试题解析文本保存成功!")
diff --git a/test13_1.py b/test13_1.py
new file mode 100644
index 0000000..5acb0c7
--- /dev/null
+++ b/test13_1.py
@@ -0,0 +1,63 @@
+from zai import ZhipuAiClient
+client = ZhipuAiClient(api_key="78dc1dfe37e04f29bd4ca9a49858a969.gn7TIZTfzpY35nx9") # 请填写您自己的APIKey
+
+
+prompt = """
+你是“初中几何题-图像结构提取器”,专为初中生设计。任务只有一项:
+看到几何题图片后,用中文输出“完整的题干原文 + 图形客观结构描述”,绝口不提解题思路或答案。
+目标:
+ 让后续 GeoGebra 生成器仅凭你的输出即可复刻原图,同时让初中生一眼看懂图形。
+ 输出格式(固定四段)
+ 题干原文(OCR 结果,逐字照录)
+ 基本元素表(点、线、圆、角、标注长度/角度,按出现顺序编号)
+ 关系表(平行、垂直、相切、全等、相似、共线、共点等)
+ 给出各元素大概位置或坐标
+写作规范:
+ 一律用中文,术语用课本标准词。
+ 描述顺序:先整体外形(如“梯形 ABCD”),再局部细节(如“AB∥CD”)。
+ 长度、角度直接写数值并带单位;若图中仅给符号,则照抄符号。
+ 位置关系用“//、⊥、≅、∼、∈”等符号,后接括号说明。
+ 注意几何图形的形状和线段的长度
+ 不使用“可能、大约”等模糊词。
+ 不解释题意,不提示解法。
+注意:
+ 一定要以图为主,不要根据题干内容随意发挥。除非题干中提到了:长度、角度等有实际意义的才进行参考
+ 图中没有线段一定不要出现,图中存在的线段一定不要缺失。
+示例模板:
+【题干原文】
+如图,梯形 ABCD 中,AB∥CD …(以下略)
+【基本元素表】
+点:A、B、C、D、E(对角线交点)
+线段:AB=6 cm,CD=10 cm,AD=4 cm,BC=4 cm,AC,BD
+角:∠DAB=60°,∠ABC=120°
+圆:无
+【关系表】
+AB // CD
+AD = BC
+AC 与 BD 交于 E
+∠DAB 与 ∠ABC 互补
+【元素位置】
+A点在左上,B点在右上,C点在A点和B点的下方
+——请严格按以上格式输出,不要省略任何字段。
+"""
+
+response = client.chat.completions.create(
+ model="glm-4.1v-thinking-flash", # 请填写您要调用的模型名称
+ messages=[
+ {
+ "role": "user",
+ "content": [
+ {"type": "text", "text": prompt},
+ {"type": "image_url", "image_url": {"url": "https://dsideal.obs.cn-north-1.myhuaweicloud.com/wb/img10.jpg"}}
+ ]
+ }
+ ]
+)
+
+print(response.choices[0].message.content)
+
+
+# 保存成QvqResult.txt
+with open("QvqResult.txt", "w", encoding='utf-8') as f:
+ f.write(response.choices[0].message.content)
+print("试题解析文本保存成功!")
diff --git a/test13_2.py b/test13_2.py
new file mode 100644
index 0000000..3656396
--- /dev/null
+++ b/test13_2.py
@@ -0,0 +1,101 @@
+from openai import OpenAI
+
+# 初始化OpenAI客户端
+client = OpenAI(
+ api_key="f6150e6c-422a-4265-8b63-4d941b271220",
+ base_url="https://ark.cn-beijing.volces.com/api/v3"
+)
+
+reasoning_content = "" # 定义完整思考过程
+answer_content = "" # 定义完整回复
+is_answering = False # 判断是否结束思考过程并开始回复
+
+prompt = """
+你是“初中几何题-图像结构提取器”,专为初中生设计。任务只有一项:
+看到几何题图片后,用中文输出“完整的题干原文 + 图形客观结构描述”,绝口不提解题思路或答案。数学公式需要用latex格式输出。
+目标:
+ 让后续 GeoGebra 生成器仅凭你的输出即可复刻原图,同时让初中生一眼看懂图形。
+ 输出格式(固定四段)
+ 题干原文(OCR 结果,逐字照录)
+ 基本元素表(点、线、圆、角、标注长度/角度,按出现顺序编号)
+ 关系表(平行、垂直、相切、全等、相似、共线、共点等)
+ 给出各元素大概位置或坐标
+写作规范:
+ 一律用中文,术语用课本标准词。
+ 描述顺序:先整体外形(如“梯形 ABCD”),再局部细节(如“AB∥CD”)。
+ 长度、角度直接写数值并带单位;若图中仅给符号,则照抄符号。
+ 位置关系用“//、⊥、≅、∼、∈”等符号,后接括号说明。
+ 注意几何图形的形状和线段的长度
+ 如果图形为坐标系,要分析抛物线的开口方向和经过的象限,并详细描述。识别图片中的坐标系类型,如直角坐标系、极坐标系等。
+ 不使用“可能、大约”等模糊词。
+ 请结合题干内容对图形进行描述。
+ 不解释题意,不提示解法。
+ 要以markdown格式输出,不要有\\(或\\),如果有公式在两侧要有$
+示例模板:
+【题干原文】
+如图,梯形 ABCD 中,AB∥CD …(以下略)
+【基本元素表】
+点:A、B、C、D、E(对角线交点)
+线段:AB=6 cm,CD=10 cm,AD=4 cm,BC=4 cm,AC,BD
+角:∠DAB=60°,∠ABC=120°
+圆:无
+【关系表】
+AB // CD
+AD = BC
+AC 与 BD 交于 E
+∠DAB 与 ∠ABC 互补
+【元素位置】
+A点在左上,B点在右上,C点在A点和B点的下方
+——请严格按以上格式输出,不要省略任何字段。
+"""
+
+# 创建聊天完成请求
+completion = client.chat.completions.create(
+ model="doubao-1.5-vision-pro-250328", # 此处以 qvq-max 为例,可按需更换模型名称
+ messages=[
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "image_url",
+ "image_url": {
+ "url": "https://dsideal.obs.cn-north-1.myhuaweicloud.com/wb/img09.jpg"
+ },
+ },
+ {"type": "text",
+ "text": prompt},
+ ],
+ },
+ ],
+ stream=True,
+)
+
+print("\n" + "=" * 20 + "思考过程" + "=" * 20 + "\n")
+
+for chunk in completion:
+ # 如果chunk.choices为空,则打印usage
+ if not chunk.choices:
+ print("\nUsage:")
+ print(chunk.usage)
+ else:
+ delta = chunk.choices[0].delta
+ # 打印思考过程
+ if hasattr(delta, 'reasoning_content') and delta.reasoning_content != None:
+ print(delta.reasoning_content, end='', flush=True)
+ reasoning_content += delta.reasoning_content
+ else:
+ # 开始回复
+ if delta.content != "" and is_answering is False:
+ print("\n" + "=" * 20 + "完整回复" + "=" * 20 + "\n")
+ is_answering = True
+ # 打印回复过程
+ print(delta.content, end='', flush=True)
+ answer_content += delta.content
+
+# print("=" * 20 + "完整思考过程" + "=" * 20 + "\n")
+# print(reasoning_content)
+# print("=" * 20 + "完整回复" + "=" * 20 + "\n")
+# 保存成QvqResult.txt
+with open("QvqResult.txt", "w", encoding='utf-8') as f:
+ f.write(answer_content)
+print("试题解析文本保存成功!")
diff --git a/test14.py b/test14.py
new file mode 100644
index 0000000..dab4363
--- /dev/null
+++ b/test14.py
@@ -0,0 +1,134 @@
+from openai import OpenAI
+
+if __name__ == '__main__':
+ # 读取 QvqResult.txt 内容
+ file_name="QvqResult_14.txt"
+ # file_name = "GlmResult.txt"
+ with open(file_name, 'r', encoding='utf-8') as file:
+ QvqResult = file.read() # 直接获取整个文件内容为字符串
+
+ # 初始化OpenAI客户端
+ client = OpenAI(
+ api_key="sk-f6da0c787eff4b0389e4ad03a35a911f",
+ base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
+ )
+
+ reasoning_content = "" # 定义完整思考过程
+ answer_content = "" # 定义完整回复
+ is_answering = False # 判断是否结束思考过程并开始回复
+
+ prompt = """
+# Role: GeoGebra 几何图形生成器
+
+## Profile
+- language: 中文
+- description: 专门用于根据初中几何题的题干和几何图形的描述来生成Geogebra指令集的角色,确保生成的指令集严格遵循几何约束和动态坐标系构建规则,并具备错误熔断机制。
+- background: 拥有深厚的几何学和计算机科学背景,熟悉Geogebra软件的操作和指令集编写。
+- personality: 严谨、细致、高效
+- expertise: 几何学、计算机编程、Geogebra软件应用
+
+**几何图形生成规则(通用强制约束版)**
+
+请严格按以下优先级执行,不受题目具体内容影响:
+1. **几何约束最高优先级**
+ - 描述中提到的水平线段,一定要保持水平,不可以进行变更
+ - 当文字描述与坐标/位置冲突时,以文字描述的几何关系为准
+ - 必须自动验证:{长度|角度|中点|平行|垂直}关系
+ - 验证失败时:重新计算坐标并报告修正
+ - 有动点的,要设置滑块。没有动点的,不要设置滑块。
+ - 检查描述中提到的最长的边做为X轴,最长边的左端点做为原点
+
+2. **动态坐标系构建**
+ ```mermaid
+ graph TB
+ A[定位原点] --> B{原点坐标明确?}
+ B -->|是| C[直接采用]
+ B -->|否| D[根据相对关系推算]
+ E[建立坐标系] --> F{存在水平/垂直要求?}
+ F -->|是| G[调整坐标满足]
+ F -->|否| H[保持默认方向]
+```
+
+3、错误熔断机制
+
+检测到矛盾 → 触发修正流程:
+
+if not satisfy_constraint(description):
+ new_coords = recalculate_by_geometry()
+ log_adjustment(old_coords, new_coords, reason)
+
+4、元素生成协议
+
+顺序:固定点 → 固定线 → 动态点(初始位) → 动态元素
+
+依赖检查:确保父元素先于子元素生成
+
+5、输出结构(强制)
+
+[修正报告] (若有调整)
+[坐标摘要] (最终使用坐标)
+[Geogebra指令] (完整可执行代码)
+注意:
+【1】GGB指令集中不要添加注释!不要添加除指令集外的其它描述性文字,需要可以直接批量执行的!
+【2】仔细检查原图中是线段还是直线,要严格进行识别!
+【3】仔细检查原图中的每一条边是否都正确进行了线段标识!
+【4】不显示网格(使用ShowGrid(false)),不显示坐标轴(使用ShowAxes(false))
+【5】如果在使用Segment创建两个点的线段时,需要指定一个标签名,然后使用ShowLabel隐藏这个标签名,注意使用的是ShowLabel而不是SetVisibleInView,而且只是Segment创建两个点的线段时才隐藏标签名
+【6】注意不要使用Perpendicular,需要使用PerpendicularLine来替代
+【7】注意不要使用SetLabel,因为会提示“未知的指令”。
+【8】注意不要使用Angle,无需标注角度。
+【9】如果有滑块使用Slider
+【10】如果没有动点就无需添加滑块。
+【11】注意不要使用TangentPoint,因为会提示“未知的指令”。
+
+6、题目的文字描述信息
+```
+{QvqResult}
+```
+ """
+ prompt = prompt.replace("{QvqResult}", QvqResult)
+ # 创建聊天完成请求
+ completion = client.chat.completions.create(
+ model="deepseek-r1-0528",
+ messages=[
+ {
+ "role": "user",
+ "content": [
+ {"type": "text",
+ "text": prompt},
+ ],
+ },
+ ],
+ stream=True,
+ )
+
+ print("\n" + "=" * 20 + "思考过程" + "=" * 20 + "\n")
+
+ for chunk in completion:
+ # 如果chunk.choices为空,则打印usage
+ if not chunk.choices:
+ print("\nUsage:")
+ print(chunk.usage)
+ else:
+ delta = chunk.choices[0].delta
+ # 打印思考过程
+ if hasattr(delta, 'reasoning_content') and delta.reasoning_content != None:
+ print(delta.reasoning_content, end='', flush=True)
+ reasoning_content += delta.reasoning_content
+ else:
+ # 开始回复
+ if delta.content != "" and is_answering is False:
+ print("\n" + "=" * 20 + "完整回复" + "=" * 20 + "\n")
+ is_answering = True
+ # 打印回复过程
+ print(delta.content, end='', flush=True)
+ answer_content += delta.content
+
+ # print("=" * 20 + "完整思考过程" + "=" * 20 + "\n")
+ # print(reasoning_content)
+ # print("=" * 20 + "完整回复" + "=" * 20 + "\n")
+ print(answer_content)
+ # 保存成GGB.txt
+ with open("GGB.txt", "w", encoding='utf-8') as f:
+ f.write(answer_content)
+ print("GGB指令集保存成功!")
diff --git a/test14_1.py b/test14_1.py
new file mode 100644
index 0000000..9212b27
--- /dev/null
+++ b/test14_1.py
@@ -0,0 +1,134 @@
+from openai import OpenAI
+
+if __name__ == '__main__':
+ # 读取 QvqResult.txt 内容
+ file_name="QvqResult.txt"
+ # file_name = "GlmResult.txt"
+ with open(file_name, 'r', encoding='utf-8') as file:
+ QvqResult = file.read() # 直接获取整个文件内容为字符串
+
+ # 初始化OpenAI客户端
+ client = OpenAI(
+ api_key="sk-f6da0c787eff4b0389e4ad03a35a911f",
+ base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
+ )
+
+ reasoning_content = "" # 定义完整思考过程
+ answer_content = "" # 定义完整回复
+ is_answering = False # 判断是否结束思考过程并开始回复
+
+ prompt = """
+# Role: GeoGebra 几何图形生成器
+
+## Profile
+- language: 中文
+- description: 专门用于根据初中几何题的题干和几何图形的描述来生成Geogebra指令集的角色,确保生成的指令集严格遵循几何约束和动态坐标系构建规则,并具备错误熔断机制。
+- background: 拥有深厚的几何学和计算机科学背景,熟悉Geogebra软件的操作和指令集编写。
+- personality: 严谨、细致、高效
+- expertise: 几何学、计算机编程、Geogebra软件应用
+
+**几何图形生成规则(通用强制约束版)**
+
+请严格按以下优先级执行,不受题目具体内容影响:
+1. **几何约束最高优先级**
+ - 描述中提到的水平线段,一定要保持水平,不可以进行变更
+ - 当文字描述与坐标/位置冲突时,以文字描述的几何关系为准
+ - 必须自动验证:{长度|角度|中点|平行|垂直}关系
+ - 验证失败时:重新计算坐标并报告修正
+ - 有动点的,要设置滑块。没有动点的,不要设置滑块。
+ - 检查描述中提到的最长的边做为X轴,最长边的左端点做为原点
+
+2. **动态坐标系构建**
+ ```mermaid
+ graph TB
+ A[定位原点] --> B{原点坐标明确?}
+ B -->|是| C[直接采用]
+ B -->|否| D[根据相对关系推算]
+ E[建立坐标系] --> F{存在水平/垂直要求?}
+ F -->|是| G[调整坐标满足]
+ F -->|否| H[保持默认方向]
+```
+
+3、错误熔断机制
+
+检测到矛盾 → 触发修正流程:
+
+if not satisfy_constraint(description):
+ new_coords = recalculate_by_geometry()
+ log_adjustment(old_coords, new_coords, reason)
+
+4、元素生成协议
+
+顺序:固定点 → 固定线 → 动态点(初始位) → 动态元素
+
+依赖检查:确保父元素先于子元素生成
+
+5、输出结构(强制)
+
+[修正报告] (若有调整)
+[坐标摘要] (最终使用坐标)
+[Geogebra指令] (完整可执行代码)
+注意:
+【1】GGB指令集中不要添加注释!不要添加除指令集外的其它描述性文字,需要可以直接批量执行的!
+【2】仔细检查原图中是线段还是直线,要严格进行识别!
+【3】仔细检查原图中的每一条边是否都正确进行了线段标识!
+【4】不显示网格(使用ShowGrid(false)),不显示坐标轴(使用ShowAxes(false)),但如果是坐标系就需要显示坐标轴。
+【5】如果在使用Segment创建两个点的线段时,需要指定一个标签名,然后使用ShowLabel隐藏这个标签名,注意使用的是ShowLabel而不是SetVisibleInView,而且只是Segment创建两个点的线段时才隐藏标签名
+【6】注意不要使用Perpendicular,需要使用PerpendicularLine来替代
+【7】注意不要使用SetLabel,因为会提示“未知的指令”。
+【8】注意不要使用Angle,无需标注角度。
+【9】如果有滑块使用Slider
+【10】如果没有动点就无需添加滑块。
+【11】注意不要使用TangentPoint,因为会提示“未知的指令”。
+
+6、题目的文字描述信息
+```
+{QvqResult}
+```
+ """
+ prompt = prompt.replace("{QvqResult}", QvqResult)
+ # 创建聊天完成请求
+ completion = client.chat.completions.create(
+ model="deepseek-r1-0528",
+ messages=[
+ {
+ "role": "user",
+ "content": [
+ {"type": "text",
+ "text": prompt},
+ ],
+ },
+ ],
+ stream=True,
+ )
+
+ print("\n" + "=" * 20 + "思考过程" + "=" * 20 + "\n")
+
+ for chunk in completion:
+ # 如果chunk.choices为空,则打印usage
+ if not chunk.choices:
+ print("\nUsage:")
+ print(chunk.usage)
+ else:
+ delta = chunk.choices[0].delta
+ # 打印思考过程
+ if hasattr(delta, 'reasoning_content') and delta.reasoning_content != None:
+ print(delta.reasoning_content, end='', flush=True)
+ reasoning_content += delta.reasoning_content
+ else:
+ # 开始回复
+ if delta.content != "" and is_answering is False:
+ print("\n" + "=" * 20 + "完整回复" + "=" * 20 + "\n")
+ is_answering = True
+ # 打印回复过程
+ print(delta.content, end='', flush=True)
+ answer_content += delta.content
+
+ # print("=" * 20 + "完整思考过程" + "=" * 20 + "\n")
+ # print(reasoning_content)
+ # print("=" * 20 + "完整回复" + "=" * 20 + "\n")
+ print(answer_content)
+ # 保存成GGB.txt
+ with open("GGB.txt", "w", encoding='utf-8') as f:
+ f.write(answer_content)
+ print("GGB指令集保存成功!")
diff --git a/test16.py b/test16.py
new file mode 100644
index 0000000..f454173
--- /dev/null
+++ b/test16.py
@@ -0,0 +1,16 @@
+from gradio_client import (Client)
+
+client = Client("https://confucius.youdao.com/")
+result = client.predict(
+ message={"text": "Describe this image",
+ "files": 'https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png'},
+ model_selection="Confucius3-Math",
+ max_tokens=16384,
+ temperature=1,
+ top_p=0.7,
+ top_k=-1,
+ presence_penalty=0,
+ frequency_penalty=0,
+ api_name="/chat"
+)
+print(result)
diff --git a/utils/__pycache__/image_utils.cpython-312.pyc b/utils/__pycache__/image_utils.cpython-312.pyc
new file mode 100644
index 0000000..1640007
Binary files /dev/null and b/utils/__pycache__/image_utils.cpython-312.pyc differ
diff --git a/utils/image_utils.py b/utils/image_utils.py
new file mode 100644
index 0000000..9c6150e
--- /dev/null
+++ b/utils/image_utils.py
@@ -0,0 +1,11 @@
+from PIL import Image
+import io
+import base64
+
+# 创建utils目录并迁移工具函数
+def encode_image(image_path):
+ img = Image.open(image_path)
+ buffer = io.BytesIO()
+ img.save(buffer, format="JPEG")
+ buffer.seek(0)
+ return base64.b64encode(buffer.read()).decode('utf-8')
\ No newline at end of file