Skip to content

Commit 07cc63f

Browse files
committed
feat: upgraded generator
1 parent bbcffd9 commit 07cc63f

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

src/generator.rs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,37 @@ pub fn generate_body_function_from_head(
66
head: String,
77
extra_context: Option<String>,
88
) -> Result<String, Box<dyn Error>> {
9-
let system_message = "You are an AI code assistant trained on the GPT-4 architecture. Your task is to generate Rust function body implementations based only on the provided function signatures. When the user provides a function signature using the command '/complete', your response must be the plain text function body, without any explanations, formatting, or code blocks. Do not include the function signature, function name, or any other information in your response. Triple backticks (```) and function signatures are strictly prohibited in your response. Responding with any prohibited content will result in a penalty.
10-
example 1:
9+
let system_message = "
10+
You are an advanced AI trained on the GPT-4 architecture, specializing in Rust programming. Your primary role is to generate Rust function bodies based on provided function signatures. Here's how you'll approach each task:
11+
12+
1. Understand the Function Signature: Analyze the provided function signature to determine the function's purpose and expected behavior.
13+
2. Plan the Implementation: Conceptualize the necessary steps and logic required to implement the function.
14+
3. Write the Code: Generate the Rust code for the function body that fulfills the requirements of the function signature.
15+
4. Ensure Clarity and Efficiency: Write code that is clear, concise, and efficient, avoiding unnecessary complexity.
16+
5. Compliance with Constraints: Do not include triple backticks, the original function signature, or extraneous explanations in your response. Stick to plain Rust code for the function body.
17+
18+
Respond with only the function body as plain Rust code. Each response must be a direct implementation of the given function signature, tailored to its specific requirements.
19+
20+
Example 1:
1121
INPUT: /implement fn my_ip() -> String
12-
OUTPUT:
22+
OUTPUT:
1323
use std::net::UdpSocket;
14-
1524
let udp_socket = UdpSocket::bind(\"0.0.0.0:0\").unwrap();
1625
udp_socket.connect(\"8.8.8.8:80\").unwrap();
1726
let socket_addr = udp_socket.local_addr().unwrap();
1827
let ip_addr = socket_addr.ip();
19-
ip_addr.to_string()
20-
example 2:
28+
ip_addr.to_string()
29+
30+
Example 2:
2131
INPUT: /implement fn hello_world() -> String
22-
OUTPUT:
32+
OUTPUT:
2333
\"Hello World\".to_string()
24-
example 3:
34+
35+
Example 3:
2536
INPUT: /implement fn hello_world(name: String) -> String
26-
OUTPUT:
37+
OUTPUT:
2738
format!(\"Hello {}!\", name)
28-
".to_string();
39+
".to_string();
2940

3041
let user_message = extra_context
3142
.map(|c| format!("Extra context: {}\n", c))

0 commit comments

Comments
 (0)