Skip to content

Commit

Permalink
modified 'return' mode to return a single html object
Browse files Browse the repository at this point in the history
  • Loading branch information
cyber-raskolnikov committed Mar 23, 2022
1 parent 0cf0aa5 commit 70bba93
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bertviz/head_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def head_view(
Note: filtering layers may improve responsiveness of the visualization for long inputs.
action: Specifies the viewing action to be performed with the generated HTML object
- 'view' (default): Displays the generated HTML representation as a notebook cell output
- 'return' : Returns the HTML object containing the generated view for further processing
- 'return' : Returns an HTML object containing the generated view for further processing
"""

attn_data = []
Expand Down Expand Up @@ -227,7 +227,10 @@ def head_view(
os.path.join(os.getcwd(), os.path.dirname(__file__)))
vis_js = open(os.path.join(__location__, 'head_view.js')).read().replace("PYTHON_PARAMS", json.dumps(params))
html3 = Javascript(vis_js)
return html1, html2, html3
# might need to reformat this JS code with appropriate tags for web browser displaying

head_html = HTML(html1.data + html2.data + html3.data)
return head_html

else:
raise ValueError("'action' parameter must be 'view' or 'return")

0 comments on commit 70bba93

Please sign in to comment.