[scripting] extend the UniversalCompletion class with context generation
We should extend the UniversalCompletion class with features that support generating context like in gptty.context.
def build_context(self,
prompt: str,
context: List[Dict[str, str]],
max_context_length: int,
model_type: Optional[str] = None,
context_keywords_only: bool = True,
additional_context: str = "",
) -> Union[str, List[Dict[str, str]]]:
"""
Builds a full query context for a given prompt and context.
Parameters:
prompt (str): The main prompt to build the context around.
context (List[Dict[str, str]]): List of past prompts and responses.
max_context_length (int): Maximum length of the context to return.
model_type (Optional[str]): Type of the language model. If 'v1/chat/completions', return a list of dicts
with 'role' and 'content' keys. If not, return a string. Default is None.
context_keywords_only (bool, optional): If True, use only the most common phrases and words from the context
and additional context. Default is True.
additional_context (str, optional): Additional context to add to the context. Default is an empty string.
Returns:
Union[str, List[Dict[str, str]]]: If `model_type` is 'v1/chat/completions', returns a list of dicts with
'role' and 'content' keys. If not, returns a string.
"""
pass
Originally posted by @signebedi in https://github.com/signebedi/gptty/issues/39#issuecomment-1562294652