nucliadb-models 6.8.1.post5003__py3-none-any.whl → 6.9.0.post5008__py3-none-any.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.

Potentially problematic release.


This version of nucliadb-models might be problematic. Click here for more details.

nucliadb_models/search.py CHANGED
@@ -1008,6 +1008,12 @@ class Reasoning(BaseModel):
1008
1008
  )
1009
1009
 
1010
1010
 
1011
+ class CitationsType(str, Enum):
1012
+ NONE = "none"
1013
+ DEFAULT = "default"
1014
+ LLM_FOOTNOTES = "llm_footnotes"
1015
+
1016
+
1011
1017
  class ChatModel(BaseModel):
1012
1018
  """
1013
1019
  This is the model for the predict request payload on the chat endpoint
@@ -1039,10 +1045,16 @@ class ChatModel(BaseModel):
1039
1045
  user_prompt: Optional[UserPrompt] = Field(
1040
1046
  default=None, description="Optional custom prompt input by the user"
1041
1047
  )
1042
- citations: bool = Field(default=False, description="Whether to include the citations in the answer")
1048
+ citations: Union[bool, None, CitationsType] = Field(
1049
+ default=None,
1050
+ description="Whether to include citations in the response. "
1051
+ "If set to None or False, no citations will be computed. "
1052
+ "If set to True or 'default', citations will be computed after answer generation and send as a separate `CitationsGenerativeResponse` chunk"
1053
+ "If set to 'llm_footnotes', citations will be included in the LLM's response as markdown-styled footnotes. A `FootnoteCitationsGenerativeResponse` chunk will also be sent to map footnote ids to context keys in the `query_context`.",
1054
+ )
1043
1055
  citation_threshold: Optional[float] = Field(
1044
1056
  default=None,
1045
- description="If citations is True, this sets the similarity threshold (0 to 1) for paragraphs to be included as citations. Lower values result in more citations. If not provided, Nuclia's default threshold is used.", # noqa: E501
1057
+ description="If citations is set to True or 'default', this will be the similarity threshold. Value between 0 and 1, lower values will produce more citations. If not set, it will be set to the optimized threshold found by Nuclia.",
1046
1058
  ge=0.0,
1047
1059
  le=1.0,
1048
1060
  )
@@ -1616,13 +1628,16 @@ class AskRequest(AuditMetadataBase):
1616
1628
  )
1617
1629
  rank_fusion: Union[RankFusionName, RankFusion] = SearchParamDefaults.rank_fusion.to_pydantic_field()
1618
1630
  reranker: Union[RerankerName, Reranker] = SearchParamDefaults.reranker.to_pydantic_field()
1619
- citations: bool = Field(
1620
- default=False,
1621
- description="Whether to include the citations for the answer in the response",
1631
+ citations: Union[bool, None, CitationsType] = Field(
1632
+ default=None,
1633
+ description="Whether to include citations in the response. "
1634
+ "If set to None or False, no citations will be computed. "
1635
+ "If set to True or 'default', citations will be computed after answer generation and send as a separate `CitationsGenerativeResponse` chunk"
1636
+ "If set to 'llm_footnotes', citations will be included in the LLM's response as markdown-styled footnotes. A `FootnoteCitationsGenerativeResponse` chunk will also be sent to map footnote ids to context keys in the `query_context`.",
1622
1637
  )
1623
1638
  citation_threshold: Optional[float] = Field(
1624
1639
  default=None,
1625
- description="If citations is True, this sets the similarity threshold (0 to 1) for paragraphs to be included as citations. Lower values result in more citations. If not provided, Nuclia's default threshold is used.",
1640
+ description="If citations is set to True or 'default', this will be the similarity threshold. Value between 0 and 1, lower values will produce more citations. If not set, it will be set to the optimized threshold found by Nuclia.",
1626
1641
  ge=0.0,
1627
1642
  le=1.0,
1628
1643
  )
@@ -2257,10 +2272,15 @@ class SyncAskResponse(BaseModel):
2257
2272
  description="The detected relations of the answer",
2258
2273
  )
2259
2274
  citations: dict[str, Any] = Field(
2260
- default={},
2275
+ default_factory=dict,
2261
2276
  title="Citations",
2262
2277
  description="The citations of the answer. List of references to the resources used to generate the answer.",
2263
2278
  )
2279
+ citation_footnote_to_context: dict[str, str] = Field(
2280
+ default_factory=dict,
2281
+ title="Citation footnote to context",
2282
+ description="""Maps ids in the footnote citations to query_context keys (normally paragraph ids)""",
2283
+ )
2264
2284
  augmented_context: Optional[AugmentedContext] = Field(
2265
2285
  default=None,
2266
2286
  description=(
@@ -2370,6 +2390,18 @@ class CitationsAskResponseItem(BaseModel):
2370
2390
  citations: dict[str, Any]
2371
2391
 
2372
2392
 
2393
+ class FootnoteCitationsAskResponseItem(BaseModel):
2394
+ type: Literal["footnote_citations"] = "footnote_citations"
2395
+ footnote_to_context: dict[str, str] = Field(
2396
+ description="""Maps ids in the footnote citations to query_context keys (normally paragraph ids)
2397
+ e.g.,
2398
+ { "block-AA": "f44f4e8acbfb1d48de3fd3c2fb04a885/f/f44f4e8acbfb1d48de3fd3c2fb04a885/73758-73972", ... }
2399
+ If the query_context is a list, it will map to 1-based indices as strings
2400
+ e.g., { "block-AA": "1", "block-AB": "2", ... }
2401
+ """
2402
+ )
2403
+
2404
+
2373
2405
  class StatusAskResponseItem(BaseModel):
2374
2406
  type: Literal["status"] = "status"
2375
2407
  code: str
@@ -2400,6 +2432,7 @@ AskResponseItemType = Union[
2400
2432
  MetadataAskResponseItem,
2401
2433
  AugmentedContextResponseItem,
2402
2434
  CitationsAskResponseItem,
2435
+ FootnoteCitationsAskResponseItem,
2403
2436
  StatusAskResponseItem,
2404
2437
  ErrorAskResponseItem,
2405
2438
  RetrievalAskResponseItem,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nucliadb_models
3
- Version: 6.8.1.post5003
3
+ Version: 6.9.0.post5008
4
4
  Author-email: Nuclia <nucliadb@nuclia.com>
5
5
  License-Expression: Apache-2.0
6
6
  Project-URL: Homepage, https://nuclia.com
@@ -17,7 +17,7 @@ nucliadb_models/notifications.py,sha256=mna8-AoD_29Wds0Thl0AF0zpERnJmYGLZX1w1fUo
17
17
  nucliadb_models/processing.py,sha256=nhKuHQjqCdb9zJVkYGPTLub23tK9e_lwL5OCDVymZjY,719
18
18
  nucliadb_models/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  nucliadb_models/resource.py,sha256=RzCos0QRgSMkaV-p7EoceSmt7UTzt9G9be5BKF-iGrQ,9021
20
- nucliadb_models/search.py,sha256=d1KTOxd2VDKTkrJmwKSqOcZ8lcSXZpULK7a5zbMUS2c,94050
20
+ nucliadb_models/search.py,sha256=-1DECYhsVxNXAdsVnSgbvZiYqtCzFTjyahOl373otj8,95958
21
21
  nucliadb_models/security.py,sha256=opxaDLfvk3aU0sjesK0jGrYLx5h4YCwlKKN0moYs_ig,1150
22
22
  nucliadb_models/synonyms.py,sha256=afbaVqSQSxGLwi2PusVaLSRpkOtA5AZmWOKd1f4nl2E,690
23
23
  nucliadb_models/text.py,sha256=60bxZnOjRHnDdezR8VfR3AZsXTOwePFPs2BKB8wxBak,3414
@@ -33,7 +33,7 @@ nucliadb_models/graph/responses.py,sha256=Sdq8OgFAL1YT-1lJyLLrkqcScvj7YTEqAUwQ-k
33
33
  nucliadb_models/internal/__init__.py,sha256=zG33bUz1rHFPtvqQPWn4rDwBJt3FJodGuQYD45quiQg,583
34
34
  nucliadb_models/internal/predict.py,sha256=Pnx6MmLfK65eExe1XnVxqmSlvMwdowewwks9BOEoqMw,2029
35
35
  nucliadb_models/internal/shards.py,sha256=__y1OZtWGiNcPQEWfSFOj8yw458WGi7mM4vZe0K-L1Y,1691
36
- nucliadb_models-6.8.1.post5003.dist-info/METADATA,sha256=RBhoIFB5eNSgVDGBGzpbZUqxcII99eFaKZ-60dTCjDE,794
37
- nucliadb_models-6.8.1.post5003.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
38
- nucliadb_models-6.8.1.post5003.dist-info/top_level.txt,sha256=UrY1I8oeovIRwkXLYplssTrxQdUjhSEFDFbnwaIV3tA,16
39
- nucliadb_models-6.8.1.post5003.dist-info/RECORD,,
36
+ nucliadb_models-6.9.0.post5008.dist-info/METADATA,sha256=0EBLCp5IO5SqtzF-cGS-5FS0XVdDLEYfPhZq_C4B7PM,794
37
+ nucliadb_models-6.9.0.post5008.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
38
+ nucliadb_models-6.9.0.post5008.dist-info/top_level.txt,sha256=UrY1I8oeovIRwkXLYplssTrxQdUjhSEFDFbnwaIV3tA,16
39
+ nucliadb_models-6.9.0.post5008.dist-info/RECORD,,