fabricatio 0.3.14.dev5__tar.gz → 0.3.14.dev8__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.
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/.gitignore +1 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/PKG-INFO +1 -1
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/build.rs +8 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/write_article/write_article.py +11 -4
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/proto/tei.proto +1 -1
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/pyproject.toml +1 -1
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/actions/article_rag.py +5 -14
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/rag.py +30 -29
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/decorators.py +2 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/aricle_rag.py +8 -6
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/article_base.py +3 -3
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/article_main.py +3 -6
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/role.py +24 -20
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/rust.pyi +11 -64
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/src/config.rs +35 -47
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/src/tei_client.rs +2 -2
- fabricatio-0.3.14.dev8/src/templates.rs +217 -0
- fabricatio-0.3.14.dev8/templates.tar.gz +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/uv.lock +107 -104
- fabricatio-0.3.14.dev5/.python-version +0 -1
- fabricatio-0.3.14.dev5/src/templates.rs +0 -166
- fabricatio-0.3.14.dev5/templates.tar.gz +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/.github/workflows/build-package.yaml +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/.github/workflows/ruff.yaml +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/.github/workflows/tests.yaml +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/Cargo.lock +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/Cargo.toml +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/LICENSE +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/Makefile +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/README.md +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/correct/correct.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/correct/correct_loop.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/extract_and_inject/.gitignore +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/extract_and_inject/article_rag.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/extract_and_inject/ask.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/extract_and_inject/chunk_article.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/extract_and_inject/extract_and_inject.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/extract_article/extract.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/llm_usages/llm_usage.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/make_a_rating/rating.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/make_diary/commits.json +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/make_diary/diary.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/minor/hello_fabricatio.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/minor/write_a_poem.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/propose_task/.gitignore +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/propose_task/propose.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/reviewer/censor.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/reviewer/review.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/rules/.gitignore +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/rules/draft_ruleset.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/search_bibtex/.gitignore +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/search_bibtex/search.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/simple_chat/chat.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/simple_rag/simple_rag.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/task_handle/handle_task.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/write_article/.gitignore +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/write_article/article_rag.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/write_article/post_process.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/write_outline/.gitignore +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/write_outline/write_outline.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/examples/write_outline/write_outline_corrected.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/__init__.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/actions/__init__.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/actions/article.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/actions/fs.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/actions/output.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/actions/rag.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/actions/rules.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/__init__.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/advanced_judge.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/advanced_rag.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/censor.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/check.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/correct.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/extract.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/persist.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/propose.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/rating.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/review.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/task.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/emitter.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/fs/__init__.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/fs/curd.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/fs/readers.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/journal.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/action.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/adv_kwargs_types.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/__init__.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/advanced_judge.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/article_essence.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/article_outline.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/article_proposal.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/patches.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/problem.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/rag.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/rule.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/generic.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/kwargs_types.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/task.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/tool.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/usages.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/parser.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/py.typed +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/toolboxes/__init__.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/toolboxes/arithmetic.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/toolboxes/fs.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/utils.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/workflows/__init__.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/workflows/articles.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/workflows/rag.py +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/src/bib_tools.rs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/src/event.rs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/src/hash.rs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/src/hbs_helpers.rs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/src/language.rs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/src/lib.rs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/src/macro_utils/Cargo.toml +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/src/macro_utils/src/lib.rs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/src/typst_conversion/Cargo.toml +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/src/typst_conversion/src/lib.rs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/src/typst_tools.rs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/src/word_split.rs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/as_prompt.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/binary-exploitation-ctf-solver.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/chap_summary.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/check_string.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/claude-xml.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/clean-up-code.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/co_validation.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/create_json_obj.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/cryptography-ctf-solver.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/dependencies.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/document-the-code.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/draft_rating_criteria.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/draft_rating_manual.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/draft_rating_weights_klee.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/draft_tool_usage_code.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/extract.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/extract_criteria_from_reasons.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/extract_reasons_from_examples.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/find-security-vulnerabilities.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/fix-bugs.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/fix_troubled_obj.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/fix_troubled_string.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/generic_string.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/improve-performance.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/liststr.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/make_choice.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/make_judgment.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/pathstr.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/rate_fine_grind.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/refactor.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/refined_query.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/retrieved_display.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/reverse-engineering-ctf-solver.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/review_string.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/rule_requirement.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/ruleset_requirement_breakdown.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/task_briefing.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/web-ctf-solver.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/write-git-commit.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/write-github-pull-request.hbs +0 -0
- {fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/templates/built-in/write-github-readme.hbs +0 -0
@@ -1,3 +1,6 @@
|
|
1
|
+
use std::fs;
|
2
|
+
use std::path::Path;
|
3
|
+
|
1
4
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
2
5
|
tonic_build::configure()
|
3
6
|
.out_dir("src")
|
@@ -5,5 +8,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
5
8
|
.build_server(false)
|
6
9
|
.type_attribute(".", "#[derive(serde::Serialize,serde::Deserialize)]")
|
7
10
|
.compile_protos(&["proto/tei.proto"], &["proto"])
|
11
|
+
.map(|_| {
|
12
|
+
if Path::new("src/tei.v1.rs").exists() {
|
13
|
+
fs::rename("src/tei.v1.rs", "src/tei.rs").expect("Failed to rename file")
|
14
|
+
}
|
15
|
+
})
|
8
16
|
.map_err(|e| e.into())
|
9
17
|
}
|
@@ -5,7 +5,8 @@ from pathlib import Path
|
|
5
5
|
from typing import Optional
|
6
6
|
|
7
7
|
import typer
|
8
|
-
from fabricatio import Event,
|
8
|
+
from fabricatio import Event, WorkFlow, logger
|
9
|
+
from fabricatio import Role as RoleBase
|
9
10
|
from fabricatio.actions.article import (
|
10
11
|
ExtractOutlineFromRaw,
|
11
12
|
GenerateArticleProposal,
|
@@ -18,21 +19,27 @@ from fabricatio.fs import safe_text_read
|
|
18
19
|
from fabricatio.models.extra.article_main import Article
|
19
20
|
from fabricatio.models.extra.article_outline import ArticleOutline
|
20
21
|
from fabricatio.models.task import Task
|
22
|
+
from fabricatio.models.usages import LLMUsage
|
21
23
|
from fabricatio.utils import ok
|
22
24
|
from typer import Typer
|
23
25
|
|
24
26
|
# from pydantic import HttpUrl
|
25
27
|
|
28
|
+
|
29
|
+
class Role(RoleBase, LLMUsage):
|
30
|
+
"""Role class for article writing."""
|
31
|
+
|
32
|
+
|
26
33
|
Role(
|
27
34
|
name="Undergraduate Researcher",
|
28
35
|
description="Write an outline for an article in typst format.",
|
29
|
-
llm_model="openai/
|
30
|
-
|
36
|
+
llm_model="openai/qwen-plus",
|
37
|
+
llm_api_endpoint="https://dashscope.aliyuncs.com/compatible-mode/v1",
|
31
38
|
llm_stream=True,
|
32
39
|
llm_max_tokens=8191,
|
33
40
|
llm_rpm=600,
|
34
41
|
llm_tpm=900000,
|
35
|
-
llm_timeout=
|
42
|
+
llm_timeout=10,
|
36
43
|
registry={
|
37
44
|
Event.quick_instantiate(ns := "article"): WorkFlow(
|
38
45
|
name="Generate Article",
|
@@ -21,10 +21,7 @@ from fabricatio.models.extra.rule import RuleSet
|
|
21
21
|
from fabricatio.models.kwargs_types import ChooseKwargs, LLMKwargs
|
22
22
|
from fabricatio.rust import (
|
23
23
|
BibManager,
|
24
|
-
|
25
|
-
convert_all_inline_tex,
|
26
|
-
convert_to_block_formula,
|
27
|
-
convert_to_inline_formula,
|
24
|
+
convert_all_tex_math,
|
28
25
|
fix_misplaced_labels,
|
29
26
|
)
|
30
27
|
from fabricatio.utils import ok
|
@@ -129,8 +126,7 @@ class WriteArticleContentRAG(Action, Extract, AdvancedRAG):
|
|
129
126
|
raw_paras = edt
|
130
127
|
|
131
128
|
raw_paras = fix_misplaced_labels(raw_paras)
|
132
|
-
raw_paras =
|
133
|
-
raw_paras = convert_all_block_tex(raw_paras)
|
129
|
+
raw_paras = convert_all_tex_math(raw_paras)
|
134
130
|
|
135
131
|
r_print(raw_paras)
|
136
132
|
|
@@ -153,8 +149,7 @@ class WriteArticleContentRAG(Action, Extract, AdvancedRAG):
|
|
153
149
|
raw_paras = "\n".join(p for p in raw_paras.splitlines() if p and not p.endswith("**") and not p.startswith("#"))
|
154
150
|
|
155
151
|
raw_paras = fix_misplaced_labels(raw_paras)
|
156
|
-
raw_paras =
|
157
|
-
raw_paras = convert_all_block_tex(raw_paras)
|
152
|
+
raw_paras = convert_all_tex_math(raw_paras)
|
158
153
|
|
159
154
|
return await self.extract_new_subsec(subsec, raw_paras, cm)
|
160
155
|
|
@@ -261,8 +256,6 @@ class ArticleConsultRAG(Action, AdvancedRAG):
|
|
261
256
|
from questionary import confirm, text
|
262
257
|
from rich import print as r_print
|
263
258
|
|
264
|
-
from fabricatio.rust import convert_all_block_tex, convert_all_inline_tex, fix_misplaced_labels
|
265
|
-
|
266
259
|
self.target_collection = collection_name or self.safe_target_collection
|
267
260
|
|
268
261
|
cm = CitationManager()
|
@@ -272,8 +265,7 @@ class ArticleConsultRAG(Action, AdvancedRAG):
|
|
272
265
|
if await confirm("Empty the cm?").ask_async():
|
273
266
|
cm.empty()
|
274
267
|
|
275
|
-
req =
|
276
|
-
req = convert_to_inline_formula(req)
|
268
|
+
req = convert_all_tex_math(req)
|
277
269
|
|
278
270
|
await self.clued_search(
|
279
271
|
req,
|
@@ -289,8 +281,7 @@ class ArticleConsultRAG(Action, AdvancedRAG):
|
|
289
281
|
ret = await self.aask(f"{cm.as_prompt()}\n{self.req}\n{req}")
|
290
282
|
|
291
283
|
ret = fix_misplaced_labels(ret)
|
292
|
-
ret =
|
293
|
-
ret = convert_all_block_tex(ret)
|
284
|
+
ret = convert_all_tex_math(ret)
|
294
285
|
ret = cm.apply(ret)
|
295
286
|
|
296
287
|
r_print(ret)
|
@@ -51,16 +51,16 @@ class RAG(EmbeddingUsage, ABC):
|
|
51
51
|
return self._client
|
52
52
|
|
53
53
|
def init_client(
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
self,
|
55
|
+
milvus_uri: Optional[str] = None,
|
56
|
+
milvus_token: Optional[str] = None,
|
57
|
+
milvus_timeout: Optional[float] = None,
|
58
58
|
) -> Self:
|
59
59
|
"""Initialize the Milvus client."""
|
60
60
|
self._client = create_client(
|
61
61
|
uri=milvus_uri or ok(self.milvus_uri or CONFIG.rag.milvus_uri),
|
62
62
|
token=milvus_token
|
63
|
-
|
63
|
+
or (token.get_secret_value() if (token := (self.milvus_token or CONFIG.rag.milvus_token)) else ""),
|
64
64
|
timeout=milvus_timeout or self.milvus_timeout or CONFIG.rag.milvus_timeout,
|
65
65
|
)
|
66
66
|
return self
|
@@ -74,7 +74,7 @@ class RAG(EmbeddingUsage, ABC):
|
|
74
74
|
return self
|
75
75
|
|
76
76
|
def view(
|
77
|
-
|
77
|
+
self, collection_name: Optional[str], create: bool = False, **kwargs: Unpack[CollectionConfigKwargs]
|
78
78
|
) -> Self:
|
79
79
|
"""View the specified collection.
|
80
80
|
|
@@ -116,7 +116,7 @@ class RAG(EmbeddingUsage, ABC):
|
|
116
116
|
return ok(self.target_collection, "No collection is being viewed. Have you called `self.view()`?")
|
117
117
|
|
118
118
|
async def add_document[D: MilvusDataBase](
|
119
|
-
|
119
|
+
self, data: List[D] | D, collection_name: Optional[str] = None, flush: bool = False
|
120
120
|
) -> Self:
|
121
121
|
"""Adds a document to the specified collection.
|
122
122
|
|
@@ -143,15 +143,15 @@ class RAG(EmbeddingUsage, ABC):
|
|
143
143
|
return self
|
144
144
|
|
145
145
|
async def afetch_document[D: MilvusDataBase](
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
146
|
+
self,
|
147
|
+
query: List[str],
|
148
|
+
document_model: Type[D],
|
149
|
+
collection_name: Optional[str] = None,
|
150
|
+
similarity_threshold: float = 0.37,
|
151
|
+
result_per_query: int = 10,
|
152
|
+
tei_endpoint: Optional[str] = None,
|
153
|
+
reranker_threshold: float = 0.7,
|
154
|
+
filter_expr: str = "",
|
155
155
|
) -> List[D]:
|
156
156
|
"""Asynchronously fetches documents from a Milvus database based on input vectors.
|
157
157
|
|
@@ -192,7 +192,8 @@ class RAG(EmbeddingUsage, ABC):
|
|
192
192
|
retrieved_id.update(res["id"] for res in g)
|
193
193
|
if not models:
|
194
194
|
continue
|
195
|
-
rank_scores = await reranker.arerank(q, [m.prepare_vectorization() for m in models], truncate=True
|
195
|
+
rank_scores = await reranker.arerank(q, [m.prepare_vectorization() for m in models], truncate=True,
|
196
|
+
truncation_direction="Left")
|
196
197
|
raw_result.extend((models[idx], scr) for (idx, scr) in rank_scores if scr > reranker_threshold)
|
197
198
|
|
198
199
|
raw_result_sorted = sorted(raw_result, key=lambda x: x[1], reverse=True)
|
@@ -214,11 +215,11 @@ class RAG(EmbeddingUsage, ABC):
|
|
214
215
|
return document_model.from_sequence(resp)
|
215
216
|
|
216
217
|
async def aretrieve[D: MilvusDataBase](
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
218
|
+
self,
|
219
|
+
query: List[str] | str,
|
220
|
+
document_model: Type[D],
|
221
|
+
max_accepted: int = 20,
|
222
|
+
**kwargs: Unpack[FetchKwargs],
|
222
223
|
) -> List[D]:
|
223
224
|
"""Retrieve data from the collection.
|
224
225
|
|
@@ -235,15 +236,15 @@ class RAG(EmbeddingUsage, ABC):
|
|
235
236
|
query = [query]
|
236
237
|
|
237
238
|
return (
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
239
|
+
await self.afetch_document(
|
240
|
+
query=query,
|
241
|
+
document_model=document_model,
|
242
|
+
**kwargs,
|
243
|
+
)
|
244
|
+
)[:max_accepted]
|
244
245
|
|
245
246
|
async def arefined_query(
|
246
|
-
|
247
|
+
self, question: List[str] | str, **kwargs: Unpack[ChooseKwargs[Optional[List[str]]]]
|
247
248
|
) -> Optional[List[str]]:
|
248
249
|
"""Refines the given question using a template.
|
249
250
|
|
@@ -235,6 +235,7 @@ def logging_exec_time[**P, R](
|
|
235
235
|
@wraps(func)
|
236
236
|
async def _async_wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
|
237
237
|
start_time = time()
|
238
|
+
logger.debug(f"Starting execution of {func.__name__}")
|
238
239
|
result = await func(*args, **kwargs)
|
239
240
|
logger.debug(f"Execution time of `{func.__name__}`: {time() - start_time:.2f} s")
|
240
241
|
return result
|
@@ -244,6 +245,7 @@ def logging_exec_time[**P, R](
|
|
244
245
|
@wraps(func)
|
245
246
|
def _wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
|
246
247
|
start_time = time()
|
248
|
+
logger.debug(f"Starting execution of {func.__name__}")
|
247
249
|
result = func(*args, **kwargs)
|
248
250
|
logger.debug(f"Execution time of {func.__name__}: {(time() - start_time) * 1000:.2f} ms")
|
249
251
|
return result
|
{fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/aricle_rag.py
RENAMED
@@ -1,6 +1,7 @@
|
|
1
1
|
"""A Module containing the article rag models."""
|
2
2
|
|
3
3
|
import re
|
4
|
+
from dataclasses import dataclass, field
|
4
5
|
from itertools import groupby
|
5
6
|
from pathlib import Path
|
6
7
|
from typing import ClassVar, Dict, List, Optional, Self, Unpack
|
@@ -68,7 +69,7 @@ class ArticleChunk(MilvusDataBase):
|
|
68
69
|
|
69
70
|
@classmethod
|
70
71
|
def from_file[P: str | Path](
|
71
|
-
|
72
|
+
cls, path: P | List[P], bib_mgr: BibManager, **kwargs: Unpack[ChunkKwargs]
|
72
73
|
) -> List[Self]:
|
73
74
|
"""Load the article chunks from the file."""
|
74
75
|
if isinstance(path, list):
|
@@ -85,9 +86,9 @@ class ArticleChunk(MilvusDataBase):
|
|
85
86
|
title_seg = path.stem.split(" - ").pop()
|
86
87
|
|
87
88
|
key = (
|
88
|
-
|
89
|
-
|
90
|
-
|
89
|
+
bib_mgr.get_cite_key_by_title(title_seg)
|
90
|
+
or bib_mgr.get_cite_key_by_title_fuzzy(title_seg)
|
91
|
+
or bib_mgr.get_cite_key_fuzzy(path.stem)
|
91
92
|
)
|
92
93
|
if key is None:
|
93
94
|
logger.warning(f"no cite key found for {path.as_posix()}, skip.")
|
@@ -165,10 +166,11 @@ class ArticleChunk(MilvusDataBase):
|
|
165
166
|
return self
|
166
167
|
|
167
168
|
|
169
|
+
@dataclass
|
168
170
|
class CitationManager(AsPrompt):
|
169
171
|
"""Citation manager."""
|
170
172
|
|
171
|
-
article_chunks: List[ArticleChunk] =
|
173
|
+
article_chunks: List[ArticleChunk] = field(default_factory=list)
|
172
174
|
"""Article chunks."""
|
173
175
|
|
174
176
|
pat: str = r"(\[\[([\d\s,-]*)]])"
|
@@ -179,7 +181,7 @@ class CitationManager(AsPrompt):
|
|
179
181
|
"""Separator for abbreviated citation numbers."""
|
180
182
|
|
181
183
|
def update_chunks(
|
182
|
-
|
184
|
+
self, article_chunks: List[ArticleChunk], set_cite_number: bool = True, dedup: bool = True
|
183
185
|
) -> Self:
|
184
186
|
"""Update article chunks."""
|
185
187
|
self.article_chunks.clear()
|
{fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/article_base.py
RENAMED
@@ -2,9 +2,7 @@
|
|
2
2
|
|
3
3
|
from abc import ABC
|
4
4
|
from enum import StrEnum
|
5
|
-
from fabricatio.rust import extract_body, replace_thesis_body, split_out_metadata, to_metadata, word_count
|
6
5
|
from pathlib import Path
|
7
|
-
from pydantic import Field
|
8
6
|
from typing import ClassVar, Generator, List, Optional, Self, Tuple, Type
|
9
7
|
|
10
8
|
from fabricatio.capabilities.persist import PersistentAble
|
@@ -23,7 +21,9 @@ from fabricatio.models.generic import (
|
|
23
21
|
Titled,
|
24
22
|
WordCount,
|
25
23
|
)
|
24
|
+
from fabricatio.rust import extract_body, replace_thesis_body, split_out_metadata, to_metadata, word_count
|
26
25
|
from fabricatio.utils import fallback_kwargs, ok
|
26
|
+
from pydantic import Field
|
27
27
|
|
28
28
|
ARTICLE_WRAPPER = "// =-=-=-=-=-=-=-=-=-="
|
29
29
|
|
@@ -275,7 +275,7 @@ class ArticleBase[T: ChapterBase](FinalizedDumpAble, AsPrompt, FromTypstCode, To
|
|
275
275
|
)
|
276
276
|
|
277
277
|
def iter_dfs_rev(
|
278
|
-
|
278
|
+
self,
|
279
279
|
) -> Generator[ArticleOutlineBase, None, None]:
|
280
280
|
"""Performs a depth-first search (DFS) through the article structure in reverse order.
|
281
281
|
|
{fabricatio-0.3.14.dev5 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/article_main.py
RENAMED
@@ -19,8 +19,7 @@ from fabricatio.models.extra.article_outline import (
|
|
19
19
|
)
|
20
20
|
from fabricatio.models.generic import Described, SequencePatch, SketchedAble, WithRef, WordCount
|
21
21
|
from fabricatio.rust import (
|
22
|
-
|
23
|
-
convert_all_inline_tex,
|
22
|
+
convert_all_tex_math,
|
24
23
|
fix_misplaced_labels,
|
25
24
|
split_out_metadata,
|
26
25
|
word_count,
|
@@ -155,15 +154,13 @@ class Article(
|
|
155
154
|
if descriptions:
|
156
155
|
for a in self.iter_dfs():
|
157
156
|
a.description = fix_misplaced_labels(a.description)
|
158
|
-
a.description =
|
159
|
-
a.description = convert_all_block_tex(a.description)
|
157
|
+
a.description = convert_all_tex_math(a.description)
|
160
158
|
|
161
159
|
if paragraphs:
|
162
160
|
for _, _, subsec in self.iter_subsections():
|
163
161
|
for p in subsec.paragraphs:
|
164
162
|
p.content = fix_misplaced_labels(p.content)
|
165
|
-
p.content =
|
166
|
-
p.content = convert_all_block_tex(p.content)
|
163
|
+
p.content = convert_all_tex_math(p.content)
|
167
164
|
return self
|
168
165
|
|
169
166
|
@override
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"""Module that contains the Role class for managing workflows and their event registrations."""
|
2
2
|
|
3
3
|
from functools import partial
|
4
|
-
from typing import Any, Dict, Self
|
4
|
+
from typing import Any, Callable, Dict, Self, Type
|
5
5
|
|
6
6
|
from fabricatio.emitter import env
|
7
7
|
from fabricatio.journal import logger
|
@@ -68,28 +68,32 @@ class Role(WithBriefing):
|
|
68
68
|
workflow.inject_personality(self.briefing)
|
69
69
|
return self
|
70
70
|
|
71
|
-
def
|
72
|
-
|
73
|
-
|
71
|
+
def _propagate_config(
|
72
|
+
self,
|
73
|
+
workflow: WorkFlow,
|
74
|
+
has_capability: Callable[[Type], bool],
|
75
|
+
config_method_name: str,
|
76
|
+
capability_description: str,
|
77
|
+
) -> None:
|
78
|
+
"""Propagates configuration to workflow and its actions if they have a given capability."""
|
79
|
+
if not has_capability(self.__class__):
|
74
80
|
return
|
75
81
|
|
76
|
-
|
77
|
-
if
|
78
|
-
|
79
|
-
|
82
|
+
config_source_for_actions = self
|
83
|
+
if has_capability(workflow.__class__):
|
84
|
+
logger.debug(
|
85
|
+
f"Configuring {capability_description} inherited from `{self.name}` for workflow: `{workflow.name}`"
|
86
|
+
)
|
87
|
+
getattr(workflow, config_method_name)(self)
|
88
|
+
config_source_for_actions = workflow
|
80
89
|
|
81
|
-
for action in (
|
82
|
-
action
|
90
|
+
for action in (act for act in workflow.iter_actions() if has_capability(act.__class__)):
|
91
|
+
getattr(action, config_method_name)(config_source_for_actions)
|
92
|
+
|
93
|
+
def _configure_scoped_config(self, workflow: WorkFlow) -> None:
|
94
|
+
"""Configure scoped configuration for workflow and its actions."""
|
95
|
+
self._propagate_config(workflow, is_scoped_config, "fallback_to", "scoped config")
|
83
96
|
|
84
97
|
def _configure_toolbox_usage(self, workflow: WorkFlow) -> None:
|
85
98
|
"""Configure toolbox usage for workflow and its actions."""
|
86
|
-
|
87
|
-
return
|
88
|
-
|
89
|
-
supply_target = self
|
90
|
-
if is_toolbox_usage(workflow):
|
91
|
-
workflow.supply_tools_from(self)
|
92
|
-
supply_target = workflow
|
93
|
-
|
94
|
-
for action in (a for a in workflow.iter_actions() if is_toolbox_usage(a)):
|
95
|
-
action.supply_tools_from(supply_target)
|
99
|
+
self._propagate_config(workflow, is_toolbox_usage, "supply_tools_from", "toolbox usage")
|