fabricatio 0.2.6.dev2__tar.gz → 0.2.6.dev3__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.
Files changed (119) hide show
  1. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/Makefile +5 -5
  2. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/PKG-INFO +1 -1
  3. fabricatio-0.2.6.dev3/examples/correct/correct_loop.py +30 -0
  4. fabricatio-0.2.6.dev3/examples/search_bibtex/.gitignore +1 -0
  5. fabricatio-0.2.6.dev3/examples/search_bibtex/search.py +12 -0
  6. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/pyproject.toml +2 -2
  7. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/_rust.pyi +15 -1
  8. fabricatio-0.2.6.dev3/src/bib_tools.rs +88 -0
  9. fabricatio-0.2.6.dev3/templates.tar.gz +0 -0
  10. fabricatio-0.2.6.dev3/uv.lock +1547 -0
  11. fabricatio-0.2.6.dev2/src/bib_tools.rs +0 -73
  12. fabricatio-0.2.6.dev2/templates.tar.gz +0 -0
  13. fabricatio-0.2.6.dev2/uv.lock +0 -1549
  14. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/.github/workflows/build-package.yaml +0 -0
  15. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/.github/workflows/ruff.yaml +0 -0
  16. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/.github/workflows/tests.yaml +0 -0
  17. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/.gitignore +0 -0
  18. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/.python-version +0 -0
  19. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/Cargo.lock +0 -0
  20. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/Cargo.toml +0 -0
  21. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/LICENSE +0 -0
  22. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/README.md +0 -0
  23. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/examples/correct/correct.py +0 -0
  24. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/examples/extract_and_review/.gitignore +0 -0
  25. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/examples/extract_and_review/extract_and_review.py +0 -0
  26. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/examples/extract_article/extract.py +0 -0
  27. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/examples/llm_usages/llm_usage.py +0 -0
  28. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/examples/make_a_rating/rating.py +0 -0
  29. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/examples/make_diary/commits.json +0 -0
  30. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/examples/make_diary/diary.py +0 -0
  31. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/examples/minor/hello_fabricatio.py +0 -0
  32. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/examples/minor/write_a_poem.py +0 -0
  33. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/examples/propose_task/propose.py +0 -0
  34. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/examples/reviewer/review.py +0 -0
  35. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/examples/simple_chat/chat.py +0 -0
  36. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/examples/simple_rag/simple_rag.py +0 -0
  37. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/examples/task_handle/handle_task.py +0 -0
  38. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/examples/write_outline/.gitignore +0 -0
  39. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/examples/write_outline/write_outline.py +0 -0
  40. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/__init__.py +0 -0
  41. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/_rust_instances.py +0 -0
  42. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/actions/article.py +0 -0
  43. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/actions/output.py +0 -0
  44. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/actions/rag.py +0 -0
  45. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/capabilities/correct.py +0 -0
  46. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/capabilities/propose.py +0 -0
  47. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/capabilities/rag.py +0 -0
  48. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/capabilities/rating.py +0 -0
  49. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/capabilities/review.py +0 -0
  50. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/capabilities/task.py +0 -0
  51. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/config.py +0 -0
  52. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/core.py +0 -0
  53. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/decorators.py +0 -0
  54. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/fs/__init__.py +0 -0
  55. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/fs/curd.py +0 -0
  56. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/fs/readers.py +0 -0
  57. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/journal.py +0 -0
  58. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/models/action.py +0 -0
  59. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/models/events.py +0 -0
  60. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/models/extra.py +0 -0
  61. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/models/generic.py +0 -0
  62. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/models/kwargs_types.py +0 -0
  63. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/models/role.py +0 -0
  64. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/models/task.py +0 -0
  65. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/models/tool.py +0 -0
  66. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/models/usages.py +0 -0
  67. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/models/utils.py +0 -0
  68. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/parser.py +0 -0
  69. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/py.typed +0 -0
  70. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/toolboxes/__init__.py +0 -0
  71. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/toolboxes/arithmetic.py +0 -0
  72. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/toolboxes/fs.py +0 -0
  73. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/workflows/articles.py +0 -0
  74. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/python/fabricatio/workflows/rag.py +0 -0
  75. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/src/hash.rs +0 -0
  76. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/src/hbs_helpers.rs +0 -0
  77. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/src/lib.rs +0 -0
  78. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/src/templates.rs +0 -0
  79. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/binary-exploitation-ctf-solver.hbs +0 -0
  80. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/claude-xml.hbs +0 -0
  81. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/clean-up-code.hbs +0 -0
  82. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/correct.hbs +0 -0
  83. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/create_json_obj.hbs +0 -0
  84. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/cryptography-ctf-solver.hbs +0 -0
  85. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/dependencies.hbs +0 -0
  86. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/document-the-code.hbs +0 -0
  87. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/draft_rating_criteria.hbs +0 -0
  88. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/draft_rating_manual.hbs +0 -0
  89. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/draft_rating_weights_klee.hbs +0 -0
  90. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/draft_tool_usage_code.hbs +0 -0
  91. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/extract_criteria_from_reasons.hbs +0 -0
  92. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/extract_reasons_from_examples.hbs +0 -0
  93. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/find-security-vulnerabilities.hbs +0 -0
  94. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/fix-bugs.hbs +0 -0
  95. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/generic_string.hbs +0 -0
  96. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/improve-performance.hbs +0 -0
  97. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/liststr.hbs +0 -0
  98. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/make_choice.hbs +0 -0
  99. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/make_judgment.hbs +0 -0
  100. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/pathstr.hbs +0 -0
  101. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/rate_fine_grind.hbs +0 -0
  102. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/refactor.hbs +0 -0
  103. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/refined_query.hbs +0 -0
  104. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/retrieved_display.hbs +0 -0
  105. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/reverse-engineering-ctf-solver.hbs +0 -0
  106. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/review_string.hbs +0 -0
  107. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/task_briefing.hbs +0 -0
  108. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/web-ctf-solver.hbs +0 -0
  109. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/write-git-commit.hbs +0 -0
  110. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/write-github-pull-request.hbs +0 -0
  111. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/templates/built-in/write-github-readme.hbs +0 -0
  112. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/tests/test_config.py +0 -0
  113. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/tests/test_models/test_action.py +0 -0
  114. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/tests/test_models/test_advanced.py +0 -0
  115. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/tests/test_models/test_generic.py +0 -0
  116. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/tests/test_models/test_role.py +0 -0
  117. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/tests/test_models/test_task.py +0 -0
  118. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/tests/test_models/test_tool.py +0 -0
  119. {fabricatio-0.2.6.dev2 → fabricatio-0.2.6.dev3}/tests/test_models/test_usages.py +0 -0
@@ -12,16 +12,16 @@ tools:
12
12
  rm $(DATA)/scripts/*.dwarf || true
13
13
 
14
14
  dev: tools
15
- uvx --with-editable . maturin develop --uv -r
15
+ uvx --project . maturin develop --uv -r
16
16
 
17
17
  bdist:clean tools
18
- uvx --with-editable . maturin sdist -o $(DIST)
19
- uvx --with-editable . maturin build -r -o $(DIST)
18
+ uvx --project . maturin sdist -o $(DIST)
19
+ uvx --project . maturin build -r -o $(DIST)
20
20
 
21
21
  clean:
22
22
  rm -rf $(DIST) $(DATA)
23
23
 
24
24
  publish:tools
25
- uvx --with-editable . maturin publish --skip-existing
26
- uvx --with-editable . maturin upload --skip-existing $(DIST)/*
25
+ uvx --project . maturin publish --skip-existing
26
+ uvx --project . maturin upload --skip-existing $(DIST)/*
27
27
  .PHONY: tools
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fabricatio
3
- Version: 0.2.6.dev2
3
+ Version: 0.2.6.dev3
4
4
  Classifier: License :: OSI Approved :: MIT License
5
5
  Classifier: Programming Language :: Rust
6
6
  Classifier: Programming Language :: Python :: 3.12
@@ -0,0 +1,30 @@
1
+ """Example of review usage."""
2
+
3
+ import asyncio
4
+
5
+ from fabricatio import Role, logger
6
+ from questionary import confirm
7
+ from rich import print as r_print
8
+
9
+
10
+ async def main() -> None:
11
+ """Main function."""
12
+ role = Role(
13
+ name="Reviewer",
14
+ description="A role that reviews the code.",
15
+ )
16
+
17
+ code = await role.aask(
18
+ "write a cli app using rust with clap which can generate a basic manifest of a standard rust project, output code only,no extra explanation, you should using derive mode of clap."
19
+ )
20
+
21
+ logger.success(f"Code: \n{code}")
22
+
23
+ while await confirm("Do you want to review the code?").ask_async():
24
+ code = await role.correct_string(code, topic="If the cli app is of good design", supervisor_check=False)
25
+ r_print(code)
26
+ logger.success(f"Corrected: \n{code}")
27
+
28
+
29
+ if __name__ == "__main__":
30
+ asyncio.run(main())
@@ -0,0 +1,12 @@
1
+ from fabricatio import BibManager
2
+
3
+ b = BibManager("Exported Items.bib")
4
+ print(b.get_cite_key("Fault Diagnosis of Wind Turbines"))
5
+ print(
6
+ b.get_cite_key_fuzzy(
7
+ "Fault Diagnosis of Wind Turbines"
8
+ )
9
+ )
10
+
11
+ print(b.list_titles())
12
+ print(b.list_titles(True))
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fabricatio"
3
- version = "0.2.6-dev2"
3
+ version = "0.2.6-dev3"
4
4
  description = "A LLM multi-agent framework."
5
5
  readme = "README.md"
6
6
  license = { file = "LICENSE" }
@@ -85,7 +85,7 @@ full = [
85
85
  ]
86
86
 
87
87
  [tool.ruff]
88
- include = ["pyproject.toml", "python/fabricatio/*.py","python/fabricatio/*.pyi", "examples/*.py"]
88
+ include = ["pyproject.toml", "python/fabricatio/*.py", "python/fabricatio/*.pyi", "examples/*.py"]
89
89
  line-length = 120
90
90
  target-version = "py312"
91
91
  [tool.ruff.format]
@@ -1,6 +1,7 @@
1
1
  from pathlib import Path
2
2
  from typing import Any, Dict, List, Optional
3
3
 
4
+
4
5
  class TemplateManager:
5
6
  """Template rendering engine using Handlebars templates.
6
7
 
@@ -9,8 +10,9 @@ class TemplateManager:
9
10
 
10
11
  See: https://crates.io/crates/handlebars
11
12
  """
13
+
12
14
  def __init__(
13
- self, template_dirs: List[Path], suffix: Optional[str] = None, active_loading: Optional[bool] = None
15
+ self, template_dirs: List[Path], suffix: Optional[str] = None, active_loading: Optional[bool] = None
14
16
  ) -> None:
15
17
  """Initialize the template manager.
16
18
 
@@ -54,6 +56,7 @@ class TemplateManager:
54
56
  RuntimeError: If template rendering fails
55
57
  """
56
58
 
59
+
57
60
  def blake3_hash(content: bytes) -> str:
58
61
  """Calculate the BLAKE3 cryptographic hash of data.
59
62
 
@@ -64,6 +67,7 @@ def blake3_hash(content: bytes) -> str:
64
67
  Hex-encoded BLAKE3 hash string
65
68
  """
66
69
 
70
+
67
71
  class BibManager:
68
72
  """BibTeX bibliography manager for parsing and querying citation data."""
69
73
 
@@ -100,3 +104,13 @@ class BibManager:
100
104
  Uses nucleo_matcher for high-quality fuzzy text searching
101
105
  See: https://crates.io/crates/nucleo-matcher
102
106
  """
107
+
108
+ def list_titles(self, is_verbatim: Optional[bool] = False) -> List[str]:
109
+ """List all titles in the bibliography.
110
+
111
+ Args:
112
+ is_verbatim: Whether to return verbatim titles (without formatting)
113
+
114
+ Returns:
115
+ List of all titles in the bibliography
116
+ """
@@ -0,0 +1,88 @@
1
+ use biblatex::{Bibliography, ChunksExt};
2
+ use nucleo_matcher::pattern::{AtomKind, CaseMatching, Normalization, Pattern};
3
+ use nucleo_matcher::{Config, Matcher, Utf32Str};
4
+ use pyo3::exceptions::PyRuntimeError;
5
+ use pyo3::prelude::*;
6
+ use rayon::prelude::*;
7
+
8
+ #[pyclass]
9
+ pub struct BibManager {
10
+ source: Bibliography,
11
+ }
12
+
13
+
14
+ #[pymethods]
15
+ impl BibManager {
16
+ /// Create a new BibManager instance.
17
+ #[new]
18
+ fn new(path: String) -> PyResult<Self> {
19
+ let bib = std::fs::read_to_string(path)
20
+ .map_err(|e| PyErr::new::<PyRuntimeError, _>(e.to_string()))?;
21
+
22
+ let source = Bibliography::parse(&bib)
23
+ .map_err(|e| PyErr::new::<PyRuntimeError, _>(e.to_string()))?;
24
+
25
+ Ok(BibManager { source })
26
+ }
27
+
28
+ /// find the cite key of an article with given title
29
+ fn get_cite_key(&self, title: String) -> Option<String> {
30
+ let title_lower = title.to_lowercase();
31
+
32
+ self.source.iter().par_bridge()
33
+ .find_map_any(|entry| {
34
+ let entry_title = entry.title()
35
+ .map_err(|e| PyErr::new::<PyRuntimeError, _>(format!("{}", e)))
36
+ .ok()?
37
+ .to_biblatex_string(false)
38
+ .replace("{", "")
39
+ .replace("}", "")
40
+ .to_lowercase();
41
+
42
+ (entry_title == title_lower).then(|| entry.key.clone())
43
+ })
44
+ }
45
+
46
+ /// Find the corresponding cite key of an article with given query string using fuzzy matcher
47
+ fn get_cite_key_fuzzy(&self, query: String) -> Option<String> {
48
+ let mut matcher = Matcher::new(Config::DEFAULT);
49
+ let pattern = Pattern::new(
50
+ query.as_str(),
51
+ CaseMatching::Ignore,
52
+ Normalization::Smart,
53
+ AtomKind::Substring,
54
+ );
55
+
56
+
57
+ self.source.iter()
58
+ .map(|entry| {
59
+ let mut buf = vec![];
60
+ let text = entry.to_biblatex_string().replace("{", "")
61
+ .replace("}", "");
62
+ (pattern.score(Utf32Str::new(text.as_str(), &mut buf), &mut matcher), entry)
63
+ })
64
+ .par_bridge()
65
+ // Use filter_map's more concise form with pattern matching
66
+ .filter_map(|(maybe_score, entry)| maybe_score.map(|score| (score, entry)))
67
+ .max_by_key(|(score, _)| *score)
68
+ .map(|(_, entry)| entry.key.clone())
69
+ }
70
+ #[pyo3(signature = (is_verbatim=false))]
71
+ fn list_titles(&self, is_verbatim: bool) -> Vec<String> {
72
+ self.source.iter().map(|entry| {
73
+ entry.title()
74
+ .map_err(|e| PyErr::new::<PyRuntimeError, _>(format!("{}", e)))
75
+ .ok()
76
+ .unwrap()
77
+ .to_biblatex_string(is_verbatim)
78
+ .replace("{", "")
79
+ .replace("}", "")
80
+ }).collect::<Vec<_>>()
81
+ }
82
+ }
83
+
84
+
85
+ pub(crate) fn register(_: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
86
+ m.add_class::<BibManager>()?;
87
+ Ok(())
88
+ }
Binary file