This commit is contained in:
retoor 2025-03-30 01:47:00 +01:00
parent c64c92e1cc
commit 213b6b0578
7 changed files with 0 additions and 143 deletions

View File

@ -1,32 +0,0 @@
#!/usr/bin/env python3
# Not written by retoor! This is generated boiler plate to give an example!
import cgi
import cgitb
from xmlrpc.client import ServerProxy
client = ServerProxy("https://api.molodetz.nl/rpc")
ask_gpt = client.gpt4o_mini
cgitb.enable()
print("Content-Type: text/html")
print()
import pathlib
form = cgi.FieldStorage()
question = form.getvalue("question", "")
page_source = pathlib.Path(__file__).parent.joinpath("gpt_template.html").read_text()
if question:
try:
response = ask_gpt(question)
except Exception as e:
response = f"Error: {e}"
page_source = page_source.replace("...", response)
page_source = page_source.replace("display:none;","")
print(page_source)

View File

@ -1,64 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GPT Example</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f9;
}
.container {
max-width: 600px;
margin: 50px auto;
padding: 20px;
background: #fff;
border-radius: 8px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
h1 {
color: #333;
text-align: center;
}
textarea, input {
width: 100%;
padding: 10px;
margin: 10px 0;
font-size: 16px;
border: 1px solid #ddd;
border-radius: 4px;
}
input[type="submit"] {
background-color: #4CAF50;
color: white;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #45a049;
}
.response-box {
padding: 10px;
background: #f9f9f9;
border: 1px solid #ddd;
border-radius: 4px;
min-height: 100px;
}
</style>
</head>
<body>
<div class="container">
<h1>Ask GPT</h1>
<div style="display:none;" class="response-box">
<p id="response">...</p>
</div>
<form action="/cgi-bin/gpt.py" method="post">
<textarea name="question" rows="4" placeholder="Your prompt.."></textarea>
<input type="submit" value="Get Answer">
</form>
</div>
</body>
</html>

12
main.c
View File

@ -163,14 +163,6 @@ void repl() {
continue;
}
if (!strncmp(line, "exit", 4)) exit(0);
if (!strncmp(line, "help", 4)) {
help();
continue;
}
if (!strncmp(line, "!debug", 6)) {
r_malloc_stats();
continue;
}
while (line && *line != '\n') {
char *response = openai_chat("user", line);
@ -190,10 +182,6 @@ void repl() {
}
}
void help() {
const char * help_text = "Written by retoor@molodetz.nl\n\n";
render(help_text);
}
char *strreplace(const char *content, const char *what, const char *with) {
char *pos = strstr(content, what);

View File

@ -1 +0,0 @@
#include "malloc.h"

View File

@ -1,33 +0,0 @@
#ifndef R_MALLOC
#define R_MALLOC
#include <malloc.h>
long long int r_malloc_alloc_count = 0;
long long int r_malloc_alloc_total = 0;
void *r_malloc(size_t size) {
r_malloc_alloc_count++;
r_malloc_alloc_total++;
return malloc(size);
}
void r_free(void *ptr) {
r_malloc_alloc_count--;
free(ptr);
}
void r_malloc_stats() {
fprintf(stderr, "r_malloc_alloc_count: %lld\n", r_malloc_alloc_count);
fprintf(stderr, "r_malloc_alloc_total: %lld\n", r_malloc_alloc_total);
fprintf(stderr, "r_malloc_freed_total: %lld\n",
r_malloc_alloc_total - r_malloc_alloc_count);
}
#define malloc(x) r_malloc(x)
#define free(x) r_free(x)
#include <stdio.h>
#endif

1
r.h
View File

@ -1,7 +1,6 @@
#ifndef R_H
#define R_H
#include "auth.h"
#include "malloc.h"
#include "utils.h"
#include <stdbool.h>
#include <string.h>

BIN
rpylib.so

Binary file not shown.