Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
1 change: 1 addition & 0 deletions .sample.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OPENAI_API_KEY=sk-123456
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# FORMULA LLM - LLM Explanation and Repair

### Requirements

```
python = 3.10
python = 3.12
dotnet 6.0
poetry
```

### Python dependencies

```
Dependencies are listed in pyproject.toml under [tool.poetry.dependencies]
```

### Install poetry
### Install poetry

```bash
// Linux, macOS, and Windows (WSL)
$ curl -sSL https://install.python-poetry.org | python3 -
Expand All @@ -22,30 +25,29 @@ $ (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Co
```

### Create conda environment

```bash
$ conda create -n fpy python=3.10
$ conda create -n fpy python=3.12
$ conda activate fpy
$ poetry install
```

### Install Formula

```bash
$ dotnet tool install --global VUISIS.Formula.<x64|ARM64>
```

### Set OpenAI Env
### Set OpenAI Env

Create a .env file in the root directory and set the environment variable OPENAI_API_KEY.

```
Set the environment variable OPENAI_API_KEY if using agents module and GPT before running.
OPENAI_API_KEY=<your-openai-api-key>
```

### Install Ollama For Local LLM
```bash
// Download Ollama for your platform here https://ollama.com/download if using pipelines module.

// Pull the LLM models
$ ollama pull mistral
$ ollama pull bakllava
### Run Jupyter Notebook

// Run the Ollama server exe or by command
$ ollama serve
```
```bash
$ jupyter notebook
```
56 changes: 6 additions & 50 deletions examples/agents.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "050d5d96-2ed2-4bf8-9691-b80d4b81d6e6",
"metadata": {},
"outputs": [],
Expand All @@ -23,64 +23,20 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "744121f0-a9a6-4ecc-a8d6-42be5857fb62",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(Compiled) MappingExample.4ml\n",
"0.29s.\n"
]
}
],
"outputs": [],
"source": [
"code = load(\".\\data\\MappingExample.4ml\")"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "187342d8-56fe-4039-a8b1-d3ffe61af6ee",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mThis formula model defines a domain called Mapping, which consists of three types of entities: Component, Processor, and Mapping. \n",
"\n",
"- Component: Represents a component with an id (Integer) and utilization (Real).\n",
"- Processor: Represents a processor with an id (Integer).\n",
"- Mapping: Represents the mapping of a Component to a Processor.\n",
"\n",
"The model also includes two constraints:\n",
"1. `invalidUtilization`: This constraint specifies that the utilization of a Component must be greater than 0.\n",
"2. `badMapping`: This constraint checks if the total utilization of components mapped to a processor exceeds 100.\n",
"\n",
"The `conforms` statement ensures that there are no violations of the `badMapping` and `invalidUtilization` constraints in the model.\n",
"\n",
"The partial model `pm` of Mapping specifies the creation of two components (c1 and c2) with ids 0 and 1 respectively, a processor p1 with id 0, and maps both components to processor p1.\n",
"\n",
"Now, let's analyze why this formula model is broken and how it can be fixed:\n",
"\n",
"1. The `badMapping` constraint is checking if the total utilization of components mapped to a processor exceeds 100, but the sum is calculated incorrectly. The correct sum should be the sum of utilizations of components mapped to the processor, not the sum of all component utilizations. This can be fixed by updating the sum calculation in the `badMapping` constraint.\n",
"\n",
"2. The `conforms` statement is used to ensure that there are no violations of constraints, but it is missing the actual constraints to be checked. It should include `no badMapping` and `no invalidUtilization` to enforce the constraints properly.\n",
"\n",
"3. The partial model `pm` is incomplete as it does not specify the values of x and y for components c1 and c2 respectively. These values should be provided to create valid instances of components.\n",
"\n",
"By addressing these issues, the formula model can be fixed and accurately represent the constraints and entities in the Mapping domain.\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n"
]
}
],
"outputs": [],
"source": [
"prompt = \"Can you tell me what this formula model is doing?\"\n",
"fa.run(code, prompt)"
Expand All @@ -103,7 +59,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
Loading