Skip to content

Commit

Permalink
Updated code with the established formulallm package.
Browse files Browse the repository at this point in the history
  • Loading branch information
saj122 committed Nov 16, 2023
1 parent 183d021 commit 3ef7b39
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 513 deletions.
19 changes: 3 additions & 16 deletions Src/Kernel/FormulaPy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ python >= 3.10
dotnet 6.0
```

### With .NET on x64 or Apple Silicon ARM64
### Install and Set Env
```bash
$ cd Src/CommandLine
$ dotnet build CommandLine.sln /p:Configuration=Release /p:Platform=x64|ARM64
```
dotnet tool install --global VUISIS.Formula.<x64|ARM64>

### Copy CommandLine build files into the CommandLine folder.
```bash
$ cp -r Src/CommandLine/bin/Release/<OS>/<PLATFORM>/net6.0/* Src/Kernel/FormulaPy/CommandLine
Set the environment variable OPENAI_API_KEY before running.
```

### Install FormulaPy kernel
Expand All @@ -27,13 +23,4 @@ $ pip install .
```bash
$ sudo ln -s /usr/lib/dotnet/host/fxr/<version>/libhostfxr.so /usr/lib/dotnet
$ conda install -c conda-forge libstdcxx-ng=12
```

### Add to config.py with OpenAI API key in SelfRepairLLM/src
```bash
$ cfg = {
"OPENAI_API_KEY" : "",
"ACTIVELOOP_TOKEN" : "(OPTIONAL)",
"LANGCHAIN_API_KEY" : "(OPTIONAL)"
}
```
247 changes: 29 additions & 218 deletions Src/Kernel/FormulaPy/formula.ipynb

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions Src/Kernel/FormulaPy/formula/CommandLine/.gitignore

This file was deleted.

9 changes: 0 additions & 9 deletions Src/Kernel/FormulaPy/formula/CommandLine/runtimeconfig.json

This file was deleted.

6 changes: 0 additions & 6 deletions Src/Kernel/FormulaPy/formula/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
__version__ = '0.0.1'

from pythonnet import load
load("coreclr")
import clr
d = __file__.replace("__init__.py","")
clr.AddReference(d + "CommandLine/VUISIS.Formula.x64.dll")

from .formula_magic import FormulaMagics

def load_ipython_extension(ipython):
Expand Down
72 changes: 0 additions & 72 deletions Src/Kernel/FormulaPy/formula/formula_agent.py

This file was deleted.

27 changes: 5 additions & 22 deletions Src/Kernel/FormulaPy/formula/formula_magic.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
from __future__ import print_function
from pickle import TRUE
from IPython.core.magic import (Magics, magics_class, line_magic)
from IPython.core.magic_arguments import (argument, magic_arguments, parse_argstring)

import re, os

from Microsoft.Formula.CommandLine import CommandInterface, CommandLineProgram
from System.IO import StringWriter
from System import Console

from .formula_agent import run_agent_executor, run_agent_executor_repair
from formulallm.formula_agent import run_agent_executor, run_agent_executor_repair
from formulallm.formula_program import FormulaInterface

@magics_class
class FormulaMagics(Magics):

def __init__(self, shell, data=None):
super(FormulaMagics, self).__init__(shell)
self.sw = StringWriter()
self.total_sw_output = "END"
Console.SetOut(self.sw)
Console.SetError(self.sw)
self.file_txt = None

sink = CommandLineProgram.ConsoleSink()
chooser = CommandLineProgram.ConsoleChooser()
self.ci = CommandInterface(sink, chooser)
self.ci.DoCommand("wait on")
self.sw.GetStringBuilder().Clear()
self.fi = FormulaInterface()
print("Successfully initialized formula.")

@line_magic
Expand Down Expand Up @@ -68,14 +54,11 @@ def run_command(self, cmd, args=None):
line = cmd
else:
line = cmd + " " + args

self.ci.DoCommand(line)

temp_str = self.sw.ToString()

temp_str = self.fi.run_command(line)
if cmd == "extract":
self.total_sw_output = temp_str

self.sw.GetStringBuilder().Clear()
print(temp_str)

@line_magic
Expand Down
82 changes: 0 additions & 82 deletions Src/Kernel/FormulaPy/formula/formula_tools.py

This file was deleted.

65 changes: 0 additions & 65 deletions Src/Kernel/FormulaPy/formula/prompts.py

This file was deleted.

19 changes: 0 additions & 19 deletions Src/Kernel/FormulaPy/formula/temp.4ml

This file was deleted.

3 changes: 1 addition & 2 deletions Src/Kernel/FormulaPy/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
author='VUISIS',
author_email='[email protected]',
packages=['formula'],
install_requires=['pythonnet','jupyter','langchain==0.0.239', "openai"],
package_data={'formula': ['CommandLine/*']}
install_requires=['jupyter','formulallm']
)

0 comments on commit 3ef7b39

Please sign in to comment.