Skip to content

Commit

Permalink
Allow null context in LLMQA ingredient
Browse files Browse the repository at this point in the history
  • Loading branch information
parkervg committed Oct 16, 2024
1 parent c8e3058 commit 3ee8077
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions blendsql/ingredients/builtin/qa/examples.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from attr import attrs, attrib, validators
from attr import attrs, attrib
import pandas as pd
from typing import Optional, List, Callable

Expand All @@ -8,9 +8,9 @@
@attrs(kw_only=True)
class QAExample(Example):
question: str = attrib()
context: pd.DataFrame = attrib(
context: Optional[pd.DataFrame] = attrib(
converter=lambda d: pd.DataFrame.from_dict(d) if isinstance(d, dict) else d,
validator=validators.instance_of(pd.DataFrame),
default=None,
)
options: Optional[List[str]] = attrib(default=None)

Expand All @@ -19,7 +19,8 @@ def to_string(self, context_formatter: Callable[[pd.DataFrame], str]) -> str:
s += f"\n\nQuestion: {self.question}\n"
if self.options is not None:
s += f"Options: {', '.join(self.options)}\n"
s += f"Context:\n{context_formatter(self.context)}"
if self.context is not None:
s += f"Context:\n{context_formatter(self.context)}"
s += "\nAnswer: "
return s

Expand Down

0 comments on commit 3ee8077

Please sign in to comment.