fabricatio 0.3.14.dev7__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.dev7 → fabricatio-0.3.14.dev8}/PKG-INFO +1 -1
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/write_article/write_article.py +11 -4
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/pyproject.toml +1 -1
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/actions/article_rag.py +52 -52
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/decorators.py +2 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/aricle_rag.py +4 -5
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/article_base.py +2 -2
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/article_main.py +3 -3
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/role.py +24 -20
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/rust.pyi +8 -62
- fabricatio-0.3.14.dev8/src/templates.rs +217 -0
- fabricatio-0.3.14.dev8/templates.tar.gz +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/uv.lock +62 -75
- fabricatio-0.3.14.dev7/src/templates.rs +0 -166
- fabricatio-0.3.14.dev7/templates.tar.gz +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/.github/workflows/build-package.yaml +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/.github/workflows/ruff.yaml +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/.github/workflows/tests.yaml +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/.gitignore +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/Cargo.lock +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/Cargo.toml +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/LICENSE +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/Makefile +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/README.md +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/build.rs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/correct/correct.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/correct/correct_loop.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/extract_and_inject/.gitignore +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/extract_and_inject/article_rag.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/extract_and_inject/ask.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/extract_and_inject/chunk_article.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/extract_and_inject/extract_and_inject.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/extract_article/extract.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/llm_usages/llm_usage.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/make_a_rating/rating.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/make_diary/commits.json +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/make_diary/diary.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/minor/hello_fabricatio.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/minor/write_a_poem.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/propose_task/.gitignore +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/propose_task/propose.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/reviewer/censor.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/reviewer/review.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/rules/.gitignore +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/rules/draft_ruleset.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/search_bibtex/.gitignore +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/search_bibtex/search.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/simple_chat/chat.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/simple_rag/simple_rag.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/task_handle/handle_task.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/write_article/.gitignore +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/write_article/article_rag.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/write_article/post_process.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/write_outline/.gitignore +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/write_outline/write_outline.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/examples/write_outline/write_outline_corrected.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/proto/tei.proto +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/__init__.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/actions/__init__.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/actions/article.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/actions/fs.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/actions/output.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/actions/rag.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/actions/rules.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/__init__.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/advanced_judge.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/advanced_rag.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/censor.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/check.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/correct.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/extract.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/persist.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/propose.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/rag.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/rating.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/review.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/capabilities/task.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/emitter.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/fs/__init__.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/fs/curd.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/fs/readers.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/journal.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/action.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/adv_kwargs_types.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/__init__.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/advanced_judge.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/article_essence.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/article_outline.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/article_proposal.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/patches.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/problem.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/rag.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/rule.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/generic.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/kwargs_types.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/task.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/tool.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/usages.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/parser.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/py.typed +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/toolboxes/__init__.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/toolboxes/arithmetic.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/toolboxes/fs.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/utils.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/workflows/__init__.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/workflows/articles.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/workflows/rag.py +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/src/bib_tools.rs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/src/config.rs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/src/event.rs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/src/hash.rs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/src/hbs_helpers.rs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/src/language.rs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/src/lib.rs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/src/macro_utils/Cargo.toml +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/src/macro_utils/src/lib.rs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/src/tei_client.rs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/src/typst_conversion/Cargo.toml +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/src/typst_conversion/src/lib.rs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/src/typst_tools.rs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/src/word_split.rs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/as_prompt.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/binary-exploitation-ctf-solver.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/chap_summary.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/check_string.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/claude-xml.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/clean-up-code.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/co_validation.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/create_json_obj.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/cryptography-ctf-solver.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/dependencies.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/document-the-code.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/draft_rating_criteria.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/draft_rating_manual.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/draft_rating_weights_klee.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/draft_tool_usage_code.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/extract.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/extract_criteria_from_reasons.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/extract_reasons_from_examples.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/find-security-vulnerabilities.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/fix-bugs.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/fix_troubled_obj.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/fix_troubled_string.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/generic_string.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/improve-performance.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/liststr.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/make_choice.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/make_judgment.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/pathstr.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/rate_fine_grind.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/refactor.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/refined_query.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/retrieved_display.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/reverse-engineering-ctf-solver.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/review_string.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/rule_requirement.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/ruleset_requirement_breakdown.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/task_briefing.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/web-ctf-solver.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/write-git-commit.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/write-github-pull-request.hbs +0 -0
- {fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/templates/built-in/write-github-readme.hbs +0 -0
@@ -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",
|
@@ -1,11 +1,11 @@
|
|
1
1
|
"""A module for writing articles using RAG (Retrieval-Augmented Generation) capabilities."""
|
2
2
|
|
3
3
|
from asyncio import gather
|
4
|
-
|
5
4
|
from pathlib import Path
|
6
|
-
from pydantic import Field, PositiveInt
|
7
5
|
from typing import ClassVar, List, Optional
|
8
6
|
|
7
|
+
from pydantic import Field, PositiveInt
|
8
|
+
|
9
9
|
from fabricatio.capabilities.advanced_rag import AdvancedRAG
|
10
10
|
from fabricatio.capabilities.censor import Censor
|
11
11
|
from fabricatio.capabilities.extract import Extract
|
@@ -75,11 +75,11 @@ class WriteArticleContentRAG(Action, Extract, AdvancedRAG):
|
|
75
75
|
tei_endpoint: Optional[str] = None
|
76
76
|
|
77
77
|
async def _execute(
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
self,
|
79
|
+
article_outline: ArticleOutline,
|
80
|
+
collection_name: Optional[str] = None,
|
81
|
+
supervisor: Optional[bool] = None,
|
82
|
+
**cxt,
|
83
83
|
) -> Article:
|
84
84
|
article = Article.from_outline(article_outline).update_ref(article_outline)
|
85
85
|
self.target_collection = collection_name or self.safe_target_collection
|
@@ -100,12 +100,12 @@ class WriteArticleContentRAG(Action, Extract, AdvancedRAG):
|
|
100
100
|
"questionary", "`questionary` is required for supervisor mode, please install it by `fabricatio[qa]`"
|
101
101
|
)
|
102
102
|
async def _supervisor_inner(
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
103
|
+
self,
|
104
|
+
article: Article,
|
105
|
+
article_outline: ArticleOutline,
|
106
|
+
chap: ArticleChapter,
|
107
|
+
sec: ArticleSection,
|
108
|
+
subsec: ArticleSubsection,
|
109
109
|
) -> ArticleSubsection:
|
110
110
|
from questionary import confirm, text
|
111
111
|
from rich import print as r_print
|
@@ -133,12 +133,12 @@ class WriteArticleContentRAG(Action, Extract, AdvancedRAG):
|
|
133
133
|
return await self.extract_new_subsec(subsec, raw_paras, cm)
|
134
134
|
|
135
135
|
async def _inner(
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
136
|
+
self,
|
137
|
+
article: Article,
|
138
|
+
article_outline: ArticleOutline,
|
139
|
+
chap: ArticleChapter,
|
140
|
+
sec: ArticleSection,
|
141
|
+
subsec: ArticleSubsection,
|
142
142
|
) -> ArticleSubsection:
|
143
143
|
cm = CitationManager()
|
144
144
|
|
@@ -154,7 +154,7 @@ class WriteArticleContentRAG(Action, Extract, AdvancedRAG):
|
|
154
154
|
return await self.extract_new_subsec(subsec, raw_paras, cm)
|
155
155
|
|
156
156
|
async def extract_new_subsec(
|
157
|
-
|
157
|
+
self, subsec: ArticleSubsection, raw_paras: str, cm: CitationManager
|
158
158
|
) -> ArticleSubsection:
|
159
159
|
"""Extract the new subsec."""
|
160
160
|
new_subsec = ok(
|
@@ -177,14 +177,14 @@ class WriteArticleContentRAG(Action, Extract, AdvancedRAG):
|
|
177
177
|
return subsec
|
178
178
|
|
179
179
|
async def write_raw(
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
180
|
+
self,
|
181
|
+
article: Article,
|
182
|
+
article_outline: ArticleOutline,
|
183
|
+
chap: ArticleChapter,
|
184
|
+
sec: ArticleSection,
|
185
|
+
subsec: ArticleSubsection,
|
186
|
+
cm: CitationManager,
|
187
|
+
extra_instruction: str = "",
|
188
188
|
) -> str:
|
189
189
|
"""Write the raw paragraphs of the subsec."""
|
190
190
|
return await self.aask(
|
@@ -200,14 +200,14 @@ class WriteArticleContentRAG(Action, Extract, AdvancedRAG):
|
|
200
200
|
)
|
201
201
|
|
202
202
|
async def search_database(
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
203
|
+
self,
|
204
|
+
article: Article,
|
205
|
+
article_outline: ArticleOutline,
|
206
|
+
chap: ArticleChapter,
|
207
|
+
sec: ArticleSection,
|
208
|
+
subsec: ArticleSubsection,
|
209
|
+
cm: CitationManager,
|
210
|
+
extra_instruction: str = "",
|
211
211
|
) -> None:
|
212
212
|
"""Search database for related references."""
|
213
213
|
search_req = (
|
@@ -312,12 +312,12 @@ class TweakArticleRAG(Action, RAG, Censor):
|
|
312
312
|
"""The limit of references to be retrieved"""
|
313
313
|
|
314
314
|
async def _execute(
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
315
|
+
self,
|
316
|
+
article: Article,
|
317
|
+
collection_name: str = "article_essence",
|
318
|
+
twk_rag_ruleset: Optional[RuleSet] = None,
|
319
|
+
parallel: bool = False,
|
320
|
+
**cxt,
|
321
321
|
) -> Article:
|
322
322
|
"""Write an article based on the provided outline.
|
323
323
|
|
@@ -372,10 +372,10 @@ class TweakArticleRAG(Action, RAG, Censor):
|
|
372
372
|
subsec,
|
373
373
|
ruleset=ruleset,
|
374
374
|
reference=f"{'\n\n'.join(d.display() for d in await self.aretrieve(refind_q, document_model=ArticleEssence, max_accepted=self.ref_limit))}\n\n"
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
375
|
+
f"You can use Reference above to rewrite the `{subsec.__class__.__name__}`.\n"
|
376
|
+
f"You should Always use `{subsec.language}` as written language, "
|
377
|
+
f"which is the original language of the `{subsec.title}`. "
|
378
|
+
f"since rewrite a `{subsec.__class__.__name__}` in a different language is usually a bad choice",
|
379
379
|
)
|
380
380
|
|
381
381
|
|
@@ -390,12 +390,12 @@ class ChunkArticle(Action):
|
|
390
390
|
"""The maximum overlapping rate between chunks."""
|
391
391
|
|
392
392
|
async def _execute(
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
393
|
+
self,
|
394
|
+
article_path: str | Path,
|
395
|
+
bib_manager: BibManager,
|
396
|
+
max_chunk_size: Optional[int] = None,
|
397
|
+
max_overlapping_rate: Optional[float] = None,
|
398
|
+
**_,
|
399
399
|
) -> List[ArticleChunk]:
|
400
400
|
return ArticleChunk.from_file(
|
401
401
|
article_path,
|
@@ -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.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/aricle_rag.py
RENAMED
@@ -1,13 +1,9 @@
|
|
1
1
|
"""A Module containing the article rag models."""
|
2
2
|
|
3
|
-
from itertools import groupby
|
4
|
-
|
5
3
|
import re
|
6
4
|
from dataclasses import dataclass, field
|
7
|
-
from
|
8
|
-
from more_itertools.recipes import flatten, unique
|
5
|
+
from itertools import groupby
|
9
6
|
from pathlib import Path
|
10
|
-
from pydantic import Field
|
11
7
|
from typing import ClassVar, Dict, List, Optional, Self, Unpack
|
12
8
|
|
13
9
|
from fabricatio.fs import safe_text_read
|
@@ -17,6 +13,9 @@ from fabricatio.models.generic import AsPrompt
|
|
17
13
|
from fabricatio.models.kwargs_types import ChunkKwargs
|
18
14
|
from fabricatio.rust import BibManager, blake3_hash, split_into_chunks
|
19
15
|
from fabricatio.utils import ok, wrapp_in_block
|
16
|
+
from more_itertools.more import first
|
17
|
+
from more_itertools.recipes import flatten, unique
|
18
|
+
from pydantic import Field
|
20
19
|
|
21
20
|
|
22
21
|
class ArticleChunk(MilvusDataBase):
|
{fabricatio-0.3.14.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/article_base.py
RENAMED
@@ -3,7 +3,6 @@
|
|
3
3
|
from abc import ABC
|
4
4
|
from enum import StrEnum
|
5
5
|
from pathlib import Path
|
6
|
-
from pydantic import Field
|
7
6
|
from typing import ClassVar, Generator, List, Optional, Self, Tuple, Type
|
8
7
|
|
9
8
|
from fabricatio.capabilities.persist import PersistentAble
|
@@ -24,6 +23,7 @@ from fabricatio.models.generic import (
|
|
24
23
|
)
|
25
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.dev7 → fabricatio-0.3.14.dev8}/python/fabricatio/models/extra/article_main.py
RENAMED
@@ -1,6 +1,5 @@
|
|
1
1
|
"""ArticleBase and ArticleSubsection classes for managing hierarchical document components."""
|
2
2
|
|
3
|
-
from pydantic import Field, NonNegativeInt
|
4
3
|
from typing import ClassVar, Dict, Generator, List, Self, Tuple, Type, override
|
5
4
|
|
6
5
|
from fabricatio.capabilities.persist import PersistentAble
|
@@ -25,6 +24,7 @@ from fabricatio.rust import (
|
|
25
24
|
split_out_metadata,
|
26
25
|
word_count,
|
27
26
|
)
|
27
|
+
from pydantic import Field, NonNegativeInt
|
28
28
|
|
29
29
|
PARAGRAPH_SEP = "// - - -"
|
30
30
|
|
@@ -81,8 +81,8 @@ class ArticleSubsection(SubSectionBase):
|
|
81
81
|
if len(self.paragraphs) == 0:
|
82
82
|
summary += f"`{self.__class__.__name__}` titled `{self.title}` have no paragraphs, You should add some!\n"
|
83
83
|
if (
|
84
|
-
|
85
|
-
|
84
|
+
abs((wc := self.word_count) - self.expected_word_count) / self.expected_word_count
|
85
|
+
> self._max_word_count_deviation
|
86
86
|
):
|
87
87
|
summary += f"`{self.__class__.__name__}` titled `{self.title}` have {wc} words, expected {self.expected_word_count} words!"
|
88
88
|
|
@@ -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")
|