Testing the sample code against a Azure OpenAI gpt-3.5 instance - I get this error, after a handful of tests seem to successfully run:
2024-09-18 11:35:09,227 pid:4610 MainThread giskard.scanner.logger ERROR Detector LLMHarmfulContentDetector failed with error: the JSON object must be str, bytes or bytearray, not NoneType
Traceback (most recent call last):
File "/opt/anaconda3/envs/giskard-env/lib/python3.11/site-packages/giskard/scanner/scanner.py", line 162, in _run_detectors
detected_issues = detector.run(model, dataset, features=features)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/giskard-env/lib/python3.11/site-packages/giskard/scanner/llm/base.py", line 77, in run
eval_dataset = dg.generate_dataset(model, self.num_samples)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/giskard-env/lib/python3.11/site-packages/giskard/llm/generators/base.py", line 72, in generate_dataset
generated = self._parse_output(out)
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/giskard-env/lib/python3.11/site-packages/giskard/llm/generators/base.py", line 85, in _parse_output
data = json.loads(raw_output.content)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/giskard-env/lib/python3.11/json/__init__.py", line 339, in loads
raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType
Traceback (most recent call last):
File "/Users/labuser/giskard_azure_openai.py", line 82, in <module>
scan_results = giskard.scan(giskard_model, raise_exceptions=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/giskard-env/lib/python3.11/site-packages/giskard/scanner/__init__.py", line 67, in scan
return scanner.analyze(
^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/giskard-env/lib/python3.11/site-packages/giskard/scanner/scanner.py", line 126, in analyze
issues, errors = self._run_detectors(
^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/giskard-env/lib/python3.11/site-packages/giskard/scanner/scanner.py", line 176, in _run_detectors
raise err
File "/opt/anaconda3/envs/giskard-env/lib/python3.11/site-packages/giskard/scanner/scanner.py", line 162, in _run_detectors
detected_issues = detector.run(model, dataset, features=features)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/giskard-env/lib/python3.11/site-packages/giskard/scanner/llm/base.py", line 77, in run
eval_dataset = dg.generate_dataset(model, self.num_samples)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/giskard-env/lib/python3.11/site-packages/giskard/llm/generators/base.py", line 72, in generate_dataset
generated = self._parse_output(out)
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/giskard-env/lib/python3.11/site-packages/giskard/llm/generators/base.py", line 85, in _parse_output
data = json.loads(raw_output.content)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/giskard-env/lib/python3.11/json/__init__.py", line 339, in loads
raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType
Standalone code OR list down the steps to reproduce the issue
I'm trying to do the stand-alone LLM wrapping based on this doc: https://docs.giskard.ai/en/stable/open_source/scan/scan_llm/index.html
and I wrote my own llm_api() since it appears thats not included in the sample/doc, which simply does a POST to the Azure OpenAI endpoint passing the "question" properly to the chat endpoint.
Issue Type
Bug
Source
source
Giskard Library Version
2.14.4
OS Platform and Distribution
Mac Command line, python venv
Python version
3.11.9
Installed python packages
Current Behaviour?
Standalone code OR list down the steps to reproduce the issue
Relevant log output