mirror of
https://github.com/hwchase17/langchain.git
synced 2026-07-14 05:11:08 +00:00
13 lines
512 B
Python
13 lines
512 B
Python
from typing import Any, Dict, List
|
|
|
|
from langchain.schema import get_buffer_string # noqa: 401
|
|
|
|
|
|
def get_prompt_input_key(inputs: Dict[str, Any], memory_variables: List[str]) -> str:
|
|
# "stop" is a special key that can be passed as input but is not used to
|
|
# format the prompt.
|
|
prompt_input_keys = list(set(inputs).difference(memory_variables + ["stop"]))
|
|
if len(prompt_input_keys) != 1:
|
|
raise ValueError(f"One input key expected got {prompt_input_keys}")
|
|
return prompt_input_keys[0]
|