Skip to content

Commit

Permalink
🏷️ Make evidence value optional (#174)
Browse files Browse the repository at this point in the history
* 📝 Make evidence value optional

Signed-off-by: Evaline Ju <[email protected]>

* 🏷️💡 Make evidence value optional

Signed-off-by: Evaline Ju <[email protected]>

---------

Signed-off-by: Evaline Ju <[email protected]>
  • Loading branch information
evaline-ju authored Aug 22, 2024
1 parent 6ef348a commit de0aa8c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
2 changes: 0 additions & 2 deletions docs/api/openapi_detector_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ components:
type: object
required:
- name
- value
title: Evidence
EvidenceObj:
properties:
Expand All @@ -397,7 +396,6 @@ components:
type: object
required:
- name
- value
title: EvidenceObj
GenerationAnalysisHttpRequest:
properties:
Expand Down
2 changes: 0 additions & 2 deletions docs/api/orchestrator_openapi_0_1_0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,6 @@ components:
type: object
required:
- name
- value
title: Evidence
EvidenceObj:
properties:
Expand All @@ -641,7 +640,6 @@ components:
type: object
required:
- name
- value
title: EvidenceObj
FinishReason:
type: string
Expand Down
12 changes: 8 additions & 4 deletions src/clients/detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,11 @@ impl ContentAnalysisRequest {
pub struct Evidence {
/// Evidence name
pub name: String,
/// Evidence value
pub value: String,
/// Optional, evidence value
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
/// Optional, score for evidence
#[serde(skip_serializing_if = "Option::is_none")]
pub score: Option<f64>,
}

Expand All @@ -173,9 +175,11 @@ pub struct Evidence {
pub struct EvidenceObj {
/// Evidence name
pub name: String,
/// Evidence value
pub value: String,
/// Optional, evidence value
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
/// Optional, score for evidence
#[serde(skip_serializing_if = "Option::is_none")]
pub score: Option<f64>,
/// Optional, evidence on evidence value
// Evidence nesting should likely not go beyond this
Expand Down
18 changes: 11 additions & 7 deletions src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -986,9 +986,11 @@ fn validate_detector_params(
pub struct Evidence {
// Name for the evidence
pub name: String,
// Value for the evidence
pub value: String,
// Computed score for the value
// Optional, value for the evidence
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
// Optional, computed score for the value
#[serde(skip_serializing_if = "Option::is_none")]
pub score: Option<f64>,
}

Expand All @@ -997,11 +999,13 @@ pub struct Evidence {
pub struct EvidenceObj {
// Name for the evidence
pub name: String,
// Value for the evidence
pub value: String,
// Computed score for the value
// Optional, value for the evidence
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
// Optional, omputed score for the value
#[serde(skip_serializing_if = "Option::is_none")]
pub score: Option<f64>,
// Additional evidence
// Optional, additional evidence
#[serde(skip_serializing_if = "Option::is_none")]
pub evidence: Option<Vec<Evidence>>,
}
Expand Down
4 changes: 2 additions & 2 deletions src/orchestrator/unary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ mod tests {
evidence: Some(
[EvidenceObj {
name: "relevant chunk".into(),
value: "What is capital of Brazil".into(),
value: Some("What is capital of Brazil".into()),
score: Some(0.99),
evidence: None,
}]
Expand All @@ -988,7 +988,7 @@ mod tests {
evidence: Some(
[EvidenceObj {
name: "relevant chunk".into(),
value: "What is capital of Brazil".into(),
value: Some("What is capital of Brazil".into()),
score: Some(0.99),
evidence: None,
}]
Expand Down

0 comments on commit de0aa8c

Please sign in to comment.