Fix bug in PromptGuard configuration (#80)

Signed-off-by: José Ulises Niño Rivera <junr03@users.noreply.github.com>
This commit is contained in:
José Ulises Niño Rivera 2024-09-25 22:36:55 -06:00 committed by GitHub
parent 7d130e102a
commit 370f3bb2c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 25 additions and 13 deletions

View file

@ -25,7 +25,6 @@ pub struct StoreVectorEmbeddingsRequest {
pub points: Vec<VectorPoint>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchPointResult {
pub id: String,
@ -124,7 +123,7 @@ pub mod open_ai {
pub struct ChatCompletionsResponse {
pub usage: Usage,
pub choices: Vec<Choice>,
pub model: String
pub model: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@ -173,7 +172,7 @@ pub enum PromptGuardTask {
#[serde(rename = "toxicity")]
Toxicity,
#[serde(rename = "both")]
Both
Both,
}
#[derive(Debug, Clone, Serialize, Deserialize)]

View file

@ -148,10 +148,10 @@ system_prompt: |
- Use miles per hour for wind speed
prompt_guards:
input_guard:
- name: jailbreak
input_guards:
jailbreak:
on_exception_message: Looks like you are curious about my abilities
- name: toxic
toxicity:
on_exception_message: Looks like you are curious about my abilities
prompt_targets:
@ -190,7 +190,6 @@ ratelimits:
#[test]
fn test_deserialize_configuration() {
let c: super::Configuration = serde_yaml::from_str(CONFIGURATION).unwrap();
assert_eq!(c.prompt_guards.unwrap().input_guard.len(), 2);
let _: super::Configuration = serde_yaml::from_str(CONFIGURATION).unwrap();
}
}

View file

@ -30,7 +30,10 @@ pub struct CreateEmbeddingRequest {
}
impl CreateEmbeddingRequest {
pub fn new(input: embeddings::CreateEmbeddingRequestInput, model: String) -> CreateEmbeddingRequest {
pub fn new(
input: embeddings::CreateEmbeddingRequestInput,
model: String,
) -> CreateEmbeddingRequest {
CreateEmbeddingRequest {
input: Box::new(input),
model,

View file

@ -27,7 +27,12 @@ pub struct CreateEmbeddingResponse {
}
impl CreateEmbeddingResponse {
pub fn new(data: Vec<embeddings::Embedding>, model: String, object: Object, usage: embeddings::CreateEmbeddingResponseUsage) -> CreateEmbeddingResponse {
pub fn new(
data: Vec<embeddings::Embedding>,
model: String,
object: Object,
usage: embeddings::CreateEmbeddingResponseUsage,
) -> CreateEmbeddingResponse {
CreateEmbeddingResponse {
data,
model,