-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
83 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# How-To: Visualize Views | ||
|
||
There has been implemented Gradio Adapter class to create simple UI interface. It allows to display Data Preview related to Views | ||
and execute user queries. | ||
|
||
## Installation | ||
```bash | ||
pip install dbally[gradio] | ||
``` | ||
|
||
## Create own gradio interface | ||
Define collection with implemented views | ||
|
||
```python | ||
llm = LiteLLM(model_name="gpt-3.5-turbo") | ||
collection = dbally.create_collection("recruitment", llm, event_handlers=[CLIEventHandler()]) | ||
collection.add(CandidateView, lambda: CandidateView(engine)) | ||
collection.add(SampleText2SQLView, lambda: SampleText2SQLView(prepare_freeform_enginge())) | ||
``` | ||
|
||
Create gradio interface | ||
```python | ||
gradio_adapter = GradioAdapter() | ||
gradio_interface = await gradio_adapter.create_interface(collection, similarity_store_list=[country_similarity]) | ||
``` | ||
|
||
Launch the gradio interface. To publish public interface pass argument `share=True` | ||
```python | ||
gradio_interface.launch() | ||
``` | ||
|
||
The endpoint is set by gradio server by triggering python module with Gradio Adapter launch command. | ||
Private endpoint is set to http://127.0.0.1:7860/ by default. | ||
|
||
## Links | ||
* [Example Gradio Interface](visualize_views_code.py) |
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
This file was deleted.
Oops, something went wrong.
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,18 @@ | ||
import sys | ||
|
||
|
||
class FileLogger: | ||
def __init__(self, filename): | ||
self.logFile = open(filename, "w") | ||
self.console = sys.stdout | ||
|
||
def write(self, message): | ||
self.logFile.write(message) | ||
self.console.write(message) | ||
|
||
def flush(self): | ||
self.logFile.flush() | ||
self.console.flush() | ||
|
||
def isatty(self): | ||
return False |