Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gradio): enhance gradio interface #90

Merged
merged 12 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docs/how-to/visualize-collection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# How-To: Visualize Collection

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.

## Installation

Install `dbally` with `gradio` extra.

```bash
pip install dbally["gradio"]
```

## Run the app

Pick the collection created using [`create_collection`][dbally.create_collection] and lunch the gradio interface.

```python
from dbally.gradio import create_gradio_interface

gradio_interface = create_gradio_interface(collection)
gradio_interface.launch()
```
Visit <http://127.0.0.1:7860>{target="_blank"} to test the collection.

!!! note
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.

## Full Example

Access the full example on [GitHub](https://github.com/deepsense-ai/db-ally/tree/main/examples/visualize_collection.py){target="_blank"}.
44 changes: 0 additions & 44 deletions docs/how-to/visualize_views.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@
from dbally.llms.litellm import LiteLLM


async def main():
async def main() -> None:
await country_similarity.update()

llm = LiteLLM(model_name="gpt-3.5-turbo")
dbally.event_handlers = [CLIEventHandler(), BufferEventHandler()]

collection = dbally.create_collection("candidates", llm)
collection.add(CandidateView, lambda: CandidateView(engine))
collection.add(SampleText2SQLViewCyphers, lambda: SampleText2SQLViewCyphers(create_freeform_memory_engine()))
gradio_interface = await create_gradio_interface(user_collection=collection)

gradio_interface = create_gradio_interface(collection)
gradio_interface.launch()


Expand Down
2 changes: 1 addition & 1 deletion examples/visualize_fallback_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async def main():

user_collection.set_fallback(fallback_collection).set_fallback(second_fallback_collection)

gradio_interface = await create_gradio_interface(user_collection=user_collection)
gradio_interface = create_gradio_interface(user_collection)
gradio_interface.launch()


Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ nav:
- how-to/use_elastic_store.md
- how-to/use_custom_similarity_store.md
- how-to/update_similarity_indexes.md
- how-to/visualize_views.md
- how-to/visualize-collection.md
- how-to/log_runs_to_langsmith.md
- how-to/trace_runs_with_otel.md
- how-to/create_custom_event_handler.md
Expand Down
2 changes: 1 addition & 1 deletion src/dbally/gradio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from dbally.gradio.gradio_interface import create_gradio_interface
from dbally.gradio.interface import create_gradio_interface

__all__ = ["create_gradio_interface"]
Loading
Loading