1
+ use auto_gpt_agent:: function_to_string as ai;
2
+
3
+ #[ ai]
4
+ pub fn print_backend_webserver_code ( _project_description : & str ) {
5
+ /// INPUT: Takes in a PROJECT_DESCRIPTION and CODE_TEMPLATE for a website backend build
6
+ /// IMPORTANT: The backend code is ONLY an example. If the Project Description requires it, make as many changes as you like.
7
+ /// IMPORTANT: You do not need to follow the backend code exactly. Write functions that make sense for the users request if required.
8
+ /// FUNCTION: Takes an existing set of code marked as CODE_TEMPLATE and updates or re-writes it to work for the purpose in the PROJECT_DESCRIPTION
9
+ /// IMPORTANT: The following libraries are already installed
10
+ /// reqwest, serde, serde_json, tokio, actix-web, async-trait, actix_cors
11
+ /// No other external libraries should be used. Write functions that fit with the description from the PROJECT_DESCRIPTION
12
+ /// OUTPUT: Print ONLY the code, nothing else. This function ONLY prints code.
13
+ println ! ( OUTPUT ) ;
14
+ }
15
+
16
+ #[ ai]
17
+ pub fn print_improved_webserver_code ( _project_description : & str ) {
18
+ /// INPUT: Takes in a PROJECT_DESCRIPTION and CODE_TEMPLATE for a website backend build
19
+ /// FUNCTION: Performs the following tasks:
20
+ /// 1. Removes any bugs in the code and adds minor additional functionality
21
+ /// 2. Makes sure everything requested in the spec from a backend standpoint was followed. If not, add the feature. No code should be implemented later. Everything should be written now.
22
+ /// 3. ONLY writes the code. No commentary.
23
+ /// IMPORTANT: The following libraries are already installed. Does not use ANY libraries other than what was provided in the template
24
+ /// reqwest, serde, serde_json, tokio, actix-web, async-trait
25
+
26
+ println ! ( OUTPUT ) ;
27
+ }
28
+
29
+ #[ ai]
30
+ pub fn print_fixed_code ( _project_description : & str ) {
31
+ /// INPUT: Takes in Rust BROKEN_CODE and the ERROR_BUGS found
32
+ /// FUNCTION: Removes bugs from code
33
+ /// IMPORTANT: Only prints out the new and improved code. No commentary or anything else
34
+ println ! ( OUTPUT ) ;
35
+ }
36
+
37
+
38
+ #[ ai]
39
+ pub fn print_rest_api_endpoints ( _project_description : & str ) {
40
+ /// INPUT: Takes in Rust webserver CODE_INPUT based on actix-web
41
+ /// FUNCTION: Prints out the JSON schema for url endpoints and their respective types
42
+ /// LOGIC: Script analyses all code and can categorize into the following object keys:
43
+ /// "route": This represents the url path of the endpoint
44
+ /// "is_route_dynamic": if a route has curly braces in it such as {symbol} or {id} as an example, then this will be set to true
45
+ /// "method": This represents the method being called
46
+ /// "request_body": This represents the body of a post method request
47
+ /// "response": This represents the output based upon the structs in the code and understanding the functions
48
+ /// IMPORTANT: Only prints out the JSON schema. No commentary or anything else.
49
+ /// MUST READ: All keys are strings. Even bool should be wrapped in double quotes as "bool"
50
+ /// EXAMPLE:
51
+ /// INPUT_CODE:
52
+ /// ...
53
+ /// pub struct Item {
54
+ /// pub id: u64,
55
+ /// pub name: String,
56
+ /// pub completed: bool,
57
+ /// }
58
+ /// pub struct User {
59
+ /// pub id: u64,
60
+ /// pub username: String,
61
+ /// pub password: String,
62
+ /// }
63
+ /// ...
64
+ /// HttpServer::new(move || {
65
+ /// App::new()
66
+ /// .app_data(data.clone())
67
+ /// .route("/item", web::post().to(create_item))
68
+ /// .route("/item/{id}", web::get().to(read_item))
69
+ /// .route("/item/{id}", web::put().to(update_item))
70
+ /// .route("/item/{id}", web::delete().to(delete_item))
71
+ /// .route("/signup", web::post().to(signup))
72
+ /// .route("/crypto", web::get().to(crypto))
73
+ /// PRINTS JSON FORMATTED OUTPUT:
74
+ /// [
75
+ /// {
76
+ /// "route": "/item/{id}",
77
+ /// "is_route_dynamic": "true",
78
+ /// "method": "get"
79
+ /// "request_body": "None",
80
+ /// "response": {
81
+ /// "id": "number",
82
+ /// "name": "string",
83
+ /// "completed": "bool",
84
+ /// }
85
+ /// },
86
+ /// {
87
+ /// "route": "/item",
88
+ /// "is_route_dynamic": "false",
89
+ /// "method": "post",
90
+ /// "request_body": {
91
+ /// "id": "number",
92
+ /// "name": "string",
93
+ /// "completed": "bool",
94
+ /// },
95
+ /// "response": "None"
96
+ /// },
97
+ /// {
98
+ /// "route": "/item/{id}",
99
+ /// "is_route_dynamic": "true",
100
+ /// "method": "delete",
101
+ /// "request_body": "None",
102
+ /// "response": "None"
103
+ /// },
104
+ /// {
105
+ /// "route": "/crypto",
106
+ /// "is_route_dynamic": "false",
107
+ /// "method": "get",
108
+ /// "request_body": "None",
109
+ /// "response": "not_provided"
110
+ /// },
111
+ /// ... // etc
112
+ /// ]
113
+ println ! ( OUTPUT ) ;
114
+ }
0 commit comments