fabricatio_typst.actions.article_rag
A module for writing articles using RAG (Retrieval-Augmented Generation) capabilities.
Attributes
Classes
Write an article based on the provided outline. |
|
Write an article based on the provided outline. |
|
Write an article based on the provided outline. |
|
Chunk an article into smaller chunks. |
|
Store ArticleEssence instances into LanceDB. |
Module Contents
- fabricatio_typst.actions.article_rag.TYPST_CITE_USAGE = Multiline-String
Show Value
"""citation number is REQUIRED to cite any reference!' Legal citing syntax examples(seperated by |): [[1]]|[[1,2]]|[[1-3]]|[[12,13-15]]|[[1-3,5-7]] Illegal citing syntax examples(seperated by |): [[1],[2],[3]]|[[1],[1-2]] You SHALL not cite a single reference more than once!It's recommended to cite multiple references that supports your conclusion at a time. """
- fabricatio_typst.actions.article_rag.TYPST_MATH_USAGE = Multiline-String
Show Value
"""Wrap inline expression with '\(' and '\)',like '\(>5m\)' '\(89%\)', and wrap block equation with '\[' and '\]'. In addition to that, you can add a label outside the block equation which can be used as a cross reference identifier, the label is a string wrapped in `<` and `>` like `<energy-release-rate-equation>`.Note that the label string should be a summarizing title for the equation being labeled and should never be written within the formula block. you can refer to that label by using the syntax with prefix of `@eqt:`, which indicate that this notation is citing a label from the equations. For example ' @eqt:energy-release-rate-equation ' DO remember that the notation shall have both suffixed and prefixed space char which enable the compiler to distinguish the notation from the plaintext.Below is two usage example: ```typst See @eqt:mass-energy-equation , it's the foundation of physics. \[ E = m c^2 \] <mass-energy-equation> In @eqt:mass-energy-equation , \(m\) stands for mass, \(c\) stands for speed of light, and \(E\) stands for energy. ``` """
- class fabricatio_typst.actions.article_rag.WriteArticleContentRAG(/, **data: Any)
Bases:
fabricatio_core.models.action.Action,fabricatio_capabilities.capabilities.extract.Extract,fabricatio_typst.capabilities.citation_rag.CitationLancedbRAGWrite an article based on the provided outline.
- extractor_model: fabricatio_core.models.kwargs_types.LLMKwargs
The model to use for extracting the content from the retrieved references.
- query_model: fabricatio_core.models.kwargs_types.ListStringKwargs | None = None
The model to use for querying the database
- result_per_query: pydantic.PositiveInt = 4
The number of results to be returned per query.
- cite_req: str = Multiline-String
Show Value
"""citation number is REQUIRED to cite any reference!' Legal citing syntax examples(seperated by |): [[1]]|[[1,2]]|[[1-3]]|[[12,13-15]]|[[1-3,5-7]] Illegal citing syntax examples(seperated by |): [[1],[2],[3]]|[[1],[1-2]] You SHALL not cite a single reference more than once!It's recommended to cite multiple references that supports your conclusion at a time. """
The req of the write article content.
- math_req: str = Multiline-String
Show Value
"""Wrap inline expression with '\(' and '\)',like '\(>5m\)' '\(89%\)', and wrap block equation with '\[' and '\]'. In addition to that, you can add a label outside the block equation which can be used as a cross reference identifier, the label is a string wrapped in `<` and `>` like `<energy-release-rate-equation>`.Note that the label string should be a summarizing title for the equation being labeled and should never be written within the formula block. you can refer to that label by using the syntax with prefix of `@eqt:`, which indicate that this notation is citing a label from the equations. For example ' @eqt:energy-release-rate-equation ' DO remember that the notation shall have both suffixed and prefixed space char which enable the compiler to distinguish the notation from the plaintext.Below is two usage example: ```typst See @eqt:mass-energy-equation , it's the foundation of physics. \[ E = m c^2 \] <mass-energy-equation> In @eqt:mass-energy-equation , \(m\) stands for mass, \(c\) stands for speed of light, and \(E\) stands for energy. ``` """
The req of the write article content.
- async extract_new_subsec(subsec: fabricatio_typst.models.article_main.ArticleSubsection, raw_paras: str, cm: fabricatio_typst.models.article_rag.CitationManager) fabricatio_typst.models.article_main.ArticleSubsection
Extract the new subsec.
- async write_raw(article: fabricatio_typst.models.article_main.Article, article_outline: fabricatio_typst.models.article_outline.ArticleOutline, chap: fabricatio_typst.models.article_main.ArticleChapter, sec: fabricatio_typst.models.article_main.ArticleSection, subsec: fabricatio_typst.models.article_main.ArticleSubsection, cm: fabricatio_typst.models.article_rag.CitationManager, extra_instruction: str = '') str
Write the raw paragraphs of the subsec.
- async search_database(article: fabricatio_typst.models.article_main.Article, article_outline: fabricatio_typst.models.article_outline.ArticleOutline, chap: fabricatio_typst.models.article_main.ArticleChapter, sec: fabricatio_typst.models.article_main.ArticleSection, subsec: fabricatio_typst.models.article_main.ArticleSubsection, cm: fabricatio_typst.models.article_rag.CitationManager, extra_instruction: str = '') None
Search database for related references.
- class fabricatio_typst.actions.article_rag.ArticleConsultRAG(/, **data: Any)
Bases:
fabricatio_core.models.action.Action,fabricatio_typst.capabilities.citation_rag.CitationLancedbRAGWrite an article based on the provided outline.
- output_key: str = 'consult_count'
The key used to store this action’s output in the context dictionary.
- search_increment_multiplier: float = 1.6
The multiplier to increase the limit of references to retrieve per query.
- ref_q_model: fabricatio_core.models.kwargs_types.ListStringKwargs = None
The model to use for refining query.
- req: str = Multiline-String
Show Value
"""citation number is REQUIRED to cite any reference!' Legal citing syntax examples(seperated by |): [[1]]|[[1,2]]|[[1-3]]|[[12,13-15]]|[[1-3,5-7]] Illegal citing syntax examples(seperated by |): [[1],[2],[3]]|[[1],[1-2]] You SHALL not cite a single reference more than once!It's recommended to cite multiple references that supports your conclusion at a time. """
The request for the rag model.
- class fabricatio_typst.actions.article_rag.TweakArticleLancedbRAG(/, **data: Any)
Bases:
fabricatio_core.models.action.Action,fabricatio_lancedb.capabilities.lancedb.LancedbRAG,fabricatio_rule.capabilities.censor.CensorWrite an article based on the provided outline.
This class inherits from Action, RAG, and Censor to provide capabilities for writing and refining articles using Retrieval-Augmented Generation (RAG) techniques. It processes an article outline, enhances subsections by searching for related references, and applies censoring rules to ensure compliance with the provided ruleset.
- ruleset: fabricatio_rule.models.rule.RuleSet | None = None
The ruleset to be used for censoring the article.
- class fabricatio_typst.actions.article_rag.ChunkArticle(/, **data: Any)
Bases:
fabricatio_core.models.action.ActionChunk an article into smaller chunks.
- class fabricatio_typst.actions.article_rag.StoreArticleEssence
Bases:
fabricatio_rag.actions.db.StoreDocuments[fabricatio_typst.models.article_rag.ArticleEssenceStorable,fabricatio_typst.models.article_rag.ArticleEssenceStorable,fabricatio_lancedb.capabilities.lancedb.LancedbAddRAGConfig,fabricatio_lancedb.capabilities.lancedb.LancedbFetchRAGConfig[fabricatio_typst.models.article_rag.ArticleEssenceStorable]],fabricatio_lancedb.capabilities.lancedb.LancedbRAG[fabricatio_typst.models.article_rag.ArticleEssenceStorable,fabricatio_lancedb.capabilities.lancedb.LancedbAddRAGConfig,fabricatio_lancedb.capabilities.lancedb.LancedbFetchRAGConfig[fabricatio_typst.models.article_rag.ArticleEssenceStorable]]Store ArticleEssence instances into LanceDB.