Skip to content

Commit dafb047

Browse files
mhordynskimicpst
andauthored
feat: remove prompt lab (#549)
Co-authored-by: Michał Pstrąg <47692610+micpst@users.noreply.github.com>
1 parent e0d8941 commit dafb047

File tree

16 files changed

+2886
-3537
lines changed

16 files changed

+2886
-3537
lines changed

docs/how-to/prompts/promptfoo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ specified in the [promptfoo documentation](https://www.promptfoo.dev/docs/instal
55
configuration files for all the prompts discovered by our autodiscover mechanism by running the following command:
66

77
```bash
8-
ragbits prompts generate-promptfoo-configs
8+
ragbits prompts promptfoo
99
```
1010

1111
This command will generate a YAML files in the directory specified by `--target-path` (`promptfooconfigs` by

docs/how-to/prompts/prompts_lab.md

Lines changed: 0 additions & 43 deletions
This file was deleted.
-50.4 KB
Binary file not shown.

docs/quickstart/quickstart1_prompts.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,6 @@ ragbits prompts exec song_prompt:SongPrompt --payload '{"subject": "unicorns", "
110110

111111
Remember to change `song_prompt` to the name of the module where the prompt is defined and adjust the values of the placeholders to your liking.
112112

113-
!!! tip
114-
Ragbits also comes with a built-in GUI tool called Prompts Lab that allows you to manage and interact with prompts in a more user-friendly way. To learn more about using Prompts Lab, see the how-to article [How to Manage Prompts using GUI with Prompts Lab](../how-to/prompts/prompts_lab.md).
115-
116113
## Conclusion
117114
You now know how to define a prompt in Ragbits and how to use it with Large Language Models. You've also learned to make the prompt dynamic by using Pydantic models and the Jinja2 templating language. To learn more about defining prompts, such as configuring the desired output format, refer to the how-to article [How to define and use Prompts in Ragbits](../how-to/prompts/use_prompting.md).
118115

mkdocs.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ nav:
1010
- quickstart/quickstart1_prompts.md
1111
- quickstart/quickstart2_rag.md
1212
- How-to:
13-
- Prompting:
14-
- "Define and use prompts": how-to/prompts/use_prompting.md
15-
- "Use images in prompts": how-to/prompts/use_images_in_prompts.md
16-
- "Manage prompts using GUI": how-to/prompts/prompts_lab.md
17-
- "Test prompts with promptfoo": how-to/prompts/promptfoo.md
13+
- "Prompts":
14+
- "Define and use prompts": how-to/prompts/use_prompting.md
15+
- "Use images in prompts": how-to/prompts/use_images_in_prompts.md
16+
- "Test prompts with promptfoo": how-to/prompts/promptfoo.md
1817
- LLMs:
1918
- "Interact with LLMs": how-to/llms/use_llms.md
2019
- "Use local or self-hosted LLMs": how-to/llms/use_local_llms.md

packages/ragbits-core/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44

5+
- Remove prompt lab (#549)
56
- Add batched() helper method to utils (#555)
67
- Rename DocumentMeta create_text_document_from_literal to from_literal (#561)
78
- Adjust typing for DocumentSearch (#554)

packages/ragbits-core/pyproject.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ local = [
6060
fastembed = [
6161
"fastembed>=0.4.2,<1.0.0"
6262
]
63-
lab = [
64-
"gradio~=4.44.0,<5.0.0",
65-
]
6663
promptfoo = [
6764
"PyYAML>=6.0.2,<7.0.0",
6865
]

packages/ragbits-core/src/ragbits/core/prompt/_cli.py

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import asyncio
2+
import inspect
23
import json
34
from importlib import import_module
45
from pathlib import Path
@@ -9,6 +10,7 @@
910
from ragbits.cli import print_output
1011
from ragbits.core.config import core_config
1112
from ragbits.core.llms.base import LLM, LLMType
13+
from ragbits.core.prompt.discovery import PromptDiscovery
1214
from ragbits.core.prompt.prompt import ChatFormat, Prompt
1315

1416
prompts_app = typer.Typer(no_args_is_help=True)
@@ -21,6 +23,16 @@ class LLMResponseCliOutput(BaseModel):
2123
answer: str | BaseModel | None = None
2224

2325

26+
class PromptInfo(BaseModel):
27+
"""Information about a Prompt class for CLI display"""
28+
29+
name: str
30+
import_path: str
31+
description: str
32+
input_type: str
33+
output_type: str
34+
35+
2436
def _render(prompt_path: str, payload: str | None) -> Prompt:
2537
module_stringified, object_stringified = prompt_path.split(":")
2638
prompt_cls = getattr(import_module(module_stringified), object_stringified)
@@ -34,23 +46,7 @@ def _render(prompt_path: str, payload: str | None) -> Prompt:
3446

3547

3648
@prompts_app.command()
37-
def lab(
38-
file_pattern: str = core_config.prompt_path_pattern,
39-
llm_factory: str = core_config.llm_preference_factories[LLMType.TEXT],
40-
) -> None:
41-
"""
42-
Launches the interactive application for listing, rendering, and testing prompts
43-
defined within the current project.
44-
45-
For more information, see the [Prompts Lab documentation](../how-to/prompts/prompts_lab.md).
46-
"""
47-
from ragbits.core.prompt.lab.app import lab_app
48-
49-
lab_app(file_pattern=file_pattern, llm_factory=llm_factory)
50-
51-
52-
@prompts_app.command()
53-
def generate_promptfoo_configs(
49+
def promptfoo(
5450
file_pattern: str = core_config.prompt_path_pattern,
5551
root_path: Path = Path.cwd(), # noqa: B008
5652
target_path: Path = Path("promptfooconfigs"),
@@ -65,6 +61,25 @@ def generate_promptfoo_configs(
6561
generate_configs(file_pattern=file_pattern, root_path=root_path, target_path=target_path)
6662

6763

64+
@prompts_app.command()
65+
def search(file_pattern: str = core_config.prompt_path_pattern, root_path: Path = Path.cwd()) -> None: # noqa: B008
66+
"""
67+
Lists all available prompts that can be used with the 'render' and 'exec' commands.
68+
"""
69+
prompt_classes = PromptDiscovery(file_pattern=file_pattern, root_path=root_path).discover()
70+
prompt_infos = [
71+
PromptInfo(
72+
name=prompt_cls.__name__,
73+
import_path=f"{prompt_cls.__module__}:{prompt_cls.__name__}",
74+
description=inspect.getdoc(prompt_cls) or "",
75+
input_type=getattr(prompt_cls.input_type, "__name__", str(prompt_cls.input_type)),
76+
output_type=getattr(prompt_cls.output_type, "__name__", str(prompt_cls.output_type)),
77+
)
78+
for prompt_cls in prompt_classes
79+
]
80+
print_output(prompt_infos)
81+
82+
6883
@prompts_app.command()
6984
def render(prompt_path: str, payload: str | None = None) -> None:
7085
"""

packages/ragbits-core/src/ragbits/core/prompt/discovery/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/ragbits-core/src/ragbits/core/prompt/lab/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)