Skip to content

Commit 8692637

Browse files
authored
feat(gradio): enhance gradio interface (#90)
1 parent c562c01 commit 8692637

9 files changed

+401
-352
lines changed

docs/how-to/visualize-collection.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# How-To: Visualize Collection
2+
3+
db-ally provides simple way to visualize your collection with [Gradio](https://gradio.app){target="_blank"}. The app allows you to debug your views and query data using different LLMs.
4+
5+
## Installation
6+
7+
Install `dbally` with `gradio` extra.
8+
9+
```bash
10+
pip install dbally["gradio"]
11+
```
12+
13+
## Run the app
14+
15+
Pick the collection created using [`create_collection`][dbally.create_collection] and lunch the gradio interface.
16+
17+
```python
18+
from dbally.gradio import create_gradio_interface
19+
20+
gradio_interface = create_gradio_interface(collection)
21+
gradio_interface.launch()
22+
```
23+
Visit <http://127.0.0.1:7860>{target="_blank"} to test the collection.
24+
25+
!!! note
26+
By default, the app will use LLM API key defined in environment variable depending on the LLM provider used. You can override the key in the app.
27+
28+
## Full Example
29+
30+
Access the full example on [GitHub](https://github.com/deepsense-ai/db-ally/tree/main/examples/visualize_collection.py){target="_blank"}.

docs/how-to/visualize_views.md

-44
This file was deleted.

examples/visualize_views_code.py examples/visualize_collection.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@
1111
from dbally.llms.litellm import LiteLLM
1212

1313

14-
async def main():
14+
async def main() -> None:
1515
await country_similarity.update()
16+
1617
llm = LiteLLM(model_name="gpt-3.5-turbo")
1718
dbally.event_handlers = [CLIEventHandler(), BufferEventHandler()]
19+
1820
collection = dbally.create_collection("candidates", llm)
1921
collection.add(CandidateView, lambda: CandidateView(engine))
2022
collection.add(SampleText2SQLViewCyphers, lambda: SampleText2SQLViewCyphers(create_freeform_memory_engine()))
21-
gradio_interface = await create_gradio_interface(user_collection=collection)
23+
24+
gradio_interface = create_gradio_interface(collection)
2225
gradio_interface.launch()
2326

2427

examples/visualize_fallback_code.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async def main():
2828

2929
user_collection.set_fallback(fallback_collection).set_fallback(second_fallback_collection)
3030

31-
gradio_interface = await create_gradio_interface(user_collection=user_collection)
31+
gradio_interface = create_gradio_interface(user_collection)
3232
gradio_interface.launch()
3333

3434

mkdocs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ nav:
3636
- how-to/use_elastic_store.md
3737
- how-to/use_custom_similarity_store.md
3838
- how-to/update_similarity_indexes.md
39-
- how-to/visualize_views.md
39+
- how-to/visualize-collection.md
4040
- how-to/log_runs_to_langsmith.md
4141
- how-to/trace_runs_with_otel.md
4242
- how-to/create_custom_event_handler.md

src/dbally/gradio/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from dbally.gradio.gradio_interface import create_gradio_interface
1+
from dbally.gradio.interface import create_gradio_interface
22

33
__all__ = ["create_gradio_interface"]

0 commit comments

Comments
 (0)