Skip to content

Commit

Permalink
Merge pull request #13 from Neo-Zenith/wy-dev
Browse files Browse the repository at this point in the history
add more prompt engineering
  • Loading branch information
woonyee28 authored Jan 20, 2024
2 parents 91b5f82 + 8a1fe0d commit e9f9ae0
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 11 deletions.
27 changes: 18 additions & 9 deletions express/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 55 additions & 2 deletions express/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,62 @@ app.post("/openai", async (req, res) => {
role: "system",
content: `Context: You are an engineer working on convex optimization problem with applications from finance to
healthcare and control systems. Your job is to convert mathematical expression with convex objectives into efficient C code for
embedded devices. If possible, include the cvxopt.h library
embedded devices. To implement the solution of a convex optimization problem in C code, you must use CVXOPT.
Make sure the C code generated is correct and with zero error. This task is very important, you will get fired if you fail it.
The team relies on you.`,
The team relies on you.
Example of Input:
f(x)=x^2+2x+1 with the constraint x≥2
Example of Output:
#include <stdio.h>
#include <cvxopt.h>
int main() {
// Create the quadratic function: f(x) = x^2 + 2x + 1
quadprog_problem* qp = create_quadprog_problem();
quadprog_matrix* P = create_quadprog_matrix(1, 1);
quadprog_matrix* q = create_quadprog_matrix(1, 1);
quadprog_matrix* G = create_quadprog_matrix(1, 1);
quadprog_matrix* h = create_quadprog_matrix(1, 1);
quadprog_matrix* A = create_quadprog_matrix(1, 1);
quadprog_matrix* b = create_quadprog_matrix(1, 1);
set_quadprog_matrix_values(P, 0, 0, 2.0);
set_quadprog_matrix_values(q, 0, 0, 2.0);
set_quadprog_matrix_values(G, 0, 0, -1.0);
set_quadprog_matrix_values(h, 0, 0, -2.0);
set_quadprog_matrix_values(A, 0, 0, 1.0);
set_quadprog_matrix_values(b, 0, 0, -2.0);
set_quadprog_problem(P, q, G, h, A, b);
// Solve the quadratic program
quadprog_options* options = create_quadprog_options();
quadprog_results* results = create_quadprog_results();
int status = solve_quadprog(qp, options, results);
// Check if the optimization was successful
if (status == 0) {
printf("Optimization successful\n");
// Extract the optimal solution
double* x = get_quadprog_results_x(results);
printf("Optimal solution x: %f\n", x[0]);
} else {
printf("Optimization failed\n");
}
// Clean up memory
destroy_quadprog_problem(qp);
destroy_quadprog_options(options);
destroy_quadprog_results(results);
return 0;
}
`,
},
{
role: "user",
Expand Down

0 comments on commit e9f9ae0

Please sign in to comment.