Compare commits
No commits in common. "c645645155268c217fa46ffd7124fb3bacb45365" and "8e7e5f96c310d401191ee7bd3ace9f0b8ddb8d90" have entirely different histories.
c645645155
...
8e7e5f96c3
26
Makefile
26
Makefile
@ -1,20 +1,18 @@
|
|||||||
all: build run
|
all: build run
|
||||||
|
|
||||||
# Variables for compiler and flags
|
|
||||||
CC = gcc
|
|
||||||
CFLAGS = -Ofast -Werror -Wall -lreadline -lncurses -lcurl -lssl -lcrypto -ljson-c -lm
|
|
||||||
|
|
||||||
# Targets
|
|
||||||
build:
|
|
||||||
$(CC) main.c $(CFLAGS) -o r
|
|
||||||
publish r
|
|
||||||
|
|
||||||
build_free:
|
|
||||||
$(CC) main.c -DFREE_VERSION $(CFLAGS) -o rf
|
|
||||||
publish rf
|
|
||||||
|
|
||||||
build_rpylib:
|
build_rpylib:
|
||||||
$(CC) -shared -o rpylib.so -fPIC rpylib.c -lpython3.12 `python3-config --includes` -I/usr/include/CL -ljson-c -lcurl
|
gcc -shared -o rpylib.so -fPIC rpylib.c -lpython3.12 `python3-config --includes` -I/usr/include/CL -ljson-c -lcurl
|
||||||
|
|
||||||
run:
|
|
||||||
|
build:
|
||||||
|
# -lpython3.14 -I/usr/include/python3.14
|
||||||
|
gcc main.c -Ofast -o r -Werror -Wall -lreadline -lncurses -lcurl -lssl -lcrypto -ljson-c -lm
|
||||||
|
publish r
|
||||||
|
|
||||||
|
build_free:
|
||||||
|
gcc main.c -lcurl -DFREE_VERSION -lssl -lcrypto -ljson-c -Ofast -o rf -Werror -Wall -lreadline -lncurses -lm
|
||||||
|
publish rf
|
||||||
|
|
||||||
|
run:
|
||||||
./r
|
./r
|
||||||
|
|||||||
4
main.c
4
main.c
@ -198,9 +198,7 @@ void repl() {
|
|||||||
if (!line || !*line)
|
if (!line || !*line)
|
||||||
continue;
|
continue;
|
||||||
// previous_line = line;
|
// previous_line = line;
|
||||||
if(!strncmp(line,"dump",4)){
|
|
||||||
printf("%s\n",message_json());
|
|
||||||
}
|
|
||||||
if (!strncmp(line, "exit", 4)) {
|
if (!strncmp(line, "exit", 4)) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|||||||
9
rpylib.c
9
rpylib.c
@ -37,6 +37,10 @@ SOFTWARE.
|
|||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
#include "openai.h"
|
#include "openai.h"
|
||||||
|
|
||||||
|
static PyObject* mymodule_hello(PyObject *self, PyObject *args) {
|
||||||
|
return PyUnicode_FromString("Hello, World from C!");
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject* rpylib_reset(PyObject *self, PyObject *args) {
|
static PyObject* rpylib_reset(PyObject *self, PyObject *args) {
|
||||||
return PyUnicode_FromString("True");
|
return PyUnicode_FromString("True");
|
||||||
}
|
}
|
||||||
@ -53,6 +57,7 @@ static PyObject* rpylib_chat(PyObject *self, PyObject *args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static PyMethodDef MyModuleMethods[] = {
|
static PyMethodDef MyModuleMethods[] = {
|
||||||
|
{"hello", mymodule_hello, METH_NOARGS, "Returns a Hello World string"},
|
||||||
{"chat", rpylib_chat, METH_VARARGS, "Chat with OpenAI."},
|
{"chat", rpylib_chat, METH_VARARGS, "Chat with OpenAI."},
|
||||||
{"reset", rpylib_reset, METH_NOARGS, "Reset message history."},
|
{"reset", rpylib_reset, METH_NOARGS, "Reset message history."},
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
@ -61,11 +66,11 @@ static PyMethodDef MyModuleMethods[] = {
|
|||||||
static struct PyModuleDef rpylib = {
|
static struct PyModuleDef rpylib = {
|
||||||
PyModuleDef_HEAD_INIT,
|
PyModuleDef_HEAD_INIT,
|
||||||
"rpylib",
|
"rpylib",
|
||||||
"R - the power of R in Python, made by retoor.",
|
"A simple C extension module for Python",
|
||||||
-1,
|
-1,
|
||||||
MyModuleMethods
|
MyModuleMethods
|
||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC PyInit_rpylib(void) {
|
PyMODINIT_FUNC PyInit_rpylib(void) {
|
||||||
return PyModule_Create(&rpylib);
|
return PyModule_Create(&rpylib);
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user