Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[scripting] extend the UniversalCompletion class with context generation #68

Open
signebedi opened this issue May 25, 2023 · 0 comments

Comments

@signebedi
Copy link
Owner

[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 #39 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant