-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added an LLM recipe validation function to recipe manager as well as …
…a script that will automatically generate recipes which are then LLM judged. This is rough work to provide pointers for doing in an agentic flow, but don't merge this PR as-is
- Loading branch information
Showing
4 changed files
with
156 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import json | ||
import os | ||
import readline | ||
import shutil | ||
import sys | ||
|
||
import pandas as pd | ||
from dotenv import load_dotenv | ||
from recipe_sync import create_new_recipe, llm_validate_recipe | ||
|
||
load_dotenv() | ||
|
||
input_data = "./tests/humanitarian_user_inputs_short.csv" | ||
work_dir = "./work/checked_out" | ||
|
||
env_cmd = " python " | ||
author = "matt" | ||
|
||
data = pd.read_csv(input_data) | ||
|
||
user_inputs = data["user_input"] | ||
|
||
# | ||
# This code will read an input file of user questions, | ||
# automatically generate recipes and have an LLM review the output | ||
# | ||
# | ||
|
||
|
||
results = [] | ||
|
||
for input in user_inputs[0:3]: | ||
print(input) | ||
|
||
input = input + " /nochecks" | ||
|
||
create_new_recipe(input, author) | ||
print("\n\n") | ||
|
||
# Find most recent directory by timestamp in ./management/work | ||
dirs = os.listdir(work_dir) | ||
dirs = sorted(dirs, key=lambda x: os.path.getmtime(f"{work_dir}/{x}"), reverse=True) | ||
recent_dir = work_dir + "/" + dirs[0] + "/recipe.py" | ||
|
||
validation_result = llm_validate_recipe(input, recent_dir) | ||
|
||
r = { | ||
"input": input, | ||
"validation_result": validation_result["answer"], | ||
"validation_reason": validation_result["reason"], | ||
} | ||
|
||
results.append(r) | ||
|
||
print("\n\n") | ||
|
||
results = pd.DataFrame(results) | ||
results.to_csv("results.csv") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{# templates/validate_recipe_prompt.jinja2 #} | ||
|
||
The user requested this: | ||
|
||
{{ user_input }} | ||
|
||
The recipe code is: | ||
|
||
{{ recipe_code }} | ||
|
||
The recipe output is: | ||
|
||
{{ recipe_result }} | ||
|
||
Did the recipe output match the user request? | ||
|
||
Provide your answer as a valid JSON string in the following format: | ||
|
||
{ | ||
"answer": "<yes>", | ||
"reason": "<reason for your answer>" | ||
"user_input": "<user_input>", | ||
} |