Pycell
-Local Installation-
Copy pycell.py and table.html into a project folder. By default the code allows for concurrent runs of Pycell by different users, therefore unique files to user runs are stored in a local directory while pycell can be stored in a cloud directory.
Create a folder within your documents folder called CodeGen also create a subfolder within CodeGen called documents. Alternatively, within pycell you can change the target root folder to store credentials and output files.
Install dependent libraries, [pandas, numpy, flask, string, and openai]
Ensure your openai api keys are stored within keys.txt in CodeGen.
Run pycell.py.
Commands:
Pycell first attempts to run what is entered in the cell, as though it is a python command. That means that you can easily generate and process data easily with integrated python support.
If it cannot run the entered text as native python it tries to split the text into value and source arguments, which are split by a double colon, "<value>::<source args>". Source args do not have to be given of course.
At this point if the value is not prefaced by an '=' sign then either the input cell is fileld with the value, or if source args are given then the input cell is filled with all source args concatenated.
When text is prefaced by an '=' sign it is treated as a command.
Python Scripts -
Run python scripts stored in documents folder. E.g entering '=HelloWorld.py' into a cell will run the python script 'HelloWorld', given it's in CodeGen/Documents
Run python functions.
To fill cell using a python script the script must print the desired output.
Targets and Sources:
Again, pycell will attempt to execute simple python commands when prefaced with an equals sign here. That is, suppose one has a local variable being used by their local pycell instance, <myVar>. They can print the value of the variable, <myVar>, in the cell using 'print(<myVar>)' or using '=<myVar>'. Note, entering '=print(<myVar>)' will fill the cell with nothing, because print has no output.
Target Arguments - These are the cells which will be filled
Structure : [<initial coordinate>, 'to', <final coordinate>, number steps] * Only <initial coordinate> is required when targeting just a single cell.
Source Arguments - These are the cells which will be used to fill the target.
Structure type A : [<initial coordinate>, 'to', <final coordinate>, number steps] * Only <initial coordinate> is required when sourcing just a single cell.
Structure type B: [<text 1>, <text 2>,...]
The length of target args and source args do not have to be identical. Suppose we have [[x0, y0], [x1, y1], [x2,y2]]::[[0, 0], [1, 1]], then [x0, y0] will take the value in cell [0, 0], [x1, y1] will take the value in cell [1, 1], and [x2, y2] will take the value in cell [0, 0]. Note the same operation can be created using the 'to' keyword as [[x0,y0], 'to', [x2, y2], 3]::[[0, 0], [1, 1]].
Built-In Commands
AI(args) will generate an AI text response given the args.
promt - type string: Text input for ai text response.
form_data - type array: Leave empty or if referencing the form for input type form_data=form_data.
conversation - type dictionary : See openai gpt conversation structure
max_tokens, temperature, fine_tuned_model - See openai.
cform(args) Will convert the dictionary output into a more readable format.
data - the raw data from an AI output.
form_data - type array: Leave empty or if referencing the form for input type form_data=form_data.