Skip to content

Commit 2770824

Browse files
authored
Merge pull request #2161 from Giskard-AI/fix/2156-bug-modulenotfounderror-no-module-named-ipython
chore(deps): add IPython dependency and improve import structure in r…
2 parents e53c8ae + 24d98db commit 2770824

File tree

4 files changed

+35
-23
lines changed

4 files changed

+35
-23
lines changed

giskard/rag/report.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import matplotlib
88
import numpy as np
99
import pandas as pd
10-
from IPython.core.display import HTML
1110

1211
from ..llm.client.base import LLMClient
1312
from ..llm.embeddings.base import BaseEmbedding
@@ -135,6 +134,8 @@ def to_html(self, filename=None, embed=False):
135134
return
136135

137136
if embed:
137+
from IPython.core.display import HTML
138+
138139
return HTML(f'<iframe srcdoc="{escape(html)}" width=100% height=800px></iframe>')
139140
return html
140141

pdm.lock

Lines changed: 22 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ dependencies = [
174174
"colorama", # needed for the scan
175175
"num2words>=0.5.13",
176176
"griffe>=1.0.0,<2.0.0",
177+
"ipython",
177178
]
178179

179180
[project.optional-dependencies]

tests/rag/test_report.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from unittest.mock import Mock, patch
33

44
import numpy as np
5+
import pytest
56
from bokeh.plotting import figure
67

78
from giskard.rag import QATestset, RAGReport
@@ -98,6 +99,15 @@ def test_report_plots():
9899
assert len(histograms["Question"]["simple"]) == 4
99100

100101

102+
@pytest.mark.parametrize("embed", [False, True])
103+
def test_report_to_html(embed):
104+
"""Test that to_html works correctly with different embed parameter values."""
105+
testset, answers, metrics_results = _create_test_data()
106+
107+
report = RAGReport(testset, answers, metrics_results)
108+
report.to_html(embed=embed)
109+
110+
101111
def test_report_save_load(tmp_path):
102112
testset, answers, metrics_results = _create_test_data(with_documents=True)
103113
llm_client = Mock()

0 commit comments

Comments
 (0)