Go: format code (#16813)

### Summary

Aligned to EE

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-07-10 20:30:00 +08:00
committed by GitHub
parent 106c2d0a41
commit 0aa2993d55
27 changed files with 172 additions and 126 deletions

View File

@@ -1169,3 +1169,7 @@ func (s *Service) RemoveIngestionTasksByCondition(tasks []string, email, status
return []map[string]interface{}{element}, nil
}
func CheckLicense() (common.ErrorCode, string) {
return common.CodeLicenseValid, ""
}

View File

@@ -1677,8 +1677,9 @@ func (s *Service) HandleHeartbeat(message *common.BaseMessage) (common.ErrorCode
Timestamp: message.Timestamp,
Ext: message.Ext,
}
GlobalServerStore.UpdateServerInfo(message.ServerName, status)
return common.CodeLicenseValid, ""
return CheckLicense()
}
// InitDefaultAdmin initialize default admin user

View File

@@ -23,7 +23,6 @@
// (value.type starts with "file") emit a stable "<file:key>" stub
// so the run keeps flowing while the FileService integration
// surfaces the actual bytes via the storage layer.
//
package component
import (
@@ -53,7 +52,6 @@ const fileStubPrefix = "<file:"
var tipsPlaceholderPattern = regexp.MustCompile(`\{\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}`)
// userFillUpParam is the per-instance configuration for UserFillUp.
//
type userFillUpParam struct {
EnableTips bool `json:"enable_tips"`
Tips string `json:"tips"`

View File

@@ -310,8 +310,8 @@ func formatAkShareArticles(articles []akshareArticle) string {
for _, item := range articles {
parts = append(parts, fmt.Sprintf(
`<a href="%s">%s</a>
新闻内容: %s
发布时间:%s
新闻内容: %s
发布时间:%s
文章来源: %s`,
item.URL,
item.Title,

View File

@@ -107,4 +107,4 @@ int DartsTrie::Get(std::string_view key) const {
key = empty_null_terminated_sv;
}
return darts_->exactMatchSearch<DartsCore::value_type>(key.data(), key.size());
}
}

View File

@@ -439,4 +439,4 @@ int main() {
// test_fine_grained_tokenize_consistency_with_python();
test_tokenize_text("在本研究中我们提出了一种novel的neural network架构用于解决multi-modal learning问题。我们的方法结合了CNN(Convolutional Neural Networks)和Transformer的优势在ImageNet数据集上达到了state-of-the-art性能。实验结果表明在batch size为256、learning rate为0.001的条件下我们的模型在validation set上的accuracy达到了95.7%比baseline方法提高了3.2%。此外我们还进行了ablation study来分析不同components的contribution。所有代码已在GitHub上开源地址是https://github.com/example/our-project。未来工作将集中在model compression和real-time inference optimization上。");
return 0;
}
}

View File

@@ -43,7 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
#define PCRE2_MAJOR 10
#define PCRE2_MINOR 47
#define PCRE2_PRERELEASE
#define PCRE2_PRERELEASE
#define PCRE2_DATE 2025-10-21
/* When an application links to a PCRE2 DLL in Windows, the symbols that are

View File

@@ -2450,4 +2450,4 @@ int RAGAnalyzer::AnalyzeImpl(const Term &input, void *data, bool fine_grained, b
}
}
return 0;
}
}

View File

@@ -114,28 +114,28 @@ void RAGAnalyzer_SetEnablePosition(RAGAnalyzerHandle handle, bool enable_positio
int RAGAnalyzer_Analyze(RAGAnalyzerHandle handle, const char* text, RAGTokenCallback callback) {
if (!handle || !text || !callback) return -1;
fprintf(stderr, "[C_API] Analyze called with text length: %zu\n", strlen(text));
RAGAnalyzer* analyzer = static_cast<RAGAnalyzer*>(handle);
Term input;
input.text_ = std::string(text);
TermList output;
int ret = analyzer->Analyze(input, output);
fprintf(stderr, "[C_API] Analyze returned: %d, tokens: %zu\n", ret, output.size());
if (ret != 0) {
return ret;
}
// Call callback for each token
for (const auto& term : output) {
callback(term.text_.c_str(), term.text_.length(), term.word_offset_, term.end_offset_);
}
return 0;
}
@@ -144,13 +144,13 @@ char* RAGAnalyzer_Tokenize(RAGAnalyzerHandle handle, const char* text) {
fprintf(stderr, "[C_API] Tokenize called with null handle or text\n");
return nullptr;
}
fprintf(stderr, "[C_API] Tokenize called with text length: %zu\n", strlen(text));
RAGAnalyzer* analyzer = static_cast<RAGAnalyzer*>(handle);
std::string result = analyzer->Tokenize(std::string(text));
// Allocate memory for C string
char* c_result = static_cast<char*>(DEBUG_MALLOC(result.size() + 1));
if (c_result) {

View File

@@ -8,38 +8,38 @@
// Test case 1: Single thread, loop 1000 times
void test_single_thread() {
std::cout << "Test 1: Single thread, 1000 iterations..." << std::endl;
// Create analyzer instance
RAGAnalyzerHandle handle = RAGAnalyzer_Create("./resource");
assert(handle != nullptr && "Failed to create RAGAnalyzer");
// Load the analyzer
int result = RAGAnalyzer_Load(handle);
if (result != 0) {
printf("Failed to load RAGAnalyzer: %d\n", result);
}
assert(result == 0 && "Failed to load RAGAnalyzer");
const char* input = "rag";
bool all_passed = true;
for (int i = 0; i < 1000; ++i) {
char* tokens = RAGAnalyzer_Tokenize(handle, input);
if (tokens == nullptr || strlen(tokens) == 0) {
std::cerr << "Iteration " << i << ": Failed - returned empty or null string" << std::endl;
all_passed = false;
}
// Free the returned string
if (tokens != nullptr) {
free(tokens);
}
}
// Destroy analyzer instance
RAGAnalyzer_Destroy(handle);
if (all_passed) {
std::cout << "Test 1: PASSED" << std::endl;
} else {
@@ -51,32 +51,32 @@ void test_single_thread() {
// Test case 2: 16 threads, each loop 1000 times
void test_multi_thread() {
std::cout << "Test 2: 32 threads, each 100000 iterations..." << std::endl;
// Create analyzer instance (shared across threads)
RAGAnalyzerHandle handle = RAGAnalyzer_Create(".");
assert(handle != nullptr && "Failed to create RAGAnalyzer");
// Load the analyzer
int result = RAGAnalyzer_Load(handle);
assert(result == 0 && "Failed to load RAGAnalyzer");
const char* input = "rag";
const int num_threads = 32;
const int iterations_per_thread = 100000;
std::vector<std::thread> threads;
std::vector<bool> thread_results(num_threads, true);
for (int t = 0; t < num_threads; ++t) {
threads.emplace_back([&, t]() {
for (int i = 0; i < iterations_per_thread; ++i) {
char* tokens = RAGAnalyzer_Tokenize(handle, input);
if (tokens == nullptr || strlen(tokens) == 0) {
std::cerr << "Thread " << t << " Iteration " << i << ": Failed - returned empty or null string" << std::endl;
thread_results[t] = false;
}
// Free the returned string
if (tokens != nullptr) {
free(tokens);
@@ -84,15 +84,15 @@ void test_multi_thread() {
}
});
}
// Wait for all threads to complete
for (auto& t : threads) {
t.join();
}
// Destroy analyzer instance
RAGAnalyzer_Destroy(handle);
bool all_passed = true;
for (int t = 0; t < num_threads; ++t) {
if (!thread_results[t]) {
@@ -100,7 +100,7 @@ void test_multi_thread() {
break;
}
}
if (all_passed) {
std::cout << "Test 2: PASSED" << std::endl;
} else {
@@ -115,7 +115,7 @@ int main() {
test_single_thread();
// test_multi_thread();
std::cout << "=== All tests PASSED ===" << std::endl;
return 0;
}

View File

@@ -21,4 +21,4 @@ void Term::Reset() {
word_offset_ = 0;
}
Term TermList::global_temporary_;
Term TermList::global_temporary_;

View File

@@ -165,7 +165,7 @@ struct Tok2vecModel {
int po_nO=96,po_nP=3,po_nI=576;
struct ResBlk{bool has=false;std::vector<float>W,b,lnG,lnb;};
ResBlk res[4]; int n_res=0;
bool load(const std::string& dir) {
std::ifstream cf(dir+"/model.ckpt"); if(!cf)return false;
std::stringstream cb;cb<<cf.rdbuf();
@@ -206,7 +206,7 @@ struct Tok2vecModel {
if(ld(pk+"W",&rb.W,&r0,&r1,&r2)){ld(pk+"B",&rb.b);ld(pk+"lnG",&rb.lnG);ld(pk+"lnb",&rb.lnb);rb.has=true;n_res++;}}
return!embeds.empty();
}
// Run tok2vec → (n_tokens, 96)
void forward(const std::vector<std::string>& tokens, float* out) {
int n=(int)tokens.size(),D=96,NE=(int)embeds.size(),EC=NE*D;
@@ -241,7 +241,7 @@ struct ParserModel {
std::vector<float> pW_pre,pb_pre,pad_pre; // preaffine
std::vector<float> pW_cls,pb_cls; // classifier
std::vector<std::string> move_names;
bool load(const std::string& dir) {
std::ifstream cf(dir+"/model.ckpt"); if(!cf)return false;
std::stringstream cb;cb<<cf.rdbuf();
@@ -275,7 +275,7 @@ struct ParserModel {
if(mn&&mn->type==JVal::ARR)for(auto& v:mn->arr)move_names.push_back(v.str);}
return!pW_hid.empty() && !pW_pre.empty() && !pW_cls.empty();
}
// Run parser forward + state machine → (heads, labels)
void parse(const float* tokvecs, int n_tokens,
std::vector<int>& out_heads, std::vector<std::string>& out_labels) {
@@ -283,7 +283,7 @@ struct ParserModel {
std::vector<float> hidden((size_t)n_tokens*nO,0);
for(int i=0;i<n_tokens;i++) linear(hidden.data()+(size_t)i*nO, tokvecs+(size_t)i*96,
pW_hid.data(), pb_hid.data(), nO, 96);
// 2. Pre-compute features
std::vector<float> precomp((size_t)(n_tokens+1)*nP*nO*nI,0);
// Pad token (index 0)
@@ -304,20 +304,20 @@ struct ParserModel {
}
}
}
// Helper: get feature value for a token at piece p, window w, output dim o
auto feat = [&](int idx, int p, int w, int o) -> float {
int ri = (idx < 0 || idx >= n_tokens) ? 0 : idx + 1;
return precomp[(size_t)ri*nP*nO*nI + (size_t)p*nO*nI + (size_t)w + (size_t)o*nI];
};
// 3. Arc-hybrid state machine
out_heads.assign(n_tokens, -1);
out_labels.assign(n_tokens, "");
std::vector<int> stack;
std::vector<int> buffer(n_tokens);
for(int i=0;i<n_tokens;i++) buffer[i]=i;
// Validate move_names covers all actions before indexing
if((int)move_names.size()!=n_actions){out_heads.clear();out_labels.clear();return;}
int act_S=-1, act_D=-1;
@@ -325,7 +325,7 @@ struct ParserModel {
if(move_names[i]=="S") act_S=i;
if(move_names[i]=="D") act_D=i;
}
auto leftmost = [&](int idx)->int{
for(int i=0;i<n_tokens;i++) if(out_heads[i]==idx) return i;
return -1;
@@ -334,21 +334,21 @@ struct ParserModel {
int r=-1; for(int i=0;i<n_tokens;i++) if(out_heads[i]==idx) r=i;
return r;
};
std::vector<float> scores(n_actions,0);
std::vector<float> feats(nP*nI*nO,0);
for(int step=0; step<n_tokens*4 && !(buffer.empty()&&stack.size()<=1); step++){
int s0=stack.empty()?-1:stack.back();
int s1=stack.size()<2?-1:stack[stack.size()-2];
int s2=stack.size()<3?-1:stack[stack.size()-3];
int b0=buffer.empty()?-1:buffer[0];
int b1=buffer.size()<2?-1:buffer[1];
// Build feature indices (same as verified Python implementation)
int idxs[16]={s0,s1, b0,s0, s0,leftmost(s0), s0,rightmost(s0),
s1,leftmost(s1), s1,rightmost(s1), s2,b1, b0,b1};
// Build feature vector: sum of precomputed features at each (idx, piece, window)
for(int o=0;o<nO;o++) feats[o]=0;
for(int p=0;p<nP;p++){
@@ -359,7 +359,7 @@ struct ParserModel {
}
}
}
// Classify
for(int a=0;a<n_actions;a++){
float s=pb_cls[a];
@@ -368,7 +368,7 @@ struct ParserModel {
for(int j=0;j<nO;j++) s += pW_cls[(size_t)a*nO+j] * hidden[(size_t)cls_idx*nO+j];
scores[a]=s;
}
// Pick best VALID action
int best=-1; float best_sc=-1e30f;
for(int a=0;a<n_actions;a++){
@@ -380,7 +380,7 @@ struct ParserModel {
if(valid && scores[a]>best_sc){best_sc=scores[a];best=a;}
}
if(best<0) break;
const std::string& act=move_names[best];
if(act=="S"){stack.push_back(buffer[0]);buffer.erase(buffer.begin());}
else if(act=="D"){stack.pop_back();}
@@ -432,23 +432,23 @@ void ThincParser_Destroy(ThincParserHandle h) { delete (ParserState*)h; }
char* ThincParser_Predict(ThincParserHandle h, const char* tokens_json) {
auto* s=(ParserState*)h;
if(!s||!s->loaded||!tokens_json) return strdup("[]");
auto j=JParser().parse(std::string(tokens_json));
if(j.type!=JVal::ARR) return strdup("[]");
std::vector<std::string> tokens;
for(auto& v:j.arr) tokens.push_back(v.str);
int n=(int)tokens.size();
if(!n) return strdup("[]");
// Run tok2vec
std::vector<float> tokvecs((size_t)n*96,0);
s->tok2vec.forward(tokens, tokvecs.data());
// Run parser
std::vector<int> heads;
std::vector<std::string> labels;
s->parser.parse(tokvecs.data(), n, heads, labels);
// Build JSON output
std::string r="[";
for(int i=0;i<n;i++){
@@ -507,11 +507,11 @@ char* ThincTagger_Predict(ThincTaggerHandle h, const char* tokens_json) {
for(auto& v:j.arr) tokens.push_back(v.str);
int n=(int)tokens.size(), n_tags=(int)s->tW.size()/96;
if(!n||!n_tags)return strdup("[]");
// Run tok2vec to get 96-dim embeddings, then softmax + argmax
std::vector<float> tokvecs((size_t)n*96,0);
s->tok2vec.forward(tokens, tokvecs.data());
std::vector<int> best_tags(n, 0);
for(int i=0;i<n;i++){
float best_sc=-1e30f;
@@ -521,7 +521,7 @@ char* ThincTagger_Predict(ThincTaggerHandle h, const char* tokens_json) {
if(sc>best_sc){best_sc=sc;best_tags[i]=t;}
}
}
// Strip morphologizer output to just POS (e.g. "Gender=Masc|Number=Sing|POS=NOUN" → "NOUN")
// For non-morphologizer models the tag string is used as-is.
auto pos_only = [](const std::string& t) -> std::string {

View File

@@ -312,4 +312,4 @@ bool Tokenizer::TokenizeWhite(const std::string &input_string, TermList &raw_ter
}
return true;
}
}

View File

@@ -229,4 +229,4 @@ std::string WordNetLemmatizer::Lemmatize(const std::string &form, const std::str
}
return form;
}
}

View File

@@ -75,9 +75,9 @@ func (dao *DocumentDAO) IncrementCounts(id string, kbID string, chunkNum int64,
return DB.Model(&entity.Document{}).
Where("id = ? AND kb_id = ?", id, kbID).
Updates(map[string]interface{}{
"chunk_num": gorm.Expr("chunk_num + ?", chunkNum),
"token_num": gorm.Expr("token_num + ?", tokenNum),
"process_duration": gorm.Expr("process_duration + ?", duration),
"chunk_num": gorm.Expr("chunk_num + ?", chunkNum),
"token_num": gorm.Expr("token_num + ?", tokenNum),
"process_duration": gorm.Expr("process_duration + ?", duration),
}).Error
}

View File

@@ -66,8 +66,10 @@ func (p *Parser) ocrDetectAndRecognize(ctx context.Context, pageImg image.Image,
for _, t := range texts {
if strings.TrimSpace(t.Text) != "" {
result = append(result, pdf.TextBox{
X0: px0, X1: px1,
Top: py0, Bottom: py1,
X0: px0,
X1: px1,
Top: py0,
Bottom: py1,
Text: t.Text,
PageNumber: pageNum,
})

View File

@@ -1,4 +1,3 @@
package table
import (
@@ -17,7 +16,7 @@ func TestGroupBoxesByRC_RDiffSplitsRows(t *testing.T) {
{X0: 210, X1: 290, Top: 0, Bottom: 30, Text: "C", R: 2, C: 2},
{X0: 10, X1: 90, Top: 35, Bottom: 65, Text: "D", R: 3, C: 0},
{X0: 110, X1: 190, Top: 35, Bottom: 65, Text: "E", R: 4, C: 1},
{X0: 210, X1: 290, Top: 35, Bottom: 65, Text: "F", R: 5, C: 2},
{X0: 210, X1: 290, Top: 35, Bottom: 65, Text: "F", R: 5, C: 2},
}
rows := GroupBoxesByRC(boxes)
// R=0,1,2,3,4,5 → 6 rows (Python: R differs → new row).

View File

@@ -19,9 +19,13 @@ func RowsToHTML(rows [][]pdf.TSRCell, caption string, headerRows map[int]bool, s
for ri, row := range rows {
b.WriteString("<tr>")
for ci, cell := range row {
if covered[[2]int{ri, ci}] { continue }
if covered[[2]int{ri, ci}] {
continue
}
tag := "td"
if headerRows[ri] { tag = "th" }
if headerRows[ri] {
tag = "th"
}
b.WriteString("<")
b.WriteString(tag)
sp := ""
@@ -30,7 +34,9 @@ func RowsToHTML(rows [][]pdf.TSRCell, caption string, headerRows map[int]bool, s
sp = fmt.Sprintf("colspan=%d", s[0])
}
if s[1] > 1 {
if sp != "" { sp += " " }
if sp != "" {
sp += " "
}
sp += fmt.Sprintf("rowspan=%d", s[1])
}
}
@@ -59,17 +65,23 @@ func SimpleRowsToHTML(rows [][]string) string {
}
nCols := 0
for _, row := range rows {
if len(row) > nCols { nCols = len(row) }
if len(row) > nCols {
nCols = len(row)
}
}
var b strings.Builder
b.WriteString("<table>")
for ri, row := range rows {
b.WriteString("<tr>")
tag := "td"
if ri == 0 { tag = "th" }
if ri == 0 {
tag = "th"
}
for ci := 0; ci < nCols; ci++ {
text := ""
if ci < len(row) { text = row[ci] }
if ci < len(row) {
text = row[ci]
}
b.WriteString("<")
b.WriteString(tag)
b.WriteString(" >")
@@ -98,7 +110,9 @@ func RowsToStrings(rows [][]pdf.TSRCell) [][]string {
func HasText(rows [][]pdf.TSRCell) bool {
for _, row := range rows {
for _, c := range row {
if strings.TrimSpace(c.Text) != "" { return true }
if strings.TrimSpace(c.Text) != "" {
return true
}
}
}
return false
@@ -106,7 +120,9 @@ func HasText(rows [][]pdf.TSRCell) bool {
func HasAnyText(cells []pdf.TSRCell) bool {
for _, c := range cells {
if strings.TrimSpace(c.Text) != "" { return true }
if strings.TrimSpace(c.Text) != "" {
return true
}
}
return false
}

View File

@@ -1,4 +1,3 @@
package table
import (

View File

@@ -1,4 +1,3 @@
package table
import (
@@ -125,4 +124,3 @@ func MergeTablesAcrossPages(tables []pdf.TableItem, medianHeights map[int]float6
}
return result
}

View File

@@ -12,7 +12,9 @@ import (
func CalSpans(rows [][]pdf.TSRCell) (map[[2]int][2]int, map[[2]int]bool) {
spanInfo := make(map[[2]int][2]int)
covered := make(map[[2]int]bool)
if len(rows) == 0 || len(rows[0]) == 0 { return spanInfo, covered }
if len(rows) == 0 || len(rows[0]) == 0 {
return spanInfo, covered
}
// Compute column center positions.
nCols := len(rows[0])
@@ -32,40 +34,64 @@ func CalSpans(rows [][]pdf.TSRCell) (map[[2]int][2]int, map[[2]int]bool) {
for i, row := range rows {
for j, cell := range row {
if j >= nCols { continue }
if j >= nCols {
continue
}
// Exclude spanning cells from column/row boundary calculations.
// Use label-based detection (O(1), no dependency on column midpoints).
if strings.Contains(cell.Label, "spanning") { continue }
if cell.X0 < colLeft[j] { colLeft[j] = cell.X0 }
if cell.X1 > colRight[j] { colRight[j] = cell.X1 }
if cell.Y0 < rowTop[i] { rowTop[i] = cell.Y0 }
if cell.Y1 > rowBott[i] { rowBott[i] = cell.Y1 }
if strings.Contains(cell.Label, "spanning") {
continue
}
if cell.X0 < colLeft[j] {
colLeft[j] = cell.X0
}
if cell.X1 > colRight[j] {
colRight[j] = cell.X1
}
if cell.Y0 < rowTop[i] {
rowTop[i] = cell.Y0
}
if cell.Y1 > rowBott[i] {
rowBott[i] = cell.Y1
}
}
}
// For each spanning cell, compute how many cols/rows it covers.
for i, row := range rows {
for j, cell := range row {
if j >= nCols || covered[[2]int{i,j}] { continue }
if j >= nCols || covered[[2]int{i, j}] {
continue
}
// Skip cells without position data (they can't span).
if cell.X0 == 0 && cell.X1 == 0 && cell.Y0 == 0 && cell.Y1 == 0 { continue }
if cell.X0 == 0 && cell.X1 == 0 && cell.Y0 == 0 && cell.Y1 == 0 {
continue
}
cs, rs := 1, 1
// Count columns whose center is inside this cell's X range.
for k := j+1; k < nCols; k++ {
for k := j + 1; k < nCols; k++ {
// Skip columns with no non-spanning cells (initial values unchanged).
if colLeft[k] == 1e9 && colRight[k] == -1e9 { continue }
if colLeft[k] == 1e9 && colRight[k] == -1e9 {
continue
}
colCenter := (colLeft[k] + colRight[k]) / 2
if colCenter >= cell.X0 && colCenter <= cell.X1 { cs++ }
if colCenter >= cell.X0 && colCenter <= cell.X1 {
cs++
}
}
// Count rows whose center is inside this cell's Y range.
for k := i+1; k < nRows; k++ {
for k := i + 1; k < nRows; k++ {
// Skip rows with no non-spanning cells.
if rowTop[k] == 1e9 && rowBott[k] == -1e9 { continue }
if rowTop[k] == 1e9 && rowBott[k] == -1e9 {
continue
}
rowCenter := (rowTop[k] + rowBott[k]) / 2
if rowCenter >= cell.Y0 && rowCenter <= cell.Y1 { rs++ }
if rowCenter >= cell.Y0 && rowCenter <= cell.Y1 {
rs++
}
}
if cs > 1 || rs > 1 {
spanInfo[[2]int{i,j}] = [2]int{cs, rs}
spanInfo[[2]int{i, j}] = [2]int{cs, rs}
// Mark covered cells.
for ri := i; ri < i+rs && ri < nRows; ri++ {
for cj := j; cj < j+cs && cj < nCols; cj++ {
@@ -83,8 +109,12 @@ func CalSpans(rows [][]pdf.TSRCell) (map[[2]int][2]int, map[[2]int]bool) {
// flattenGrid flattens a 2D grid into a 1D slice for fillCellTextFromBoxes.
func FlattenGrid(grid [][]pdf.TSRCell) []pdf.TSRCell {
n := 0
for _, row := range grid { n += len(row) }
for _, row := range grid {
n += len(row)
}
flat := make([]pdf.TSRCell, 0, n)
for _, row := range grid { flat = append(flat, row...) }
for _, row := range grid {
flat = append(flat, row...)
}
return flat
}

View File

@@ -1,4 +1,3 @@
package table
import (

View File

@@ -725,7 +725,7 @@ idle ──beginPlanningTurn──▶ planning ──beginActiveTurn──▶ ac
- **TurnContext** — per-turn Preempted/Stopped channels, StopCause
- **Callbacks**: `GenInput`, `GenResume`, `PrepareAgent`, `OnAgentEvents`
**Push options:** `WithPreempt`, `WithPreemptTimeout`, `WithPreemptDelay`
**Push options:** `WithPreempt`, `WithPreemptTimeout`, `WithPreemptDelay`
**Stop options:** `WithGraceful`, `WithImmediate`, `WithGracefulTimeout`, `UntilIdleFor`, `WithSkipCheckpoint`, `WithStopCause`
---

View File

@@ -48,7 +48,7 @@ type Engine struct {
versionsSeen map[string]map[string]int
cache Cache
backgroundExec *BackgroundExecutor
callbacks *CallbackManager // lifecycle callbacks (event recording, metrics)
callbacks *CallbackManager // lifecycle callbacks (event recording, metrics)
deferredCheckpoints []deferredCheckpoint // for DurabilityExit mode
}

View File

@@ -9,7 +9,6 @@ import (
"strings"
)
// Verb lemmatization — multi-language
var verbLemma = map[string]string{
// English

View File

@@ -21,10 +21,11 @@ package task
// every 5 elements. pn is 0-indexed; output is 1-indexed.
//
// Mirrors Python: rag.nlp.add_positions()
// for pn, left, right, top, bottom in poss:
// page_num_int.append(int(pn + 1))
// top_int.append(int(top))
// position_int.append((int(pn + 1), int(left), int(right), int(top), int(bottom)))
//
// for pn, left, right, top, bottom in poss:
// page_num_int.append(int(pn + 1))
// top_int.append(int(top))
// position_int.append((int(pn + 1), int(left), int(right), int(top), int(bottom)))
func AddPositions(chunk map[string]any, positions []float64) {
if len(positions) == 0 || len(positions)%5 != 0 {
return

View File

@@ -69,18 +69,18 @@ func GetParserByID(parserID string) (ParseResultProducer, error) {
}
// Stub constructors for each parser type.
func NewNaivePDFParser() *stubParser { return &stubParser{name: "naive"} }
func NewPaperPDFParser() *stubParser { return &stubParser{name: "paper"} }
func NewBookPDFParser() *stubParser { return &stubParser{name: "book"} }
func NewPresentationParser() *stubParser { return &stubParser{name: "presentation"} }
func NewManualPDFParser() *stubParser { return &stubParser{name: "manual"} }
func NewLawsPDFParser() *stubParser { return &stubParser{name: "laws"} }
func NewQAPDFParser() *stubParser { return &stubParser{name: "qa"} }
func NewTableParser() *stubParser { return &stubParser{name: "table"} }
func NewResumePDFParser() *stubParser { return &stubParser{name: "resume"} }
func NewPicturePDFParser() *stubParser { return &stubParser{name: "picture"} }
func NewOnePDFParser() *stubParser { return &stubParser{name: "one"} }
func NewAudioParser() *stubParser { return &stubParser{name: "audio"} }
func NewEmailParser() *stubParser { return &stubParser{name: "email"} }
func NewTagPDFParser() *stubParser { return &stubParser{name: "tag"} }
func NewKGPDFParser() *stubParser { return &stubParser{name: "knowledge_graph"} }
func NewNaivePDFParser() *stubParser { return &stubParser{name: "naive"} }
func NewPaperPDFParser() *stubParser { return &stubParser{name: "paper"} }
func NewBookPDFParser() *stubParser { return &stubParser{name: "book"} }
func NewPresentationParser() *stubParser { return &stubParser{name: "presentation"} }
func NewManualPDFParser() *stubParser { return &stubParser{name: "manual"} }
func NewLawsPDFParser() *stubParser { return &stubParser{name: "laws"} }
func NewQAPDFParser() *stubParser { return &stubParser{name: "qa"} }
func NewTableParser() *stubParser { return &stubParser{name: "table"} }
func NewResumePDFParser() *stubParser { return &stubParser{name: "resume"} }
func NewPicturePDFParser() *stubParser { return &stubParser{name: "picture"} }
func NewOnePDFParser() *stubParser { return &stubParser{name: "one"} }
func NewAudioParser() *stubParser { return &stubParser{name: "audio"} }
func NewEmailParser() *stubParser { return &stubParser{name: "email"} }
func NewTagPDFParser() *stubParser { return &stubParser{name: "tag"} }
func NewKGPDFParser() *stubParser { return &stubParser{name: "knowledge_graph"} }