fabricatio 0.2.13.dev2__cp312-cp312-win_amd64.whl → 0.3.13__cp312-cp312-win_amd64.whl
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/__init__.py +3 -3
- fabricatio/actions/article.py +32 -34
- fabricatio/actions/article_rag.py +89 -69
- fabricatio/actions/output.py +22 -21
- fabricatio/actions/rag.py +4 -3
- fabricatio/capabilities/check.py +29 -30
- fabricatio/capabilities/correct.py +23 -23
- fabricatio/capabilities/extract.py +36 -32
- fabricatio/capabilities/rag.py +34 -35
- fabricatio/capabilities/rating.py +77 -72
- fabricatio/capabilities/review.py +12 -11
- fabricatio/capabilities/task.py +4 -5
- fabricatio/core.py +22 -24
- fabricatio/decorators.py +10 -10
- fabricatio/fs/__init__.py +1 -2
- fabricatio/journal.py +2 -9
- fabricatio/models/action.py +2 -1
- fabricatio/models/extra/aricle_rag.py +10 -9
- fabricatio/models/extra/article_base.py +30 -6
- fabricatio/models/extra/article_main.py +11 -10
- fabricatio/models/extra/article_outline.py +5 -36
- fabricatio/models/generic.py +31 -59
- fabricatio/models/role.py +5 -3
- fabricatio/models/task.py +9 -9
- fabricatio/models/tool.py +5 -4
- fabricatio/models/usages.py +170 -161
- fabricatio/parser.py +2 -2
- fabricatio/rust.cp312-win_amd64.pyd +0 -0
- fabricatio/rust.pyi +496 -14
- fabricatio-0.3.13.data/scripts/tdown.exe +0 -0
- fabricatio-0.3.13.data/scripts/ttm.exe +0 -0
- {fabricatio-0.2.13.dev2.dist-info → fabricatio-0.3.13.dist-info}/METADATA +1 -3
- fabricatio-0.3.13.dist-info/RECORD +63 -0
- fabricatio/config.py +0 -430
- fabricatio/constants.py +0 -20
- fabricatio/models/events.py +0 -120
- fabricatio/rust_instances.py +0 -10
- fabricatio-0.2.13.dev2.data/scripts/tdown.exe +0 -0
- fabricatio-0.2.13.dev2.data/scripts/ttm.exe +0 -0
- fabricatio-0.2.13.dev2.dist-info/RECORD +0 -67
- {fabricatio-0.2.13.dev2.dist-info → fabricatio-0.3.13.dist-info}/WHEEL +0 -0
- {fabricatio-0.2.13.dev2.dist-info → fabricatio-0.3.13.dist-info}/licenses/LICENSE +0 -0
fabricatio/capabilities/check.py
CHANGED
@@ -3,17 +3,16 @@
|
|
3
3
|
from asyncio import gather
|
4
4
|
from typing import List, Optional, Unpack
|
5
5
|
|
6
|
-
from fabricatio import TEMPLATE_MANAGER
|
6
|
+
from fabricatio.rust import CONFIG, TEMPLATE_MANAGER, detect_language
|
7
|
+
|
7
8
|
from fabricatio.capabilities.advanced_judge import AdvancedJudge
|
8
9
|
from fabricatio.capabilities.propose import Propose
|
9
|
-
from fabricatio.config import configs
|
10
10
|
from fabricatio.journal import logger
|
11
11
|
from fabricatio.models.extra.patches import RuleSetMetadata
|
12
12
|
from fabricatio.models.extra.problem import Improvement
|
13
13
|
from fabricatio.models.extra.rule import Rule, RuleSet
|
14
14
|
from fabricatio.models.generic import Display, WithBriefing
|
15
15
|
from fabricatio.models.kwargs_types import ValidateKwargs
|
16
|
-
from fabricatio.rust import detect_language
|
17
16
|
from fabricatio.utils import override_kwargs
|
18
17
|
|
19
18
|
|
@@ -25,7 +24,7 @@ class Check(AdvancedJudge, Propose):
|
|
25
24
|
"""
|
26
25
|
|
27
26
|
async def draft_ruleset(
|
28
|
-
|
27
|
+
self, ruleset_requirement: str, rule_count: int = 0, **kwargs: Unpack[ValidateKwargs[Rule]]
|
29
28
|
) -> Optional[RuleSet]:
|
30
29
|
"""Generate rule set based on requirement description.
|
31
30
|
|
@@ -45,7 +44,7 @@ class Check(AdvancedJudge, Propose):
|
|
45
44
|
rule_reqs = (
|
46
45
|
await self.alist_str(
|
47
46
|
TEMPLATE_MANAGER.render_template(
|
48
|
-
|
47
|
+
CONFIG.templates.ruleset_requirement_breakdown_template,
|
49
48
|
{"ruleset_requirement": ruleset_requirement},
|
50
49
|
),
|
51
50
|
rule_count,
|
@@ -61,7 +60,7 @@ class Check(AdvancedJudge, Propose):
|
|
61
60
|
rules = await self.propose(
|
62
61
|
Rule,
|
63
62
|
[
|
64
|
-
TEMPLATE_MANAGER.render_template(
|
63
|
+
TEMPLATE_MANAGER.render_template(CONFIG.templates.rule_requirement_template, {"rule_requirement": r})
|
65
64
|
for r in rule_reqs
|
66
65
|
],
|
67
66
|
**kwargs,
|
@@ -81,11 +80,11 @@ class Check(AdvancedJudge, Propose):
|
|
81
80
|
return RuleSet(rules=rules, **ruleset_patch.as_kwargs())
|
82
81
|
|
83
82
|
async def check_string_against_rule(
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
83
|
+
self,
|
84
|
+
input_text: str,
|
85
|
+
rule: Rule,
|
86
|
+
reference: str = "",
|
87
|
+
**kwargs: Unpack[ValidateKwargs[Improvement]],
|
89
88
|
) -> Optional[Improvement]:
|
90
89
|
"""Validate text against specific rule.
|
91
90
|
|
@@ -104,15 +103,15 @@ class Check(AdvancedJudge, Propose):
|
|
104
103
|
- Proposes Improvement only when violation is confirmed
|
105
104
|
"""
|
106
105
|
if judge := await self.evidently_judge(
|
107
|
-
|
108
|
-
|
109
|
-
|
106
|
+
f"# Content to exam\n{input_text}\n\n# Rule Must to follow\n{rule.display()}\nDoes `Content to exam` provided above violate the `{rule.name}` provided above?"
|
107
|
+
f"should I take some measure to fix that violation? true for I do need, false for I don't need.",
|
108
|
+
**override_kwargs(kwargs, default=None),
|
110
109
|
):
|
111
110
|
logger.info(f"Rule `{rule.name}` violated: \n{judge.display()}")
|
112
111
|
return await self.propose(
|
113
112
|
Improvement,
|
114
113
|
TEMPLATE_MANAGER.render_template(
|
115
|
-
|
114
|
+
CONFIG.templates.check_string_template,
|
116
115
|
{"to_check": input_text, "rule": rule.display(), "judge": judge.display(), "reference": reference},
|
117
116
|
),
|
118
117
|
**kwargs,
|
@@ -120,11 +119,11 @@ class Check(AdvancedJudge, Propose):
|
|
120
119
|
return None
|
121
120
|
|
122
121
|
async def check_obj_against_rule[M: (Display, WithBriefing)](
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
122
|
+
self,
|
123
|
+
obj: M,
|
124
|
+
rule: Rule,
|
125
|
+
reference: str = "",
|
126
|
+
**kwargs: Unpack[ValidateKwargs[Improvement]],
|
128
127
|
) -> Optional[Improvement]:
|
129
128
|
"""Validate object against rule using text representation.
|
130
129
|
|
@@ -152,11 +151,11 @@ class Check(AdvancedJudge, Propose):
|
|
152
151
|
return await self.check_string_against_rule(input_text, rule, reference, **kwargs)
|
153
152
|
|
154
153
|
async def check_string(
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
154
|
+
self,
|
155
|
+
input_text: str,
|
156
|
+
ruleset: RuleSet,
|
157
|
+
reference: str = "",
|
158
|
+
**kwargs: Unpack[ValidateKwargs[Improvement]],
|
160
159
|
) -> Optional[List[Improvement]]:
|
161
160
|
"""Validate text against full ruleset.
|
162
161
|
|
@@ -183,11 +182,11 @@ class Check(AdvancedJudge, Propose):
|
|
183
182
|
return [imp for imp in imp_seq if imp]
|
184
183
|
|
185
184
|
async def check_obj[M: (Display, WithBriefing)](
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
185
|
+
self,
|
186
|
+
obj: M,
|
187
|
+
ruleset: RuleSet,
|
188
|
+
reference: str = "",
|
189
|
+
**kwargs: Unpack[ValidateKwargs[Improvement]],
|
191
190
|
) -> Optional[List[Improvement]]:
|
192
191
|
"""Validate object against full ruleset.
|
193
192
|
|
@@ -1,11 +1,12 @@
|
|
1
1
|
"""A module containing the Correct capability for reviewing, validating, and improving objects."""
|
2
2
|
|
3
3
|
from asyncio import gather
|
4
|
-
from typing import Optional,
|
4
|
+
from typing import Optional, Unpack, cast
|
5
|
+
|
6
|
+
from fabricatio.rust import CONFIG, TEMPLATE_MANAGER
|
5
7
|
|
6
8
|
from fabricatio.capabilities.propose import Propose
|
7
9
|
from fabricatio.capabilities.rating import Rating
|
8
|
-
from fabricatio.config import configs
|
9
10
|
from fabricatio.journal import logger
|
10
11
|
from fabricatio.models.adv_kwargs_types import CorrectKwargs
|
11
12
|
from fabricatio.models.extra.problem import Improvement, ProblemSolutions
|
@@ -14,7 +15,6 @@ from fabricatio.models.kwargs_types import (
|
|
14
15
|
BestKwargs,
|
15
16
|
ValidateKwargs,
|
16
17
|
)
|
17
|
-
from fabricatio.rust_instances import TEMPLATE_MANAGER
|
18
18
|
from fabricatio.utils import fallback_kwargs, ok, override_kwargs
|
19
19
|
|
20
20
|
|
@@ -22,7 +22,7 @@ class Correct(Rating, Propose):
|
|
22
22
|
"""A class that provides the capability to correct objects."""
|
23
23
|
|
24
24
|
async def decide_solution(
|
25
|
-
|
25
|
+
self, problem_solutions: ProblemSolutions, **kwargs: Unpack[BestKwargs]
|
26
26
|
) -> ProblemSolutions:
|
27
27
|
"""Decide the best solution from a list of problem solutions.
|
28
28
|
|
@@ -72,11 +72,11 @@ class Correct(Rating, Propose):
|
|
72
72
|
return improvement
|
73
73
|
|
74
74
|
async def fix_troubled_obj[M: SketchedAble](
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
75
|
+
self,
|
76
|
+
obj: M,
|
77
|
+
problem_solutions: ProblemSolutions,
|
78
|
+
reference: str = "",
|
79
|
+
**kwargs: Unpack[ValidateKwargs[M]],
|
80
80
|
) -> Optional[M]:
|
81
81
|
"""Fix a troubled object based on problem solutions.
|
82
82
|
|
@@ -92,7 +92,7 @@ class Correct(Rating, Propose):
|
|
92
92
|
return await self.propose(
|
93
93
|
cast("Type[M]", obj.__class__),
|
94
94
|
TEMPLATE_MANAGER.render_template(
|
95
|
-
|
95
|
+
CONFIG.templates.fix_troubled_obj_template,
|
96
96
|
{
|
97
97
|
"problem": problem_solutions.problem.display(),
|
98
98
|
"solution": ok(
|
@@ -106,11 +106,11 @@ class Correct(Rating, Propose):
|
|
106
106
|
)
|
107
107
|
|
108
108
|
async def fix_troubled_string(
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
109
|
+
self,
|
110
|
+
input_text: str,
|
111
|
+
problem_solutions: ProblemSolutions,
|
112
|
+
reference: str = "",
|
113
|
+
**kwargs: Unpack[ValidateKwargs[str]],
|
114
114
|
) -> Optional[str]:
|
115
115
|
"""Fix a troubled string based on problem solutions.
|
116
116
|
|
@@ -125,7 +125,7 @@ class Correct(Rating, Propose):
|
|
125
125
|
"""
|
126
126
|
return await self.ageneric_string(
|
127
127
|
TEMPLATE_MANAGER.render_template(
|
128
|
-
|
128
|
+
CONFIG.templates.fix_troubled_string_template,
|
129
129
|
{
|
130
130
|
"problem": problem_solutions.problem.display(),
|
131
131
|
"solution": ok(
|
@@ -140,11 +140,11 @@ class Correct(Rating, Propose):
|
|
140
140
|
)
|
141
141
|
|
142
142
|
async def correct_obj[M: SketchedAble](
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
143
|
+
self,
|
144
|
+
obj: M,
|
145
|
+
improvement: Improvement,
|
146
|
+
reference: str = "",
|
147
|
+
**kwargs: Unpack[ValidateKwargs[M]],
|
148
148
|
) -> Optional[M]:
|
149
149
|
"""Review and correct an object based on defined criteria and templates.
|
150
150
|
|
@@ -178,7 +178,7 @@ class Correct(Rating, Propose):
|
|
178
178
|
return obj
|
179
179
|
|
180
180
|
async def correct_string(
|
181
|
-
|
181
|
+
self, input_text: str, improvement: Improvement, reference: str = "", **kwargs: Unpack[ValidateKwargs[str]]
|
182
182
|
) -> Optional[str]:
|
183
183
|
"""Review and correct a string based on defined criteria and templates.
|
184
184
|
|
@@ -210,7 +210,7 @@ class Correct(Rating, Propose):
|
|
210
210
|
return input_text
|
211
211
|
|
212
212
|
async def correct_obj_inplace[M: ProposedUpdateAble](
|
213
|
-
|
213
|
+
self, obj: M, **kwargs: Unpack[CorrectKwargs[M]]
|
214
214
|
) -> Optional[M]:
|
215
215
|
"""Correct an object in place based on defined criteria and templates.
|
216
216
|
|
@@ -2,9 +2,10 @@
|
|
2
2
|
|
3
3
|
from typing import List, Optional, Type, Unpack, overload
|
4
4
|
|
5
|
+
from fabricatio.rust import CONFIG
|
6
|
+
|
5
7
|
from fabricatio import TEMPLATE_MANAGER
|
6
8
|
from fabricatio.capabilities.propose import Propose
|
7
|
-
from fabricatio.config import configs
|
8
9
|
from fabricatio.models.generic import ProposedAble
|
9
10
|
from fabricatio.models.kwargs_types import ValidateKwargs
|
10
11
|
|
@@ -14,54 +15,57 @@ class Extract(Propose):
|
|
14
15
|
|
15
16
|
@overload
|
16
17
|
async def extract[M: ProposedAble](
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
self,
|
19
|
+
cls: Type[M],
|
20
|
+
source: str,
|
21
|
+
extract_requirement: Optional[str] = None,
|
22
|
+
align_language: bool = True,
|
23
|
+
**kwargs: Unpack[ValidateKwargs[M]],
|
23
24
|
) -> M: ...
|
25
|
+
|
24
26
|
@overload
|
25
27
|
async def extract[M: ProposedAble](
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
self,
|
29
|
+
cls: Type[M],
|
30
|
+
source: str,
|
31
|
+
extract_requirement: Optional[str] = None,
|
32
|
+
align_language: bool = True,
|
33
|
+
**kwargs: Unpack[ValidateKwargs[None]],
|
32
34
|
) -> Optional[M]: ...
|
33
35
|
|
34
36
|
@overload
|
35
37
|
async def extract[M: ProposedAble](
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
self,
|
39
|
+
cls: Type[M],
|
40
|
+
source: List[str],
|
41
|
+
extract_requirement: Optional[str] = None,
|
42
|
+
align_language: bool = True,
|
43
|
+
**kwargs: Unpack[ValidateKwargs[M]],
|
42
44
|
) -> List[M]: ...
|
45
|
+
|
43
46
|
@overload
|
44
47
|
async def extract[M: ProposedAble](
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
self,
|
49
|
+
cls: Type[M],
|
50
|
+
source: List[str],
|
51
|
+
extract_requirement: Optional[str] = None,
|
52
|
+
align_language: bool = True,
|
53
|
+
**kwargs: Unpack[ValidateKwargs[None]],
|
51
54
|
) -> List[Optional[M]]: ...
|
55
|
+
|
52
56
|
async def extract[M: ProposedAble](
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
self,
|
58
|
+
cls: Type[M],
|
59
|
+
source: List[str] | str,
|
60
|
+
extract_requirement: Optional[str] = None,
|
61
|
+
align_language: bool = True,
|
62
|
+
**kwargs: Unpack[ValidateKwargs[Optional[M]]],
|
59
63
|
) -> M | List[M] | Optional[M] | List[Optional[M]]:
|
60
64
|
"""Extract information from a given source to a model."""
|
61
65
|
return await self.propose(
|
62
66
|
cls,
|
63
67
|
prompt=TEMPLATE_MANAGER.render_template(
|
64
|
-
|
68
|
+
CONFIG.templates.extract_template,
|
65
69
|
[{"source": s, "extract_requirement": extract_requirement} for s in source]
|
66
70
|
if isinstance(source, list)
|
67
71
|
else {"source": source, "extract_requirement": extract_requirement, "align_language": align_language},
|
fabricatio/capabilities/rag.py
CHANGED
@@ -10,16 +10,15 @@ from functools import lru_cache
|
|
10
10
|
from operator import itemgetter
|
11
11
|
from typing import List, Optional, Self, Type, Unpack
|
12
12
|
|
13
|
+
from fabricatio.rust import CONFIG, TEMPLATE_MANAGER
|
13
14
|
from more_itertools.recipes import flatten, unique
|
14
15
|
from pydantic import Field, PrivateAttr
|
15
16
|
|
16
|
-
from fabricatio.config import configs
|
17
17
|
from fabricatio.journal import logger
|
18
18
|
from fabricatio.models.adv_kwargs_types import CollectionConfigKwargs, FetchKwargs
|
19
19
|
from fabricatio.models.extra.rag import MilvusDataBase
|
20
20
|
from fabricatio.models.kwargs_types import ChooseKwargs
|
21
21
|
from fabricatio.models.usages import EmbeddingUsage
|
22
|
-
from fabricatio.rust_instances import TEMPLATE_MANAGER
|
23
22
|
from fabricatio.utils import ok
|
24
23
|
|
25
24
|
|
@@ -50,17 +49,17 @@ class RAG(EmbeddingUsage):
|
|
50
49
|
return self._client
|
51
50
|
|
52
51
|
def init_client(
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
self,
|
53
|
+
milvus_uri: Optional[str] = None,
|
54
|
+
milvus_token: Optional[str] = None,
|
55
|
+
milvus_timeout: Optional[float] = None,
|
57
56
|
) -> Self:
|
58
57
|
"""Initialize the Milvus client."""
|
59
58
|
self._client = create_client(
|
60
|
-
uri=milvus_uri or ok(self.milvus_uri or
|
59
|
+
uri=milvus_uri or ok(self.milvus_uri or CONFIG.rag.milvus_uri).unicode_string(),
|
61
60
|
token=milvus_token
|
62
|
-
|
63
|
-
timeout=milvus_timeout or self.milvus_timeout or
|
61
|
+
or (token.get_secret_value() if (token := (self.milvus_token or CONFIG.rag.milvus_token)) else ""),
|
62
|
+
timeout=milvus_timeout or self.milvus_timeout or CONFIG.rag.milvus_timeout,
|
64
63
|
)
|
65
64
|
return self
|
66
65
|
|
@@ -73,7 +72,7 @@ class RAG(EmbeddingUsage):
|
|
73
72
|
return self
|
74
73
|
|
75
74
|
def view(
|
76
|
-
|
75
|
+
self, collection_name: Optional[str], create: bool = False, **kwargs: Unpack[CollectionConfigKwargs]
|
77
76
|
) -> Self:
|
78
77
|
"""View the specified collection.
|
79
78
|
|
@@ -86,9 +85,9 @@ class RAG(EmbeddingUsage):
|
|
86
85
|
kwargs["dimension"] = ok(
|
87
86
|
kwargs.get("dimension")
|
88
87
|
or self.milvus_dimensions
|
89
|
-
or
|
88
|
+
or CONFIG.rag.milvus_dimensions
|
90
89
|
or self.embedding_dimensions
|
91
|
-
or
|
90
|
+
or CONFIG.embedding.dimensions,
|
92
91
|
"`dimension` is not set at any level.",
|
93
92
|
)
|
94
93
|
self.client.create_collection(collection_name, auto_id=True, **kwargs)
|
@@ -115,7 +114,7 @@ class RAG(EmbeddingUsage):
|
|
115
114
|
return ok(self.target_collection, "No collection is being viewed. Have you called `self.view()`?")
|
116
115
|
|
117
116
|
async def add_document[D: MilvusDataBase](
|
118
|
-
|
117
|
+
self, data: List[D] | D, collection_name: Optional[str] = None, flush: bool = False
|
119
118
|
) -> Self:
|
120
119
|
"""Adds a document to the specified collection.
|
121
120
|
|
@@ -142,15 +141,15 @@ class RAG(EmbeddingUsage):
|
|
142
141
|
return self
|
143
142
|
|
144
143
|
async def afetch_document[D: MilvusDataBase](
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
144
|
+
self,
|
145
|
+
query: List[str],
|
146
|
+
document_model: Type[D],
|
147
|
+
collection_name: Optional[str] = None,
|
148
|
+
similarity_threshold: float = 0.37,
|
149
|
+
result_per_query: int = 10,
|
150
|
+
tei_endpoint: Optional[str] = None,
|
151
|
+
reranker_threshold: float = 0.7,
|
152
|
+
filter_expr: str = "",
|
154
153
|
) -> List[D]:
|
155
154
|
"""Asynchronously fetches documents from a Milvus database based on input vectors.
|
156
155
|
|
@@ -215,11 +214,11 @@ class RAG(EmbeddingUsage):
|
|
215
214
|
return document_model.from_sequence(resp)
|
216
215
|
|
217
216
|
async def aretrieve[D: MilvusDataBase](
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
217
|
+
self,
|
218
|
+
query: List[str] | str,
|
219
|
+
document_model: Type[D],
|
220
|
+
max_accepted: int = 20,
|
221
|
+
**kwargs: Unpack[FetchKwargs],
|
223
222
|
) -> List[D]:
|
224
223
|
"""Retrieve data from the collection.
|
225
224
|
|
@@ -236,15 +235,15 @@ class RAG(EmbeddingUsage):
|
|
236
235
|
query = [query]
|
237
236
|
|
238
237
|
return (
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
238
|
+
await self.afetch_document(
|
239
|
+
query=query,
|
240
|
+
document_model=document_model,
|
241
|
+
**kwargs,
|
242
|
+
)
|
243
|
+
)[:max_accepted]
|
245
244
|
|
246
245
|
async def arefined_query(
|
247
|
-
|
246
|
+
self, question: List[str] | str, **kwargs: Unpack[ChooseKwargs[Optional[List[str]]]]
|
248
247
|
) -> Optional[List[str]]:
|
249
248
|
"""Refines the given question using a template.
|
250
249
|
|
@@ -257,7 +256,7 @@ class RAG(EmbeddingUsage):
|
|
257
256
|
"""
|
258
257
|
return await self.alist_str(
|
259
258
|
TEMPLATE_MANAGER.render_template(
|
260
|
-
|
259
|
+
CONFIG.templates.refined_query_template,
|
261
260
|
{"question": [question] if isinstance(question, str) else question},
|
262
261
|
),
|
263
262
|
**kwargs,
|