Skip to content

Commit

Permalink
- rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
laststylebender14 committed Sep 3, 2024
1 parent 43099b8 commit 09f75c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/cli/llm/infer_arg_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl TryFrom<ChatResponse> for Answer {

#[derive(Clone, Serialize)]
struct Question {
args_info: OperationDefinition,
definition: OperationDefinition,
}

impl TryInto<ChatRequest> for Question {
Expand All @@ -65,7 +65,7 @@ impl TryInto<ChatRequest> for Question {
},
};

let input = serde_json::to_string_pretty(&Question { args_info: input2 })?;
let input = serde_json::to_string_pretty(&Question { definition: input2 })?;
let output = serde_json::to_string_pretty(&Answer {
suggestions: vec![
"createPostInput".into(),
Expand All @@ -86,11 +86,11 @@ impl TryInto<ChatRequest> for Question {
});

let rendered_prompt = template.render(&context);

Ok(ChatRequest::new(vec![
let request = ChatRequest::new(vec![
ChatMessage::system(rendered_prompt),
ChatMessage::user(serde_json::to_string(&self)?),
]))
ChatMessage::user(serde_json::to_string(&self.definition)?),
]);
Ok(request)
}
}

Expand Down Expand Up @@ -124,7 +124,7 @@ impl InferArgName {
},
};

let question = Question { args_info: question };
let question = Question { definition: question };

let mut delay = 3;
loop {
Expand Down Expand Up @@ -203,7 +203,7 @@ mod test {
#[test]
fn test_to_chat_request_conversion() {
let question = Question {
args_info: OperationDefinition {
definition: OperationDefinition {
argument: MetaData {
name: "input2".to_string(),
output_type: "Article".to_string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ ChatRequest {
ChatMessage {
role: System,
content: Text(
"Given the Operation Definition of GraphQL, suggest 5 meaningful names for the argument names.\nThe name should be concise and preferably a single word.\n\nExample Input:\n{\n \"args_info\": {\n \"argument\": {\n \"name\": \"input2\",\n \"outputType\": \"Article\"\n },\n \"field\": {\n \"name\": \"createPost\",\n \"outputType\": \"Post\"\n }\n }\n}\n\nExample Output:\n{\n \"suggestions\": [\n \"createPostInput\",\n \"postInput\",\n \"articleInput\",\n \"noteInput\",\n \"messageInput\"\n ]\n}\n\nEnsure the output is in valid JSON format.\n",
"Given the Operation Definition of GraphQL, suggest 5 meaningful names for the argument names.\nThe name should be concise and preferably a single word.\n\nExample Input:\n{\n \"definition\": {\n \"argument\": {\n \"name\": \"input2\",\n \"outputType\": \"Article\"\n },\n \"field\": {\n \"name\": \"createPost\",\n \"outputType\": \"Post\"\n }\n }\n}\n\nExample Output:\n{\n \"suggestions\": [\n \"createPostInput\",\n \"postInput\",\n \"articleInput\",\n \"noteInput\",\n \"messageInput\"\n ]\n}\n\nEnsure the output is in valid JSON format.\n",
),
extra: None,
},
ChatMessage {
role: User,
content: Text(
"{\"args_info\":{\"argument\":{\"name\":\"input2\",\"outputType\":\"Article\"},\"field\":{\"name\":\"createPost\",\"outputType\":\"Post\"}}}",
"{\"argument\":{\"name\":\"input2\",\"outputType\":\"Article\"},\"field\":{\"name\":\"createPost\",\"outputType\":\"Post\"}}",
),
extra: None,
},
Expand Down

0 comments on commit 09f75c3

Please sign in to comment.