Ethosoft-Math 0.1.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ethosoft_math-0.4.0/PKG-INFO +120 -0
- ethosoft_math-0.4.0/README.md +103 -0
- {ethosoft_math-0.1.0 → ethosoft_math-0.4.0}/pyproject.toml +32 -32
- ethosoft_math-0.4.0/src/Ethosoft_Math.egg-info/PKG-INFO +120 -0
- {ethosoft_math-0.1.0 → ethosoft_math-0.4.0}/src/Ethosoft_Math.egg-info/SOURCES.txt +3 -0
- ethosoft_math-0.4.0/src/ethosoft_math/__init__.py +36 -0
- ethosoft_math-0.4.0/src/ethosoft_math/calc.py +261 -0
- {ethosoft_math-0.1.0 → ethosoft_math-0.4.0}/src/ethosoft_math/cli.py +71 -56
- {ethosoft_math-0.1.0 → ethosoft_math-0.4.0}/src/ethosoft_math/converter.py +1436 -1418
- {ethosoft_math-0.1.0 → ethosoft_math-0.4.0}/src/ethosoft_math/protocol.py +167 -30
- ethosoft_math-0.4.0/src/ethosoft_math/runtime.py +76 -0
- ethosoft_math-0.4.0/src/ethosoft_math/tooluse.py +85 -0
- ethosoft_math-0.4.0/tests/test_basic.py +144 -0
- ethosoft_math-0.1.0/PKG-INFO +0 -72
- ethosoft_math-0.1.0/README.md +0 -55
- ethosoft_math-0.1.0/src/Ethosoft_Math.egg-info/PKG-INFO +0 -72
- ethosoft_math-0.1.0/src/ethosoft_math/__init__.py +0 -30
- ethosoft_math-0.1.0/tests/test_basic.py +0 -59
- {ethosoft_math-0.1.0 → ethosoft_math-0.4.0}/setup.cfg +0 -0
- {ethosoft_math-0.1.0 → ethosoft_math-0.4.0}/src/Ethosoft_Math.egg-info/dependency_links.txt +0 -0
- {ethosoft_math-0.1.0 → ethosoft_math-0.4.0}/src/Ethosoft_Math.egg-info/entry_points.txt +0 -0
- {ethosoft_math-0.1.0 → ethosoft_math-0.4.0}/src/Ethosoft_Math.egg-info/requires.txt +0 -0
- {ethosoft_math-0.1.0 → ethosoft_math-0.4.0}/src/Ethosoft_Math.egg-info/top_level.txt +0 -0
- {ethosoft_math-0.1.0 → ethosoft_math-0.4.0}/src/ethosoft_math/__main__.py +0 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Ethosoft-Math
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Convert math solutions into verified tool-use traces (add(3, 4) -> 7) with an executable math tool protocol.
|
|
5
|
+
Author: Ethosoft
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: math,tool-use,llm,dataset,reasoning,sympy,function-calling
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
12
|
+
Requires-Python: >=3.9
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
Requires-Dist: sympy>=1.12
|
|
15
|
+
Provides-Extra: test
|
|
16
|
+
Requires-Dist: pytest; extra == "test"
|
|
17
|
+
|
|
18
|
+
# Ethosoft-Math
|
|
19
|
+
|
|
20
|
+
Matematik çözümlerindeki **her hesabı** doğrulanmış bir araç çağrısına (tool-use) çeviren kütüphane.
|
|
21
|
+
Turn math solutions into verified tool-use traces: `3 + 4 = 7` → `topla(3, 4)` → `7`.
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
import ethosoft_math as em
|
|
25
|
+
|
|
26
|
+
em.convert("Toplam 3 + 4 = 7 elma.")
|
|
27
|
+
# 'Toplam <arac_cagrisi>topla(3, 4)</arac_cagrisi><arac_sonucu>7</arac_sonucu> elma.'
|
|
28
|
+
|
|
29
|
+
em.calculate("4 + 5") # '9' <- hesap makinesi
|
|
30
|
+
em.calculate("2 uzeri 10") # '1024'
|
|
31
|
+
em.calculate("1.250,50 + 3,5") # '1254' (Türkçe sayı yazımı)
|
|
32
|
+
em.calculate("4 + 5", trace=True) # '<arac_cagrisi>topla(4, 5)</arac_cagrisi><arac_sonucu>9</arac_sonucu>'
|
|
33
|
+
em.calculate("17 mod 5") # '2'
|
|
34
|
+
em.calculate("50'nin %20'si") # '10'
|
|
35
|
+
em.calculate("3 < 5") # 'dogru'
|
|
36
|
+
em.calculate("100 / 3", decimals=2) # '33.33'
|
|
37
|
+
em.calculate("(a+b)^2 = a^2+2ab+b^2") # 'dogru'
|
|
38
|
+
em.calculate("bana 12 * 12 yi hesapla") # '144'
|
|
39
|
+
|
|
40
|
+
em.execute('coz("x^2 - 4 = 0", "x")') # '[-2, 2]'
|
|
41
|
+
em.verify(em.convert(text)) # (cagri_sayisi, hatali_sayisi)
|
|
42
|
+
em.convert(text, lang="en") # <tool_call>add(3, 4)</tool_call>...
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Araç çalıştırıcı (modelin hesap makinesi)
|
|
46
|
+
|
|
47
|
+
Model `<arac_cagrisi>` bloğunu yazar; kütüphane içindeki çağrıyı çalıştırıp
|
|
48
|
+
`<arac_sonucu>` arasına sonucu yazar:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
em.fill_results("<arac_cagrisi>bol(48, 2)</arac_cagrisi>")
|
|
52
|
+
# '<arac_cagrisi>bol(48, 2)</arac_cagrisi><arac_sonucu>24</arac_sonucu>'
|
|
53
|
+
|
|
54
|
+
em.result_block("bol(48, 2)") # '<arac_sonucu>24</arac_sonucu>' (sadece sonuç bloğu)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Üretim döngüsünde: model `</arac_cagrisi>` yazınca dur → `result_block(metin)` → dönen bloğu ekleyip devam et.
|
|
58
|
+
Hata olursa sonuç `HATA: neden` olur; `tanimla(...)` tanımları aynı metinde sonraki çağrılarda geçerlidir.
|
|
59
|
+
|
|
60
|
+
## Düz metin → tool-use
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
em.tool_use("Mayıs'ta 48 / 2 = 24 kart, toplam 48 + 24 = 72.")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Neden
|
|
67
|
+
|
|
68
|
+
LLM'e hesabı "kafadan" yaptırmak yerine aracı çağırtmak için eğitim verisi üretirsin.
|
|
69
|
+
Her çağrı, çevirme anında **yeniden çalıştırılıp doğrulanır**; tutmayan hiçbir şey çıktıya girmez.
|
|
70
|
+
Veride yanlış olan eşitlikler (`2 + 2 = 5`) olduğu gibi bırakılır.
|
|
71
|
+
|
|
72
|
+
## Protokol (v0.2: Türkçe)
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
<arac_cagrisi>FONKSIYON(arg1, arg2, ...)</arac_cagrisi><arac_sonucu>SONUC</arac_sonucu>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
| İşlem | Türkçe ad | İngilizce ad |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| `a + b` | `topla` | `add` |
|
|
81
|
+
| `a - b` | `cikar` | `sub` |
|
|
82
|
+
| `a × b` | `carp` | `mul` |
|
|
83
|
+
| `a / b` | `bol` | `div` |
|
|
84
|
+
| `a ^ b` | `us` | `pow` |
|
|
85
|
+
| `√a` | `karekok` | `sqrt` |
|
|
86
|
+
| `n!` | `faktoriyel` | `fact` |
|
|
87
|
+
| `C(n,k)` | `kombinasyon` | `comb` |
|
|
88
|
+
| denklem çöz | `coz` | `solve` |
|
|
89
|
+
| serbest ifade | `hesapla` | `calc` |
|
|
90
|
+
|
|
91
|
+
- Türkçe ve İngilizce adların ikisi de çalışır (`execute("add(3, 4)")` = `execute("topla(3, 4)")`).
|
|
92
|
+
- Sonuç kelimeleri: `dogru` / `yanlis` / `bos` / `HATA: ...`.
|
|
93
|
+
- Gruplar: aritmetik, yüzde, sayı teorisi, üs/log, trigonometri, geometri, olasılık/istatistik,
|
|
94
|
+
diziler, cebir, analiz, lineer cebir, fonksiyon tanımlama (`tanimla`).
|
|
95
|
+
- Tam liste: `ethosoft-math protocol`
|
|
96
|
+
|
|
97
|
+
## Komut satırı
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
ethosoft-math calc "4 + 5"
|
|
101
|
+
ethosoft-math exec "carp(topla(3, 4), 2)"
|
|
102
|
+
ethosoft-math protocol > PROTOCOL.md
|
|
103
|
+
ethosoft-math convert in.jsonl out.jsonl --field solution [--lang en] [--aggressive]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Çalışma modları
|
|
107
|
+
|
|
108
|
+
| Mod | Ne yapar |
|
|
109
|
+
|---|---|
|
|
110
|
+
| `convert(text)` (varsayılan) | Yalnızca doğrulanabilen eşitlikleri, denklemleri, eşitsizlikleri, toplamları çevirir |
|
|
111
|
+
| `convert(text, aggressive=True)` | Ek olarak `=` içermeyen salt-sayısal işlemleri de çevirir |
|
|
112
|
+
| `lang="en"` | Etiket ve fonksiyon adlarını İngilizce üretir |
|
|
113
|
+
|
|
114
|
+
## Sınırlar
|
|
115
|
+
|
|
116
|
+
- Python/PoT kodu içeren çözümlere dokunmaz.
|
|
117
|
+
- İspat ve sözel anlatım satırlarında çağrı üretilmez (hesap yoktur).
|
|
118
|
+
- Çeviri modelinden önce çalıştırılmalıdır; araç blokları çeviriden korunmalıdır.
|
|
119
|
+
|
|
120
|
+
Lisans: MIT
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Ethosoft-Math
|
|
2
|
+
|
|
3
|
+
Matematik çözümlerindeki **her hesabı** doğrulanmış bir araç çağrısına (tool-use) çeviren kütüphane.
|
|
4
|
+
Turn math solutions into verified tool-use traces: `3 + 4 = 7` → `topla(3, 4)` → `7`.
|
|
5
|
+
|
|
6
|
+
```python
|
|
7
|
+
import ethosoft_math as em
|
|
8
|
+
|
|
9
|
+
em.convert("Toplam 3 + 4 = 7 elma.")
|
|
10
|
+
# 'Toplam <arac_cagrisi>topla(3, 4)</arac_cagrisi><arac_sonucu>7</arac_sonucu> elma.'
|
|
11
|
+
|
|
12
|
+
em.calculate("4 + 5") # '9' <- hesap makinesi
|
|
13
|
+
em.calculate("2 uzeri 10") # '1024'
|
|
14
|
+
em.calculate("1.250,50 + 3,5") # '1254' (Türkçe sayı yazımı)
|
|
15
|
+
em.calculate("4 + 5", trace=True) # '<arac_cagrisi>topla(4, 5)</arac_cagrisi><arac_sonucu>9</arac_sonucu>'
|
|
16
|
+
em.calculate("17 mod 5") # '2'
|
|
17
|
+
em.calculate("50'nin %20'si") # '10'
|
|
18
|
+
em.calculate("3 < 5") # 'dogru'
|
|
19
|
+
em.calculate("100 / 3", decimals=2) # '33.33'
|
|
20
|
+
em.calculate("(a+b)^2 = a^2+2ab+b^2") # 'dogru'
|
|
21
|
+
em.calculate("bana 12 * 12 yi hesapla") # '144'
|
|
22
|
+
|
|
23
|
+
em.execute('coz("x^2 - 4 = 0", "x")') # '[-2, 2]'
|
|
24
|
+
em.verify(em.convert(text)) # (cagri_sayisi, hatali_sayisi)
|
|
25
|
+
em.convert(text, lang="en") # <tool_call>add(3, 4)</tool_call>...
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Araç çalıştırıcı (modelin hesap makinesi)
|
|
29
|
+
|
|
30
|
+
Model `<arac_cagrisi>` bloğunu yazar; kütüphane içindeki çağrıyı çalıştırıp
|
|
31
|
+
`<arac_sonucu>` arasına sonucu yazar:
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
em.fill_results("<arac_cagrisi>bol(48, 2)</arac_cagrisi>")
|
|
35
|
+
# '<arac_cagrisi>bol(48, 2)</arac_cagrisi><arac_sonucu>24</arac_sonucu>'
|
|
36
|
+
|
|
37
|
+
em.result_block("bol(48, 2)") # '<arac_sonucu>24</arac_sonucu>' (sadece sonuç bloğu)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Üretim döngüsünde: model `</arac_cagrisi>` yazınca dur → `result_block(metin)` → dönen bloğu ekleyip devam et.
|
|
41
|
+
Hata olursa sonuç `HATA: neden` olur; `tanimla(...)` tanımları aynı metinde sonraki çağrılarda geçerlidir.
|
|
42
|
+
|
|
43
|
+
## Düz metin → tool-use
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
em.tool_use("Mayıs'ta 48 / 2 = 24 kart, toplam 48 + 24 = 72.")
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Neden
|
|
50
|
+
|
|
51
|
+
LLM'e hesabı "kafadan" yaptırmak yerine aracı çağırtmak için eğitim verisi üretirsin.
|
|
52
|
+
Her çağrı, çevirme anında **yeniden çalıştırılıp doğrulanır**; tutmayan hiçbir şey çıktıya girmez.
|
|
53
|
+
Veride yanlış olan eşitlikler (`2 + 2 = 5`) olduğu gibi bırakılır.
|
|
54
|
+
|
|
55
|
+
## Protokol (v0.2: Türkçe)
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
<arac_cagrisi>FONKSIYON(arg1, arg2, ...)</arac_cagrisi><arac_sonucu>SONUC</arac_sonucu>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
| İşlem | Türkçe ad | İngilizce ad |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| `a + b` | `topla` | `add` |
|
|
64
|
+
| `a - b` | `cikar` | `sub` |
|
|
65
|
+
| `a × b` | `carp` | `mul` |
|
|
66
|
+
| `a / b` | `bol` | `div` |
|
|
67
|
+
| `a ^ b` | `us` | `pow` |
|
|
68
|
+
| `√a` | `karekok` | `sqrt` |
|
|
69
|
+
| `n!` | `faktoriyel` | `fact` |
|
|
70
|
+
| `C(n,k)` | `kombinasyon` | `comb` |
|
|
71
|
+
| denklem çöz | `coz` | `solve` |
|
|
72
|
+
| serbest ifade | `hesapla` | `calc` |
|
|
73
|
+
|
|
74
|
+
- Türkçe ve İngilizce adların ikisi de çalışır (`execute("add(3, 4)")` = `execute("topla(3, 4)")`).
|
|
75
|
+
- Sonuç kelimeleri: `dogru` / `yanlis` / `bos` / `HATA: ...`.
|
|
76
|
+
- Gruplar: aritmetik, yüzde, sayı teorisi, üs/log, trigonometri, geometri, olasılık/istatistik,
|
|
77
|
+
diziler, cebir, analiz, lineer cebir, fonksiyon tanımlama (`tanimla`).
|
|
78
|
+
- Tam liste: `ethosoft-math protocol`
|
|
79
|
+
|
|
80
|
+
## Komut satırı
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
ethosoft-math calc "4 + 5"
|
|
84
|
+
ethosoft-math exec "carp(topla(3, 4), 2)"
|
|
85
|
+
ethosoft-math protocol > PROTOCOL.md
|
|
86
|
+
ethosoft-math convert in.jsonl out.jsonl --field solution [--lang en] [--aggressive]
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Çalışma modları
|
|
90
|
+
|
|
91
|
+
| Mod | Ne yapar |
|
|
92
|
+
|---|---|
|
|
93
|
+
| `convert(text)` (varsayılan) | Yalnızca doğrulanabilen eşitlikleri, denklemleri, eşitsizlikleri, toplamları çevirir |
|
|
94
|
+
| `convert(text, aggressive=True)` | Ek olarak `=` içermeyen salt-sayısal işlemleri de çevirir |
|
|
95
|
+
| `lang="en"` | Etiket ve fonksiyon adlarını İngilizce üretir |
|
|
96
|
+
|
|
97
|
+
## Sınırlar
|
|
98
|
+
|
|
99
|
+
- Python/PoT kodu içeren çözümlere dokunmaz.
|
|
100
|
+
- İspat ve sözel anlatım satırlarında çağrı üretilmez (hesap yoktur).
|
|
101
|
+
- Çeviri modelinden önce çalıştırılmalıdır; araç blokları çeviriden korunmalıdır.
|
|
102
|
+
|
|
103
|
+
Lisans: MIT
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=68", "wheel"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "Ethosoft-Math"
|
|
7
|
-
version = "0.
|
|
8
|
-
description = "Convert math solutions into verified tool-use traces (add(3, 4) -> 7) with an executable math tool protocol."
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.9"
|
|
11
|
-
license = { text = "MIT" }
|
|
12
|
-
authors = [{ name = "Ethosoft" }]
|
|
13
|
-
keywords = ["math", "tool-use", "llm", "dataset", "reasoning", "sympy", "function-calling"]
|
|
14
|
-
classifiers = [
|
|
15
|
-
"Programming Language :: Python :: 3",
|
|
16
|
-
"License :: OSI Approved :: MIT License",
|
|
17
|
-
"Intended Audience :: Science/Research",
|
|
18
|
-
"Topic :: Scientific/Engineering :: Mathematics",
|
|
19
|
-
]
|
|
20
|
-
dependencies = ["sympy>=1.12"]
|
|
21
|
-
|
|
22
|
-
[project.optional-dependencies]
|
|
23
|
-
test = ["pytest"]
|
|
24
|
-
|
|
25
|
-
[project.scripts]
|
|
26
|
-
ethosoft-math = "ethosoft_math.cli:main"
|
|
27
|
-
|
|
28
|
-
[tool.setuptools.packages.find]
|
|
29
|
-
where = ["src"]
|
|
30
|
-
|
|
31
|
-
[tool.setuptools]
|
|
32
|
-
license-files = []
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "Ethosoft-Math"
|
|
7
|
+
version = "0.4.0"
|
|
8
|
+
description = "Convert math solutions into verified tool-use traces (add(3, 4) -> 7) with an executable math tool protocol."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Ethosoft" }]
|
|
13
|
+
keywords = ["math", "tool-use", "llm", "dataset", "reasoning", "sympy", "function-calling"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Intended Audience :: Science/Research",
|
|
18
|
+
"Topic :: Scientific/Engineering :: Mathematics",
|
|
19
|
+
]
|
|
20
|
+
dependencies = ["sympy>=1.12"]
|
|
21
|
+
|
|
22
|
+
[project.optional-dependencies]
|
|
23
|
+
test = ["pytest"]
|
|
24
|
+
|
|
25
|
+
[project.scripts]
|
|
26
|
+
ethosoft-math = "ethosoft_math.cli:main"
|
|
27
|
+
|
|
28
|
+
[tool.setuptools.packages.find]
|
|
29
|
+
where = ["src"]
|
|
30
|
+
|
|
31
|
+
[tool.setuptools]
|
|
32
|
+
license-files = []
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Ethosoft-Math
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Convert math solutions into verified tool-use traces (add(3, 4) -> 7) with an executable math tool protocol.
|
|
5
|
+
Author: Ethosoft
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: math,tool-use,llm,dataset,reasoning,sympy,function-calling
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
12
|
+
Requires-Python: >=3.9
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
Requires-Dist: sympy>=1.12
|
|
15
|
+
Provides-Extra: test
|
|
16
|
+
Requires-Dist: pytest; extra == "test"
|
|
17
|
+
|
|
18
|
+
# Ethosoft-Math
|
|
19
|
+
|
|
20
|
+
Matematik çözümlerindeki **her hesabı** doğrulanmış bir araç çağrısına (tool-use) çeviren kütüphane.
|
|
21
|
+
Turn math solutions into verified tool-use traces: `3 + 4 = 7` → `topla(3, 4)` → `7`.
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
import ethosoft_math as em
|
|
25
|
+
|
|
26
|
+
em.convert("Toplam 3 + 4 = 7 elma.")
|
|
27
|
+
# 'Toplam <arac_cagrisi>topla(3, 4)</arac_cagrisi><arac_sonucu>7</arac_sonucu> elma.'
|
|
28
|
+
|
|
29
|
+
em.calculate("4 + 5") # '9' <- hesap makinesi
|
|
30
|
+
em.calculate("2 uzeri 10") # '1024'
|
|
31
|
+
em.calculate("1.250,50 + 3,5") # '1254' (Türkçe sayı yazımı)
|
|
32
|
+
em.calculate("4 + 5", trace=True) # '<arac_cagrisi>topla(4, 5)</arac_cagrisi><arac_sonucu>9</arac_sonucu>'
|
|
33
|
+
em.calculate("17 mod 5") # '2'
|
|
34
|
+
em.calculate("50'nin %20'si") # '10'
|
|
35
|
+
em.calculate("3 < 5") # 'dogru'
|
|
36
|
+
em.calculate("100 / 3", decimals=2) # '33.33'
|
|
37
|
+
em.calculate("(a+b)^2 = a^2+2ab+b^2") # 'dogru'
|
|
38
|
+
em.calculate("bana 12 * 12 yi hesapla") # '144'
|
|
39
|
+
|
|
40
|
+
em.execute('coz("x^2 - 4 = 0", "x")') # '[-2, 2]'
|
|
41
|
+
em.verify(em.convert(text)) # (cagri_sayisi, hatali_sayisi)
|
|
42
|
+
em.convert(text, lang="en") # <tool_call>add(3, 4)</tool_call>...
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Araç çalıştırıcı (modelin hesap makinesi)
|
|
46
|
+
|
|
47
|
+
Model `<arac_cagrisi>` bloğunu yazar; kütüphane içindeki çağrıyı çalıştırıp
|
|
48
|
+
`<arac_sonucu>` arasına sonucu yazar:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
em.fill_results("<arac_cagrisi>bol(48, 2)</arac_cagrisi>")
|
|
52
|
+
# '<arac_cagrisi>bol(48, 2)</arac_cagrisi><arac_sonucu>24</arac_sonucu>'
|
|
53
|
+
|
|
54
|
+
em.result_block("bol(48, 2)") # '<arac_sonucu>24</arac_sonucu>' (sadece sonuç bloğu)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Üretim döngüsünde: model `</arac_cagrisi>` yazınca dur → `result_block(metin)` → dönen bloğu ekleyip devam et.
|
|
58
|
+
Hata olursa sonuç `HATA: neden` olur; `tanimla(...)` tanımları aynı metinde sonraki çağrılarda geçerlidir.
|
|
59
|
+
|
|
60
|
+
## Düz metin → tool-use
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
em.tool_use("Mayıs'ta 48 / 2 = 24 kart, toplam 48 + 24 = 72.")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Neden
|
|
67
|
+
|
|
68
|
+
LLM'e hesabı "kafadan" yaptırmak yerine aracı çağırtmak için eğitim verisi üretirsin.
|
|
69
|
+
Her çağrı, çevirme anında **yeniden çalıştırılıp doğrulanır**; tutmayan hiçbir şey çıktıya girmez.
|
|
70
|
+
Veride yanlış olan eşitlikler (`2 + 2 = 5`) olduğu gibi bırakılır.
|
|
71
|
+
|
|
72
|
+
## Protokol (v0.2: Türkçe)
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
<arac_cagrisi>FONKSIYON(arg1, arg2, ...)</arac_cagrisi><arac_sonucu>SONUC</arac_sonucu>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
| İşlem | Türkçe ad | İngilizce ad |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| `a + b` | `topla` | `add` |
|
|
81
|
+
| `a - b` | `cikar` | `sub` |
|
|
82
|
+
| `a × b` | `carp` | `mul` |
|
|
83
|
+
| `a / b` | `bol` | `div` |
|
|
84
|
+
| `a ^ b` | `us` | `pow` |
|
|
85
|
+
| `√a` | `karekok` | `sqrt` |
|
|
86
|
+
| `n!` | `faktoriyel` | `fact` |
|
|
87
|
+
| `C(n,k)` | `kombinasyon` | `comb` |
|
|
88
|
+
| denklem çöz | `coz` | `solve` |
|
|
89
|
+
| serbest ifade | `hesapla` | `calc` |
|
|
90
|
+
|
|
91
|
+
- Türkçe ve İngilizce adların ikisi de çalışır (`execute("add(3, 4)")` = `execute("topla(3, 4)")`).
|
|
92
|
+
- Sonuç kelimeleri: `dogru` / `yanlis` / `bos` / `HATA: ...`.
|
|
93
|
+
- Gruplar: aritmetik, yüzde, sayı teorisi, üs/log, trigonometri, geometri, olasılık/istatistik,
|
|
94
|
+
diziler, cebir, analiz, lineer cebir, fonksiyon tanımlama (`tanimla`).
|
|
95
|
+
- Tam liste: `ethosoft-math protocol`
|
|
96
|
+
|
|
97
|
+
## Komut satırı
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
ethosoft-math calc "4 + 5"
|
|
101
|
+
ethosoft-math exec "carp(topla(3, 4), 2)"
|
|
102
|
+
ethosoft-math protocol > PROTOCOL.md
|
|
103
|
+
ethosoft-math convert in.jsonl out.jsonl --field solution [--lang en] [--aggressive]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Çalışma modları
|
|
107
|
+
|
|
108
|
+
| Mod | Ne yapar |
|
|
109
|
+
|---|---|
|
|
110
|
+
| `convert(text)` (varsayılan) | Yalnızca doğrulanabilen eşitlikleri, denklemleri, eşitsizlikleri, toplamları çevirir |
|
|
111
|
+
| `convert(text, aggressive=True)` | Ek olarak `=` içermeyen salt-sayısal işlemleri de çevirir |
|
|
112
|
+
| `lang="en"` | Etiket ve fonksiyon adlarını İngilizce üretir |
|
|
113
|
+
|
|
114
|
+
## Sınırlar
|
|
115
|
+
|
|
116
|
+
- Python/PoT kodu içeren çözümlere dokunmaz.
|
|
117
|
+
- İspat ve sözel anlatım satırlarında çağrı üretilmez (hesap yoktur).
|
|
118
|
+
- Çeviri modelinden önce çalıştırılmalıdır; araç blokları çeviriden korunmalıdır.
|
|
119
|
+
|
|
120
|
+
Lisans: MIT
|
|
@@ -8,7 +8,10 @@ src/Ethosoft_Math.egg-info/requires.txt
|
|
|
8
8
|
src/Ethosoft_Math.egg-info/top_level.txt
|
|
9
9
|
src/ethosoft_math/__init__.py
|
|
10
10
|
src/ethosoft_math/__main__.py
|
|
11
|
+
src/ethosoft_math/calc.py
|
|
11
12
|
src/ethosoft_math/cli.py
|
|
12
13
|
src/ethosoft_math/converter.py
|
|
13
14
|
src/ethosoft_math/protocol.py
|
|
15
|
+
src/ethosoft_math/runtime.py
|
|
16
|
+
src/ethosoft_math/tooluse.py
|
|
14
17
|
tests/test_basic.py
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""Ethosoft-Math: matematik cozumlerini dogrulanmis tool-use izlerine ceviren kutuphane.
|
|
2
|
+
|
|
3
|
+
>>> import ethosoft_math as em
|
|
4
|
+
>>> em.convert("Toplam 3 + 4 = 7 elma.")
|
|
5
|
+
'Toplam <arac_cagrisi>topla(3, 4)</arac_cagrisi><arac_sonucu>7</arac_sonucu> elma.'
|
|
6
|
+
>>> em.execute("topla(3, 4)")
|
|
7
|
+
'7'
|
|
8
|
+
>>> em.calculate("4 + 5")
|
|
9
|
+
'9'
|
|
10
|
+
"""
|
|
11
|
+
from .protocol import ( # noqa: F401
|
|
12
|
+
CALL_OPEN, CALL_CLOSE, RES_OPEN, RES_CLOSE, REG, ToolError, TR_NAMES, EN_NAMES,
|
|
13
|
+
execute, parse_call, run, render_protocol_md, localize, delocalize, set_language,
|
|
14
|
+
)
|
|
15
|
+
from .calc import calculate, evaluate # noqa: F401
|
|
16
|
+
from .tooluse import tool_use # noqa: F401
|
|
17
|
+
from .runtime import fill_results, result_block # noqa: F401
|
|
18
|
+
from .converter import convert_text, verify_converted # noqa: F401
|
|
19
|
+
|
|
20
|
+
__version__ = "0.4.0"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def convert(text: str, aggressive: bool = False, lang: str = None) -> str:
|
|
24
|
+
"""Metindeki dogrulanabilir hesaplari arac cagrilarina cevirir; sadece metni dondurur.
|
|
25
|
+
lang: 'tr' (varsayilan, <arac_cagrisi>/topla) veya 'en' (<tool_call>/add)."""
|
|
26
|
+
return convert_text(text, aggressive=aggressive, lang=lang)[0]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def verify(text: str):
|
|
30
|
+
"""Metindeki her arac cagrisini yeniden calistirir; (toplam, hatali) dondurur."""
|
|
31
|
+
return verify_converted(text)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def functions():
|
|
35
|
+
"""Protokoldeki fonksiyonlar: {ad: {cat, sig, doc}}"""
|
|
36
|
+
return {k: {"cat": v["cat"], "sig": v["sig"], "doc": v["doc"]} for k, v in REG.items()}
|