Skip to content

Commit

Permalink
Improvments from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
ludwiktrammer committed Sep 26, 2024
1 parent f8104ba commit 49113e0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
29 changes: 14 additions & 15 deletions packages/ragbits-dev-kit/src/ragbits/dev_kit/prompt_lab/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,21 +203,20 @@ def show_split(index: int, state: gr.State) -> None:
with gr.Row():
with gr.Column(scale=1):
with gr.Tab("Inputs"):
if index is not None:
input_fields: list = get_input_type_fields(prompt.input_type)
tb_dict = {}
for entry in input_fields:
with gr.Row():
var = gr.Textbox(
label=entry["field_name"],
value=entry["field_default_value"],
interactive=True,
)
list_of_vars.append(var)

tb_dict[entry["field_name"]] = var

state.dynamic_tb = tb_dict
input_fields: list = get_input_type_fields(prompt.input_type)
tb_dict = {}
for entry in input_fields:
with gr.Row():
var = gr.Textbox(
label=entry["field_name"],
value=entry["field_default_value"],
interactive=True,
)
list_of_vars.append(var)

tb_dict[entry["field_name"]] = var

state.dynamic_tb = tb_dict

render_prompt_button = gr.Button(value="Render prompts")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class PromptDiscovery:
Args:
file_pattern (str): The file pattern to search for Prompt objects. Defaults to "**/prompt_*.py"
root_path (str): The root path to search for Prompt objects. Defaults to the directory where the script is run.
root_path (Path): The root path to search for Prompt objects. Defaults to the directory where the script is run.
"""

def __init__(self, file_pattern: str = DEFAULT_FILE_PATTERN, root_path: str = "."):
def __init__(self, file_pattern: str = DEFAULT_FILE_PATTERN, root_path: Path = Path.cwd()):
self.file_pattern = file_pattern
self.root_path = root_path

Expand Down Expand Up @@ -47,7 +47,7 @@ def discover(self) -> set[type[Prompt]]:

result_set: set[type[Prompt]] = set()

for file_path in Path(self.root_path).glob(self.file_pattern):
for file_path in self.root_path.glob(self.file_pattern):
# remove file extenson and remove directory separators with dots
module_name = str(file_path).rsplit(".", 1)[0].replace(os.sep, ".")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from ragbits.dev_kit.prompt_lab.discovery.prompt_discovery import PromptDiscovery

current_dir = str(Path(__file__).parent)
current_dir = Path(__file__).parent


def test_prompt_discovery_from_file():
Expand Down

0 comments on commit 49113e0

Please sign in to comment.