Customise a model from the portal: a file, a model, a button
A page for anyone in a project, built for the one who knows least: an Excel, CSV or JSONL file of questions and answers, previewed; a model; a name; who may use it; and a button. The weights to train on are found from where the model's came (a GGUF repository's base model), the card's memory from their size, the node as the one with the most free. When it is done the adapter is published by itself (a llama.cpp model's replicas replaced to load it) and is a model of its own in the chat and the API. The project's by default; its members share it wider (confirmed, and never wider than the knowledge bases its pairs came from) or delete it. One trains at a time per project. ctl train start needs only --model and --data now, and --publish publishes when done. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fcda4d3f85
commit
a53b2f4be9
33 files changed
+2199
-134
No files matched your search
@@ -7,6 +7,7 @@ import (
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -321,3 +322,25 @@ func TestHelpersWhenInstalled(t *testing.T) {
|
||||
}
|
||||
wants(t, got, "LibreOffice yolu")
|
||||
}
|
||||
|
||||
func TestWorkbookRowsKeepTheirColumns(t *testing.T) {
|
||||
b := zipOf(t,
|
||||
"xl/workbook.xml", `<workbook xmlns:r="r"><sheets><sheet name="Sorular" sheetId="1" r:id="rId1"/></sheets></workbook>`,
|
||||
"xl/_rels/workbook.xml.rels", `<Relationships><Relationship Id="rId1" Target="worksheets/sheet1.xml"/></Relationships>`,
|
||||
"xl/sharedStrings.xml", `<sst><si><t>Soru</t></si><si><t>Cevap</t></si><si><t>İzin kaç gün?</t></si></sst>`,
|
||||
"xl/worksheets/sheet1.xml", `<worksheet><sheetData>`+
|
||||
`<row r="1"><c r="A1" t="s"><v>0</v></c><c r="B1" t="s"><v>1</v></c></row>`+
|
||||
`<row r="2"/>`+
|
||||
`<row r="3"><c r="A3" t="s"><v>2</v></c><c r="C3" t="inlineStr"><is><t>not</t></is></c></row>`+
|
||||
`<row r="4"><c r="B4"><v>20</v></c></row>`+
|
||||
`</sheetData></worksheet>`,
|
||||
)
|
||||
rows, err := XLSXRows(b)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want := [][]string{{"Soru", "Cevap"}, {"İzin kaç gün?", "", "not"}, {"", "20"}}
|
||||
if !reflect.DeepEqual(rows, want) {
|
||||
t.Errorf("rows = %q, want %q", rows, want)
|
||||
}
|
||||
}
|
||||
+114
-23
@@ -9,6 +9,7 @@ import (
|
||||
"io"
|
||||
"path"
|
||||
"regexp"
|
||||
"slices"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -227,29 +228,7 @@ func xlsxText(b []byte) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
var shared []string
|
||||
if ss, _ := member(zr, "xl/sharedStrings.xml"); ss != nil {
|
||||
var cur strings.Builder
|
||||
inT, inRPh := false, 0
|
||||
_ = walkXML(ss, func(e xmlEvent) {
|
||||
switch {
|
||||
case e.start && e.name == "si":
|
||||
cur.Reset()
|
||||
case e.end && e.name == "si":
|
||||
shared = append(shared, cur.String())
|
||||
case e.start && e.name == "rPh":
|
||||
inRPh++ // phonetic guides, not the cell's text
|
||||
case e.end && e.name == "rPh":
|
||||
inRPh--
|
||||
case e.start && e.name == "t":
|
||||
inT = true
|
||||
case e.end && e.name == "t":
|
||||
inT = false
|
||||
case !e.start && !e.end && inT && inRPh == 0:
|
||||
cur.WriteString(e.text)
|
||||
}
|
||||
})
|
||||
}
|
||||
shared := xlsxShared(zr)
|
||||
sheets, err := xlsxSheets(zr)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -307,6 +286,118 @@ func xlsxText(b []byte) (string, error) {
|
||||
return o.String(), nil
|
||||
}
|
||||
|
||||
// xlsxShared is a workbook's shared strings, which cells name by index.
|
||||
func xlsxShared(zr *zip.Reader) []string {
|
||||
var shared []string
|
||||
ss, _ := member(zr, "xl/sharedStrings.xml")
|
||||
if ss == nil {
|
||||
return nil
|
||||
}
|
||||
var cur strings.Builder
|
||||
inT, inRPh := false, 0
|
||||
_ = walkXML(ss, func(e xmlEvent) {
|
||||
switch {
|
||||
case e.start && e.name == "si":
|
||||
cur.Reset()
|
||||
case e.end && e.name == "si":
|
||||
shared = append(shared, cur.String())
|
||||
case e.start && e.name == "rPh":
|
||||
inRPh++ // phonetic guides, not the cell's text
|
||||
case e.end && e.name == "rPh":
|
||||
inRPh--
|
||||
case e.start && e.name == "t":
|
||||
inT = true
|
||||
case e.end && e.name == "t":
|
||||
inT = false
|
||||
case !e.start && !e.end && inT && inRPh == 0:
|
||||
cur.WriteString(e.text)
|
||||
}
|
||||
})
|
||||
return shared
|
||||
}
|
||||
|
||||
// XLSXRows reads a workbook's first sheet as rows of cells, each cell in
|
||||
// its column (an empty one is ""), for a table such as questions and
|
||||
// answers. Rows with nothing in them are left out.
|
||||
func XLSXRows(b []byte) ([][]string, error) {
|
||||
zr, err := openZip(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
shared := xlsxShared(zr)
|
||||
sheets, err := xlsxSheets(zr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(sheets) == 0 {
|
||||
return nil, errors.New("the workbook has no sheets")
|
||||
}
|
||||
data, err := member(zr, sheets[0].path)
|
||||
if err != nil || data == nil {
|
||||
return nil, fmt.Errorf("the workbook's first sheet, %s, could not be read", sheets[0].name)
|
||||
}
|
||||
var rows [][]string
|
||||
var row []string
|
||||
var cell strings.Builder
|
||||
cellType, col, next := "", 0, 0
|
||||
inV, inIs := false, false
|
||||
_ = walkXML(data, func(e xmlEvent) {
|
||||
switch {
|
||||
case e.start && e.name == "row":
|
||||
row, next = nil, 0
|
||||
case e.end && e.name == "row":
|
||||
if slices.ContainsFunc(row, func(s string) bool { return s != "" }) {
|
||||
rows = append(rows, row)
|
||||
}
|
||||
case e.start && e.name == "c":
|
||||
cellType = e.get("t")
|
||||
col = next
|
||||
if c, ok := columnOf(e.get("r")); ok {
|
||||
col = c
|
||||
}
|
||||
next = col + 1
|
||||
cell.Reset()
|
||||
case e.end && e.name == "c":
|
||||
v := cell.String()
|
||||
if cellType == "s" {
|
||||
if i, err := strconv.Atoi(strings.TrimSpace(v)); err == nil && i >= 0 && i < len(shared) {
|
||||
v = shared[i]
|
||||
}
|
||||
}
|
||||
if col < 0 || col > 16383 {
|
||||
return
|
||||
}
|
||||
for len(row) <= col {
|
||||
row = append(row, "")
|
||||
}
|
||||
row[col] = strings.TrimSpace(v)
|
||||
case e.start && e.name == "v":
|
||||
inV = true
|
||||
case e.end && e.name == "v":
|
||||
inV = false
|
||||
case e.start && e.name == "is":
|
||||
inIs = true
|
||||
case e.end && e.name == "is":
|
||||
inIs = false
|
||||
case !e.start && !e.end && (inV || inIs):
|
||||
cell.WriteString(e.text)
|
||||
}
|
||||
})
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
// columnOf is a cell reference's column, from 0: "B7" is 1.
|
||||
func columnOf(ref string) (int, bool) {
|
||||
n, i := 0, 0
|
||||
for ; i < len(ref) && ref[i] >= 'A' && ref[i] <= 'Z'; i++ {
|
||||
n = n*26 + int(ref[i]-'A'+1)
|
||||
}
|
||||
if i == 0 {
|
||||
return 0, false
|
||||
}
|
||||
return n - 1, true
|
||||
}
|
||||
|
||||
type sheetRef struct{ name, path string }
|
||||
|
||||
// xlsxSheets lists a workbook's sheets in their order, with the part each is
|
||||
|
||||
Reference in new issue
Block a user