Skip to content

Commit

Permalink
chat style prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
metelkin committed Jun 27, 2024
1 parent d83c3d8 commit 702724b
Show file tree
Hide file tree
Showing 16 changed files with 2,455 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
build.log
dist
node_modules
package-lock.json
package.json
draft

training.jsonl
validation.jsonl
6 changes: 6 additions & 0 deletions cases/0005/index0.heta
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
Create reaction in Heta notation with one substrate and one product.
*/

// reaction of s1 degradation
r1 @Reaction {actors: s1 => p1} := k1 * s1 * comp1;
17 changes: 17 additions & 0 deletions cases/0005/index1.heta
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Add all necessary components: species, compartments, and constants.
*/
// index.heta

// reaction of s1 degradation
r1 @Reaction {actors: s1 => p1} := k1 * s1 * comp1;

// species
s1 @Species {compartment: comp1} .= 10;
p1 @Species {compartment: comp1} .= 0;

// compartment of size 1
comp1 @Compartment .= 1;

// constant of reaction
k1 @Const = 0.01;
6 changes: 6 additions & 0 deletions cases/0006/index0.heta
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
Create reaction with no substrate and one product in Heta.
*/

// reactions
r1 @Reaction {actors: => p1} := k1 * comp1;
9 changes: 9 additions & 0 deletions cases/0006/index1.heta
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
Add necessary species
*/

// reactions
r1 @Reaction {actors: => p1} := k1 * comp1;

// species
p1 @Species {compartment: comp1} .= 0;
7 changes: 7 additions & 0 deletions cases/0007/index0.heta
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
Create mass-action reaction in Heta notation by the stoicheometry: s1 => p1.
*/

// reactions
r1 @Reaction {actors: s1 => p1} := k1 * s1 * comp1;

6 changes: 6 additions & 0 deletions cases/0008/index0.heta
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
Create mass-action reaction in Heta notation by the stoicheometry: 2s1 => p1.
*/

// reactions
r1 @Reaction {actors: 2s1 => p1} := k1 * s1^2 * comp1;
6 changes: 6 additions & 0 deletions cases/0008/index1.heta
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
Make reaction reversible
*/

// reactions
r1 @Reaction {actors: 2s1 <=> p1} := (k1 * s1^2 - k2 * p1) * comp2;
7 changes: 7 additions & 0 deletions cases/0009/index0.heta
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
Create mass-action reversible reaction in Heta notation by the stoicheometry: 2s1 => 2p1.
*/
// index.heta

// reactions
r1 @Reaction {actors: 2s1 => p1} := (k1 * s1^2 - k2 * p1^2) * comp1;
7 changes: 7 additions & 0 deletions cases/0010/index0.heta
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
Create mass-action reversible reaction in Heta notation by the stoicheometry: s1 + 2s2 + 3s3 <=> p1 + 2p2 + 3p3.
*/
// index.heta

// reactions
r1 @Reaction {actors: s1 + 2s2 + 3s3 <=> p1 + 2p2 + 3p3} := (k1 * s1 * s2^2 * s3^3 - k2 * p1 * p2^2 * p3^3) * comp1;
21 changes: 21 additions & 0 deletions cases/0011/index0.heta
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Create complete Heta model with two reactions with stoicheometry: A + 2B => C and C => D.
*/
// index.heta

// reactions
r1 @Reaction {actors: A + 2B => C} := k1 * A * B^2 * comp1;
r2 @Reaction {actors: C => D} := k2 * C * comp1;

// species
A @Species {compartment: comp1} .= 1;
B @Species {compartment: comp1} .= 10;
C @Species {compartment: comp1} .= 0;
D @Species {compartment: comp1} .= 0;

// compartments
comp1 @Compartment .= 1;

// parameters
k1 @Const = 0.01;
k2 @Const = 0.001;
34 changes: 34 additions & 0 deletions js/create-prompt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const path = require('path');
const fs = require('fs');
const { globSync } = require('glob');
const systemPrompt = `
You will be provided with description of dynamic model, and your task is to create model in Heta format.
Try not to create supplementary text, only model and comments.
`;

const directoryPath = './cases';
const validationPath = './validation';
const pattern = 'index*.heta';

const directories = fs.readdirSync(directoryPath, { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);

let lines = directories.map((directory) => {
const files = globSync(pattern, { cwd: path.join(directoryPath, directory) }).sort();
let messages = [{role: 'system', content: systemPrompt}];

files.forEach((file) => {
const filePath = path.join(directoryPath, directory, file);
const content = fs.readFileSync(filePath, 'utf8');
let matches = content.match(/\/\*([\s\S]*)\*\/([\s\S]*)/);
let prompt = matches[1].replace(/\s+/g, ' ');
let completion = matches[2].replace(/^[\s]+/, '').replace(/\r/g, '');
messages.push({role: 'user', content: prompt});
messages.push({role: 'assistant', content: completion});
});

return JSON.stringify({messages});
}).join('\n');;

fs.writeFileSync('training.jsonl', lines);
Loading

0 comments on commit 702724b

Please sign in to comment.