Skip to content

Commit b2bea7e

Browse files
committed
Return object instead of list when running GuardrailSequence.
1 parent eebdd41 commit b2bea7e

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

ads/llm/chain.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ def run(self, input: Any, num_generations: int = 1, **kwargs) -> GuardrailIO:
178178
if self.log_info or os.environ.get(LOG_ADS_GUARDRAIL_INFO) == "1":
179179
# LOG_ADS_GUARDRAIL_INFO is set to "1" in score.py by default.
180180
print(obj.dict())
181+
# If the output is a singleton list, take it out of the list.
182+
if isinstance(obj.data, list) and len(obj.data) == 1:
183+
obj.data = obj.data[0]
181184
return obj
182185

183186
def _save_to_file(self, chain_dict, filename, overwrite=False):

ads/llm/langchain/plugins/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def _print_response(self, completion, response):
4646

4747
@classmethod
4848
def get_lc_namespace(cls) -> List[str]:
49-
"""Get the namespace of the langchain object."""
49+
"""Get the namespace of the LangChain object."""
5050
return ["ads", "llm"]
5151

5252
@classmethod

0 commit comments

Comments
 (0)