Skip to content

Commit

Permalink
removed semanti context from parameters as it was not required
Browse files Browse the repository at this point in the history
  • Loading branch information
gr8nishan committed Jul 26, 2024
1 parent b43af38 commit 6c8be4e
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions libs/community/langchain_community/chains/pebblo_retrieval/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ def _call(
auth_context = inputs.get(self.auth_context_key, {})
semantic_context = inputs.get(self.semantic_context_key, {})

is_valid_prompt, prompt_entities = self._check_prompt_validity(
question, semantic_context
)
is_valid_prompt, prompt_entities = self._check_prompt_validity(question)
logger.info(f"is_valid_prompt {is_valid_prompt}")

_run_manager = run_manager or CallbackManagerForChainRun.get_noop_manager()
Expand Down Expand Up @@ -192,9 +190,7 @@ async def _acall(
"run_manager" in inspect.signature(self._aget_docs).parameters
)

is_valid_prompt, prompt_entities = self._check_prompt_validity(
question, semantic_context
)
is_valid_prompt, prompt_entities = self._check_prompt_validity(question)
logger.info(f"is_valid_prompt {is_valid_prompt}")

if accepts_run_manager:
Expand Down Expand Up @@ -535,24 +531,20 @@ def _send_prompt(self, qa_payload: Qa) -> None:
logger.warning("API key is missing for sending prompt to Pebblo cloud.")
raise NameError("API key is missing for sending prompt to Pebblo cloud.")

def _check_prompt_validity(
self, question: str, semantic_context: SemanticContext
) -> tuple:
def _check_prompt_validity(self, question: str) -> tuple[bool, Dict[str, Any]]:
"""
Check the validity of the given prompt using a remote classification service.
This method sends a prompt to a remote classifier service to determine if it
contains any entities that are on a deny list,
as specified in the semantic context.
This method sends a prompt to a remote classifier service and return entities
present in prompt or not.
Args:
question (str): The prompt question to be validated.
semantic_context (SemanticContext): The semantic context
containing deny list entities.
Returns:
bool: True if the prompt is valid (does not contain deny list entities),
False otherwise.
dict: The entities present in the prompt
"""

headers = {
Expand Down

0 comments on commit 6c8be4e

Please sign in to comment.