fabricatio 0.2.9.dev4__cp312-cp312-win_amd64.whl → 0.2.10.dev0__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/actions/article.py +9 -105
- fabricatio/capabilities/check.py +2 -1
- fabricatio/capabilities/rag.py +39 -232
- fabricatio/constants.py +20 -0
- fabricatio/decorators.py +23 -0
- fabricatio/models/adv_kwargs_types.py +42 -0
- fabricatio/models/events.py +6 -6
- fabricatio/models/extra/advanced_judge.py +2 -2
- fabricatio/models/extra/article_base.py +2 -186
- fabricatio/models/extra/article_main.py +12 -107
- fabricatio/models/extra/problem.py +12 -17
- fabricatio/models/extra/rag.py +72 -0
- fabricatio/models/extra/rule.py +1 -2
- fabricatio/models/generic.py +16 -9
- fabricatio/models/kwargs_types.py +1 -38
- fabricatio/models/task.py +3 -3
- fabricatio/models/usages.py +73 -5
- fabricatio/rust.cp312-win_amd64.pyd +0 -0
- fabricatio/rust.pyi +25 -5
- {fabricatio-0.2.9.dev4.data → fabricatio-0.2.10.dev0.data}/scripts/tdown.exe +0 -0
- {fabricatio-0.2.9.dev4.dist-info → fabricatio-0.2.10.dev0.dist-info}/METADATA +1 -1
- {fabricatio-0.2.9.dev4.dist-info → fabricatio-0.2.10.dev0.dist-info}/RECORD +24 -23
- fabricatio/models/utils.py +0 -148
- {fabricatio-0.2.9.dev4.dist-info → fabricatio-0.2.10.dev0.dist-info}/WHEEL +0 -0
- {fabricatio-0.2.9.dev4.dist-info → fabricatio-0.2.10.dev0.dist-info}/licenses/LICENSE +0 -0
@@ -1,48 +1,10 @@
|
|
1
1
|
"""This module contains the types for the keyword arguments of the methods in the models module."""
|
2
2
|
|
3
|
-
from importlib.util import find_spec
|
4
3
|
from typing import Any, Dict, List, Optional, Required, TypedDict
|
5
4
|
|
6
5
|
from litellm.caching.caching import CacheMode
|
7
6
|
from litellm.types.caching import CachingSupportedCallTypes
|
8
7
|
|
9
|
-
if find_spec("pymilvus"):
|
10
|
-
from pymilvus import CollectionSchema
|
11
|
-
from pymilvus.milvus_client import IndexParams
|
12
|
-
|
13
|
-
class CollectionConfigKwargs(TypedDict, total=False):
|
14
|
-
"""Configuration parameters for a vector collection.
|
15
|
-
|
16
|
-
These arguments are typically used when configuring connections to vector databases.
|
17
|
-
"""
|
18
|
-
|
19
|
-
dimension: int | None
|
20
|
-
primary_field_name: str
|
21
|
-
id_type: str
|
22
|
-
vector_field_name: str
|
23
|
-
metric_type: str
|
24
|
-
timeout: float | None
|
25
|
-
schema: CollectionSchema | None
|
26
|
-
index_params: IndexParams | None
|
27
|
-
|
28
|
-
|
29
|
-
class FetchKwargs(TypedDict, total=False):
|
30
|
-
"""Arguments for fetching data from vector collections.
|
31
|
-
|
32
|
-
Controls how data is retrieved from vector databases, including filtering
|
33
|
-
and result limiting parameters.
|
34
|
-
"""
|
35
|
-
|
36
|
-
collection_name: str | None
|
37
|
-
similarity_threshold: float
|
38
|
-
result_per_query: int
|
39
|
-
|
40
|
-
|
41
|
-
class RetrievalKwargs(FetchKwargs, total=False):
|
42
|
-
"""Arguments for retrieval operations."""
|
43
|
-
|
44
|
-
final_limit: int
|
45
|
-
|
46
8
|
|
47
9
|
class EmbeddingKwargs(TypedDict, total=False):
|
48
10
|
"""Configuration parameters for text embedding operations.
|
@@ -139,6 +101,7 @@ class ReviewKwargs[T](ReviewInnerKwargs[T], total=False):
|
|
139
101
|
|
140
102
|
class ReferencedKwargs[T](ValidateKwargs[T], total=False):
|
141
103
|
"""Arguments for content review operations."""
|
104
|
+
|
142
105
|
reference: str
|
143
106
|
|
144
107
|
|
fabricatio/models/task.py
CHANGED
@@ -7,11 +7,11 @@ from asyncio import Queue
|
|
7
7
|
from typing import Any, List, Optional, Self
|
8
8
|
|
9
9
|
from fabricatio.config import configs
|
10
|
+
from fabricatio.constants import TaskStatus
|
10
11
|
from fabricatio.core import env
|
11
12
|
from fabricatio.journal import logger
|
12
13
|
from fabricatio.models.events import Event, EventLike
|
13
14
|
from fabricatio.models.generic import ProposedAble, WithBriefing, WithDependency
|
14
|
-
from fabricatio.models.utils import TaskStatus
|
15
15
|
from fabricatio.rust_instances import TEMPLATE_MANAGER
|
16
16
|
from pydantic import Field, PrivateAttr
|
17
17
|
|
@@ -112,12 +112,12 @@ class Task[T](WithBriefing, ProposedAble, WithDependency):
|
|
112
112
|
"""Return a formatted status label for the task.
|
113
113
|
|
114
114
|
Args:
|
115
|
-
status (TaskStatus): The status of the task.
|
115
|
+
status (fabricatio.constants.TaskStatus): The status of the task.
|
116
116
|
|
117
117
|
Returns:
|
118
118
|
str: The formatted status label.
|
119
119
|
"""
|
120
|
-
return self._namespace.derive(self.name).push(status
|
120
|
+
return self._namespace.derive(self.name).push(status).collapse()
|
121
121
|
|
122
122
|
@property
|
123
123
|
def pending_label(self) -> str:
|
fabricatio/models/usages.py
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
import traceback
|
4
4
|
from asyncio import gather
|
5
|
-
from typing import Callable, Dict, Iterable, List, Optional, Self, Sequence, Set, Union, Unpack, overload
|
5
|
+
from typing import Callable, Dict, Iterable, List, Literal, Optional, Self, Sequence, Set, Union, Unpack, overload
|
6
6
|
|
7
7
|
import asyncstdlib
|
8
8
|
import litellm
|
@@ -13,7 +13,6 @@ from fabricatio.models.generic import ScopedConfig, WithBriefing
|
|
13
13
|
from fabricatio.models.kwargs_types import ChooseKwargs, EmbeddingKwargs, GenerateKwargs, LLMKwargs, ValidateKwargs
|
14
14
|
from fabricatio.models.task import Task
|
15
15
|
from fabricatio.models.tool import Tool, ToolBox
|
16
|
-
from fabricatio.models.utils import Messages
|
17
16
|
from fabricatio.parser import GenericCapture, JsonCapture
|
18
17
|
from fabricatio.rust_instances import TEMPLATE_MANAGER
|
19
18
|
from fabricatio.utils import ok
|
@@ -28,7 +27,7 @@ from litellm.types.utils import (
|
|
28
27
|
)
|
29
28
|
from litellm.utils import CustomStreamWrapper, token_counter # pyright: ignore [reportPrivateImportUsage]
|
30
29
|
from more_itertools import duplicates_everseen
|
31
|
-
from pydantic import Field, NonNegativeInt, PositiveInt
|
30
|
+
from pydantic import BaseModel, ConfigDict, Field, NonNegativeInt, PositiveInt
|
32
31
|
|
33
32
|
if configs.cache.enabled and configs.cache.type:
|
34
33
|
litellm.enable_cache(type=configs.cache.type, **configs.cache.params)
|
@@ -303,7 +302,7 @@ class LLMUsage(ScopedConfig):
|
|
303
302
|
and logger.debug("Co-extraction is enabled.") is None
|
304
303
|
and (
|
305
304
|
validated := validator(
|
306
|
-
response:=await self.aask(
|
305
|
+
response := await self.aask(
|
307
306
|
question=(
|
308
307
|
TEMPLATE_MANAGER.render_template(
|
309
308
|
configs.templates.co_validation_template,
|
@@ -495,7 +494,7 @@ class LLMUsage(ScopedConfig):
|
|
495
494
|
affirm_case: str = "",
|
496
495
|
deny_case: str = "",
|
497
496
|
**kwargs: Unpack[ValidateKwargs[bool]],
|
498
|
-
) -> bool:
|
497
|
+
) -> Optional[bool]:
|
499
498
|
"""Asynchronously judges a prompt using AI validation.
|
500
499
|
|
501
500
|
Args:
|
@@ -732,3 +731,72 @@ class ToolBoxUsage(LLMUsage):
|
|
732
731
|
for other in (x for x in others if isinstance(x, ToolBoxUsage)):
|
733
732
|
other.toolboxes.update(self.toolboxes)
|
734
733
|
return self
|
734
|
+
|
735
|
+
|
736
|
+
class Message(BaseModel):
|
737
|
+
"""A class representing a message."""
|
738
|
+
|
739
|
+
model_config = ConfigDict(use_attribute_docstrings=True)
|
740
|
+
role: Literal["user", "system", "assistant"]
|
741
|
+
"""The role of the message sender."""
|
742
|
+
content: str
|
743
|
+
"""The content of the message."""
|
744
|
+
|
745
|
+
|
746
|
+
class Messages(list):
|
747
|
+
"""A list of messages."""
|
748
|
+
|
749
|
+
def add_message(self, role: Literal["user", "system", "assistant"], content: str) -> Self:
|
750
|
+
"""Adds a message to the list with the specified role and content.
|
751
|
+
|
752
|
+
Args:
|
753
|
+
role (Literal["user", "system", "assistant"]): The role of the message sender.
|
754
|
+
content (str): The content of the message.
|
755
|
+
|
756
|
+
Returns:
|
757
|
+
Self: The current instance of Messages to allow method chaining.
|
758
|
+
"""
|
759
|
+
if content:
|
760
|
+
self.append(Message(role=role, content=content))
|
761
|
+
return self
|
762
|
+
|
763
|
+
def add_user_message(self, content: str) -> Self:
|
764
|
+
"""Adds a user message to the list with the specified content.
|
765
|
+
|
766
|
+
Args:
|
767
|
+
content (str): The content of the user message.
|
768
|
+
|
769
|
+
Returns:
|
770
|
+
Self: The current instance of Messages to allow method chaining.
|
771
|
+
"""
|
772
|
+
return self.add_message("user", content)
|
773
|
+
|
774
|
+
def add_system_message(self, content: str) -> Self:
|
775
|
+
"""Adds a system message to the list with the specified content.
|
776
|
+
|
777
|
+
Args:
|
778
|
+
content (str): The content of the system message.
|
779
|
+
|
780
|
+
Returns:
|
781
|
+
Self: The current instance of Messages to allow method chaining.
|
782
|
+
"""
|
783
|
+
return self.add_message("system", content)
|
784
|
+
|
785
|
+
def add_assistant_message(self, content: str) -> Self:
|
786
|
+
"""Adds an assistant message to the list with the specified content.
|
787
|
+
|
788
|
+
Args:
|
789
|
+
content (str): The content of the assistant message.
|
790
|
+
|
791
|
+
Returns:
|
792
|
+
Self: The current instance of Messages to allow method chaining.
|
793
|
+
"""
|
794
|
+
return self.add_message("assistant", content)
|
795
|
+
|
796
|
+
def as_list(self) -> List[Dict[str, str]]:
|
797
|
+
"""Converts the messages to a list of dictionaries.
|
798
|
+
|
799
|
+
Returns:
|
800
|
+
list[dict]: A list of dictionaries representing the messages.
|
801
|
+
"""
|
802
|
+
return [message.model_dump() for message in self]
|
Binary file
|
fabricatio/rust.pyi
CHANGED
@@ -12,9 +12,7 @@ Key Features:
|
|
12
12
|
"""
|
13
13
|
|
14
14
|
from pathlib import Path
|
15
|
-
from typing import List, Optional
|
16
|
-
|
17
|
-
from pydantic import JsonValue
|
15
|
+
from typing import Any, Dict, List, Optional
|
18
16
|
|
19
17
|
class TemplateManager:
|
20
18
|
"""Template rendering engine using Handlebars templates.
|
@@ -56,7 +54,7 @@ class TemplateManager:
|
|
56
54
|
This refreshes the template cache, finding any new or modified templates.
|
57
55
|
"""
|
58
56
|
|
59
|
-
def render_template(self, name: str, data:
|
57
|
+
def render_template(self, name: str, data: Dict[str, Any]) -> str:
|
60
58
|
"""Render a template with context data.
|
61
59
|
|
62
60
|
Args:
|
@@ -70,7 +68,7 @@ class TemplateManager:
|
|
70
68
|
RuntimeError: If template rendering fails
|
71
69
|
"""
|
72
70
|
|
73
|
-
def render_template_raw(self, template: str, data:
|
71
|
+
def render_template_raw(self, template: str, data: Dict[str, Any]) -> str:
|
74
72
|
"""Render a template with context data.
|
75
73
|
|
76
74
|
Args:
|
@@ -104,6 +102,28 @@ def split_word_bounds(string: str) -> List[str]:
|
|
104
102
|
A list of words extracted from the string.
|
105
103
|
"""
|
106
104
|
|
105
|
+
def split_sentence_bounds(string: str) -> List[str]:
|
106
|
+
"""Split the string into sentences based on sentence boundaries.
|
107
|
+
|
108
|
+
Args:
|
109
|
+
string: The input string to be split.
|
110
|
+
|
111
|
+
Returns:
|
112
|
+
A list of sentences extracted from the string.
|
113
|
+
"""
|
114
|
+
|
115
|
+
def split_into_chunks(string: str, max_chunk_size: int, max_overlapping_rate: float = 0.3) -> List[str]:
|
116
|
+
"""Split the string into chunks of a specified size.
|
117
|
+
|
118
|
+
Args:
|
119
|
+
string: The input string to be split.
|
120
|
+
max_chunk_size: The maximum size of each chunk.
|
121
|
+
max_overlapping_rate: The minimum overlapping rate between chunks.
|
122
|
+
|
123
|
+
Returns:
|
124
|
+
A list of chunks extracted from the string.
|
125
|
+
"""
|
126
|
+
|
107
127
|
def word_count(string: str) -> int:
|
108
128
|
"""Count the number of words in the string.
|
109
129
|
|
Binary file
|
@@ -1,7 +1,7 @@
|
|
1
|
-
fabricatio-0.2.
|
2
|
-
fabricatio-0.2.
|
3
|
-
fabricatio-0.2.
|
4
|
-
fabricatio/actions/article.py,sha256=
|
1
|
+
fabricatio-0.2.10.dev0.dist-info/METADATA,sha256=P8fqqWkcxcC1a42_I3GdmnP6qB8ZKsGoqyn4u-9yRT4,5289
|
2
|
+
fabricatio-0.2.10.dev0.dist-info/WHEEL,sha256=jABKVkLC9kJr8mi_er5jOqpiQUjARSLXDUIIxDqsS50,96
|
3
|
+
fabricatio-0.2.10.dev0.dist-info/licenses/LICENSE,sha256=do7J7EiCGbq0QPbMAL_FqLYufXpHnCnXBOuqVPwSV8Y,1088
|
4
|
+
fabricatio/actions/article.py,sha256=C4t3hB5_k4dDrVuLzVTJIp3D6XyvvlRyGIov5-mNows,8984
|
5
5
|
fabricatio/actions/article_rag.py,sha256=itGH-VCKTVFm7hrYIOOT4FyFXP8CbL042kpYNI9a2BE,4735
|
6
6
|
fabricatio/actions/output.py,sha256=gkC2u_VpMJ6jOnbyRAJN24UVK7iDAMzhItYukaW8Spk,6498
|
7
7
|
fabricatio/actions/rag.py,sha256=5nSih3YUkdt1uU02hSAMW6sADq9mkMOR1wDv7zIrIGQ,2737
|
@@ -9,44 +9,45 @@ fabricatio/actions/rules.py,sha256=SNvAvQx4xUare16Za_dEpYlYI_PJNnbiO-E0XDa5JT4,2
|
|
9
9
|
fabricatio/actions/__init__.py,sha256=wVENCFtpVb1rLFxoOFJt9-8smLWXuJV7IwA8P3EfFz4,48
|
10
10
|
fabricatio/capabilities/advanced_judge.py,sha256=selB0Gwf1F4gGJlwBiRo6gI4KOUROgh3WnzO3mZFEls,706
|
11
11
|
fabricatio/capabilities/censor.py,sha256=bBT5qy-kp7fh8g4Lz3labSwxwJ60gGd_vrkc6k1cZ1U,4719
|
12
|
-
fabricatio/capabilities/check.py,sha256=
|
12
|
+
fabricatio/capabilities/check.py,sha256=kYqzohhv2bZfl1aKSUt7a8snT8YEl2zgha_ZdAdMMfQ,8622
|
13
13
|
fabricatio/capabilities/correct.py,sha256=W_cInqlciNEhyMK0YI53jk4EvW9uAdge90IO9OElUmA,10420
|
14
14
|
fabricatio/capabilities/propose.py,sha256=hkBeSlmcTdfYWT-ph6nlbtHXBozi_JXqXlWcnBy3W78,2007
|
15
|
-
fabricatio/capabilities/rag.py,sha256=
|
15
|
+
fabricatio/capabilities/rag.py,sha256=eWA4lDs6lnBFCK80H1JF68yOe7oScydQekXlBs2X0OI,9396
|
16
16
|
fabricatio/capabilities/rating.py,sha256=Wt_H5fA1H4XuZGIMI8pr0cp_6jnXJABlo8lfU_4Fp5A,17645
|
17
17
|
fabricatio/capabilities/review.py,sha256=-EMZe0ADFPT6fPGmra16UPjJC1M3rAs6dPFdTZ88Fgg,5060
|
18
18
|
fabricatio/capabilities/task.py,sha256=JahC61X233UIPsjovxJgc_yqj_BjWZJBCzJZq11M2Xk,4417
|
19
19
|
fabricatio/capabilities/__init__.py,sha256=v1cHRHIJ2gxyqMLNCs6ERVcCakSasZNYzmMI4lqAcls,57
|
20
20
|
fabricatio/config.py,sha256=gqhdKxoj4S0EmQKprAEWUARn7yJg-w5UJ7d7GPlyttw,17631
|
21
|
+
fabricatio/constants.py,sha256=thfDuF6JEtJ5CHOnAJLfqvn5834n8ep6DH2jc6XGzQM,577
|
21
22
|
fabricatio/core.py,sha256=VQ_JKgUGIy2gZ8xsTBZCdr_IP7wC5aPg0_bsOmjQ588,6458
|
22
|
-
fabricatio/decorators.py,sha256
|
23
|
+
fabricatio/decorators.py,sha256=-rLj9OXRfzY2E2euLKAHNRcWXjA1teLElg4zZYdIojs,8291
|
23
24
|
fabricatio/fs/curd.py,sha256=p8y0LGKgVDk-CWOlm37E6wg7RK6RCD6denKo-VsW28c,4763
|
24
25
|
fabricatio/fs/readers.py,sha256=M5kojKWsJQMQpE4CBbYvas0JKmPaiaYSfWmiqJx1SP4,1884
|
25
26
|
fabricatio/fs/__init__.py,sha256=PCf0s_9KDjVfNw7AfPoJzGt3jMq4gJOfbcT4pb0D0ZY,588
|
26
27
|
fabricatio/journal.py,sha256=stnEP88aUBA_GmU9gfTF2EZI8FS2OyMLGaMSTgK4QgA,476
|
27
28
|
fabricatio/models/action.py,sha256=Kfa-zojgHQ1vPoC2lQp-thTTp0oySKn7k6I4ea6iYTs,9837
|
28
|
-
fabricatio/models/adv_kwargs_types.py,sha256=
|
29
|
-
fabricatio/models/events.py,sha256=
|
30
|
-
fabricatio/models/extra/advanced_judge.py,sha256=
|
31
|
-
fabricatio/models/extra/article_base.py,sha256=
|
29
|
+
fabricatio/models/adv_kwargs_types.py,sha256=YojZbB7m7VHA8woYnJpkLF4zPF2aYqv__SnCMK2cG-o,2180
|
30
|
+
fabricatio/models/events.py,sha256=wiirk_ASg3iXDOZU_gIimci1VZVzWE1nDmxy-hQVJ9M,4150
|
31
|
+
fabricatio/models/extra/advanced_judge.py,sha256=INUl_41C8jkausDekkjnEmTwNfLCJ23TwFjq2cM23Cw,1092
|
32
|
+
fabricatio/models/extra/article_base.py,sha256=DxBex4UsMAFmHmriwXkcvGIuU-WTSD4ZfzDEk-no9TA,11894
|
32
33
|
fabricatio/models/extra/article_essence.py,sha256=xd6j-PDqjhrMjgUmyfk6HqkyMLu-sS9feUo0sZ3QABY,2825
|
33
|
-
fabricatio/models/extra/article_main.py,sha256=
|
34
|
+
fabricatio/models/extra/article_main.py,sha256=zGzcf51abcWwiaX6iyi2V7upBLa-DBovnpTJj-qYLeA,7878
|
34
35
|
fabricatio/models/extra/article_outline.py,sha256=w7O0SHgC7exbptWVbR62FMHAueMgBpyWKVYMGGl_oj8,1427
|
35
36
|
fabricatio/models/extra/article_proposal.py,sha256=NbyjW-7UiFPtnVD9nte75re4xL2pD4qL29PpNV4Cg_M,1870
|
36
37
|
fabricatio/models/extra/patches.py,sha256=_WNCxtYzzsVfUxI16vu4IqsLahLYRHdbQN9er9tqhC0,997
|
37
|
-
fabricatio/models/extra/problem.py,sha256=
|
38
|
-
fabricatio/models/extra/
|
38
|
+
fabricatio/models/extra/problem.py,sha256=zZEnjBW2XGRVpJpUp09f1J_w5A1zU-LhxX78AVCq9ts,7113
|
39
|
+
fabricatio/models/extra/rag.py,sha256=_atfPwk3nzhiilAOC5H1WMBgTxcZvDn3qx0CVhETlZ8,2561
|
40
|
+
fabricatio/models/extra/rule.py,sha256=KQQELVhCLUXhEZ35jU3WGYqKHuCYEAkn0p6pxAE-hOU,2625
|
39
41
|
fabricatio/models/extra/__init__.py,sha256=XlYnS_2B9nhLhtQkjE7rvvfPmAAtXVdNi9bSDAR-Ge8,54
|
40
|
-
fabricatio/models/generic.py,sha256=
|
41
|
-
fabricatio/models/kwargs_types.py,sha256=
|
42
|
+
fabricatio/models/generic.py,sha256=BS-K8Rd_1aLU9jIExtXScvzNZ-lsBCmHlaBCjNJ6g3s,30655
|
43
|
+
fabricatio/models/kwargs_types.py,sha256=J4klrMVybkCWg8Fq4x27o5QSq8jmGg2XvneW66jI0Wc,4565
|
42
44
|
fabricatio/models/role.py,sha256=-CRcj5_M3_ciLPzwiNn92grBmwoSLQ-n4koVZiCNTBM,2953
|
43
|
-
fabricatio/models/task.py,sha256=
|
45
|
+
fabricatio/models/task.py,sha256=SxWI-b5jlQcGmNsjQ2aKDyywXwGiUvCR1rgUhk-pli8,10503
|
44
46
|
fabricatio/models/tool.py,sha256=jQ51g4lwTPfsMF1nbreDJtBczbxIHoXcPuLSOqHliq8,12506
|
45
|
-
fabricatio/models/usages.py,sha256=
|
46
|
-
fabricatio/models/utils.py,sha256=Ac5g-8ic6q_w7dhNuh-iiofpL1sqOACxbjPPTljP2LY,4417
|
47
|
+
fabricatio/models/usages.py,sha256=VLBpNs7zfNPqROvI2IXlqsoqKYSW8L6usNwZ1HXZVOY,34339
|
47
48
|
fabricatio/parser.py,sha256=qN2godNsArmb90btOMxgqlol57166DyYsV2JlU8DlHs,6532
|
48
49
|
fabricatio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
49
|
-
fabricatio/rust.pyi,sha256=
|
50
|
+
fabricatio/rust.pyi,sha256=vSItFXKj7YG6b7gmObMo99rWztsiYj4Ji124UNJbhd0,6957
|
50
51
|
fabricatio/rust_instances.py,sha256=Byeo8KHW_dJiXujJq7YPGDLBX5bHNDYbBc4sY3uubVY,313
|
51
52
|
fabricatio/toolboxes/arithmetic.py,sha256=WLqhY-Pikv11Y_0SGajwZx3WhsLNpHKf9drzAqOf_nY,1369
|
52
53
|
fabricatio/toolboxes/fs.py,sha256=l4L1CVxJmjw9Ld2XUpIlWfV0_Fu_2Og6d3E13I-S4aE,736
|
@@ -56,6 +57,6 @@ fabricatio/workflows/articles.py,sha256=ObYTFUqLUk_CzdmmnX6S7APfxcGmPFqnFr9pdjU7
|
|
56
57
|
fabricatio/workflows/rag.py,sha256=-YYp2tlE9Vtfgpg6ROpu6QVO8j8yVSPa6yDzlN3qVxs,520
|
57
58
|
fabricatio/workflows/__init__.py,sha256=5ScFSTA-bvhCesj3U9Mnmi6Law6N1fmh5UKyh58L3u8,51
|
58
59
|
fabricatio/__init__.py,sha256=Rmvq2VgdS2u68vnOi2i5RbeWbAwrJDbk8D8D883PJWE,1022
|
59
|
-
fabricatio/rust.cp312-win_amd64.pyd,sha256=
|
60
|
-
fabricatio-0.2.
|
61
|
-
fabricatio-0.2.
|
60
|
+
fabricatio/rust.cp312-win_amd64.pyd,sha256=pgavk4szzu7Fdb8oC-IK3XmhB9upqwxJxkMG_Ep65eQ,2235904
|
61
|
+
fabricatio-0.2.10.dev0.data/scripts/tdown.exe,sha256=hH6MCz4SZWxYNzpNzlZ3KzTM2-H_wFyxMrKie4K24Go,3364864
|
62
|
+
fabricatio-0.2.10.dev0.dist-info/RECORD,,
|
fabricatio/models/utils.py
DELETED
@@ -1,148 +0,0 @@
|
|
1
|
-
"""A module containing utility classes for the models."""
|
2
|
-
|
3
|
-
from enum import Enum
|
4
|
-
from typing import Any, Dict, List, Literal, Optional, Self
|
5
|
-
|
6
|
-
from pydantic import BaseModel, ConfigDict, Field
|
7
|
-
|
8
|
-
|
9
|
-
class Message(BaseModel):
|
10
|
-
"""A class representing a message."""
|
11
|
-
|
12
|
-
model_config = ConfigDict(use_attribute_docstrings=True)
|
13
|
-
role: Literal["user", "system", "assistant"]
|
14
|
-
"""
|
15
|
-
Who is sending the message.
|
16
|
-
"""
|
17
|
-
content: str
|
18
|
-
"""
|
19
|
-
The content of the message.
|
20
|
-
"""
|
21
|
-
|
22
|
-
|
23
|
-
class Messages(list):
|
24
|
-
"""A list of messages."""
|
25
|
-
|
26
|
-
def add_message(self, role: Literal["user", "system", "assistant"], content: str) -> Self:
|
27
|
-
"""Adds a message to the list with the specified role and content.
|
28
|
-
|
29
|
-
Args:
|
30
|
-
role (Literal["user", "system", "assistant"]): The role of the message sender.
|
31
|
-
content (str): The content of the message.
|
32
|
-
|
33
|
-
Returns:
|
34
|
-
Self: The current instance of Messages to allow method chaining.
|
35
|
-
"""
|
36
|
-
if content:
|
37
|
-
self.append(Message(role=role, content=content))
|
38
|
-
return self
|
39
|
-
|
40
|
-
def add_user_message(self, content: str) -> Self:
|
41
|
-
"""Adds a user message to the list with the specified content.
|
42
|
-
|
43
|
-
Args:
|
44
|
-
content (str): The content of the user message.
|
45
|
-
|
46
|
-
Returns:
|
47
|
-
Self: The current instance of Messages to allow method chaining.
|
48
|
-
"""
|
49
|
-
return self.add_message("user", content)
|
50
|
-
|
51
|
-
def add_system_message(self, content: str) -> Self:
|
52
|
-
"""Adds a system message to the list with the specified content.
|
53
|
-
|
54
|
-
Args:
|
55
|
-
content (str): The content of the system message.
|
56
|
-
|
57
|
-
Returns:
|
58
|
-
Self: The current instance of Messages to allow method chaining.
|
59
|
-
"""
|
60
|
-
return self.add_message("system", content)
|
61
|
-
|
62
|
-
def add_assistant_message(self, content: str) -> Self:
|
63
|
-
"""Adds an assistant message to the list with the specified content.
|
64
|
-
|
65
|
-
Args:
|
66
|
-
content (str): The content of the assistant message.
|
67
|
-
|
68
|
-
Returns:
|
69
|
-
Self: The current instance of Messages to allow method chaining.
|
70
|
-
"""
|
71
|
-
return self.add_message("assistant", content)
|
72
|
-
|
73
|
-
def as_list(self) -> List[Dict[str, str]]:
|
74
|
-
"""Converts the messages to a list of dictionaries.
|
75
|
-
|
76
|
-
Returns:
|
77
|
-
list[dict]: A list of dictionaries representing the messages.
|
78
|
-
"""
|
79
|
-
return [message.model_dump() for message in self]
|
80
|
-
|
81
|
-
|
82
|
-
class MilvusData(BaseModel):
|
83
|
-
"""A class representing data stored in Milvus."""
|
84
|
-
|
85
|
-
model_config = ConfigDict(use_attribute_docstrings=True)
|
86
|
-
id: Optional[int] = Field(default=None)
|
87
|
-
"""The identifier of the data."""
|
88
|
-
|
89
|
-
vector: List[float]
|
90
|
-
"""The vector representation of the data."""
|
91
|
-
|
92
|
-
text: str
|
93
|
-
"""The text representation of the data."""
|
94
|
-
|
95
|
-
subject: Optional[str] = Field(default=None)
|
96
|
-
"""A subject label that we use to demo metadata filtering later."""
|
97
|
-
|
98
|
-
def prepare_insertion(self) -> Dict[str, Any]:
|
99
|
-
"""Prepares the data for insertion into Milvus.
|
100
|
-
|
101
|
-
Returns:
|
102
|
-
dict: A dictionary containing the data to be inserted into Milvus.
|
103
|
-
"""
|
104
|
-
return self.model_dump(exclude_none=True)
|
105
|
-
|
106
|
-
def update_subject(self, new_subject: str) -> Self:
|
107
|
-
"""Updates the subject label of the data.
|
108
|
-
|
109
|
-
Args:
|
110
|
-
new_subject (str): The new subject label.
|
111
|
-
|
112
|
-
Returns:
|
113
|
-
Self: The updated instance of MilvusData.
|
114
|
-
"""
|
115
|
-
self.subject = new_subject
|
116
|
-
return self
|
117
|
-
|
118
|
-
def update_id(self, new_id: int) -> Self:
|
119
|
-
"""Updates the identifier of the data.
|
120
|
-
|
121
|
-
Args:
|
122
|
-
new_id (int): The new identifier.
|
123
|
-
|
124
|
-
Returns:
|
125
|
-
Self: The updated instance of MilvusData.
|
126
|
-
"""
|
127
|
-
self.id = new_id
|
128
|
-
return self
|
129
|
-
|
130
|
-
|
131
|
-
class TaskStatus(Enum):
|
132
|
-
"""An enumeration representing the status of a task.
|
133
|
-
|
134
|
-
Attributes:
|
135
|
-
Pending: The task is pending.
|
136
|
-
Running: The task is currently running.
|
137
|
-
Finished: The task has been successfully completed.
|
138
|
-
Failed: The task has failed.
|
139
|
-
Cancelled: The task has been cancelled.
|
140
|
-
"""
|
141
|
-
|
142
|
-
Pending = "pending"
|
143
|
-
Running = "running"
|
144
|
-
Finished = "finished"
|
145
|
-
Failed = "failed"
|
146
|
-
Cancelled = "cancelled"
|
147
|
-
|
148
|
-
|
File without changes
|
File without changes
|