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] expose universalCompletion class in __init__.py #39

Closed
signebedi opened this issue Mar 29, 2023 · 2 comments
Closed

[scripting] expose universalCompletion class in __init__.py #39

signebedi opened this issue Mar 29, 2023 · 2 comments

Comments

@signebedi
Copy link
Owner

[scripting] expose certain classes / structs via init.py
We should expose certain classes / structs here. For example, the log dataframe.

@signebedi signebedi changed the title [scripting] expose certain classes / structs via __init__.py [scripting] expose certain classes / structs via __init__.py Mar 31, 2023
@signebedi
Copy link
Owner Author

signebedi commented Apr 4, 2023

I think it is also worth creating a universalQuery class that can be used to create a query that (1) validates a passed model_name and, based on this, properly generates a query based on a question passed to a corresponding method, and then queries using a separate method.

class universalQuery:
  def __init__(self, model_name):
    ...

  def generate_query(self, question, tag): 
  # I think it's best for us to expect users to pull out the tag outside the context of this class method
    ...

  def submit_query_sync(self, query): # synchronous query
    ...

  def submit_query_async(self, query): # asynchronous query
    ...

We can expose this in init.py, even though it is not really how we do things.

@signebedi signebedi changed the title [scripting] expose certain classes / structs via __init__.py [scripting] expose universalQuery class in __init__.py Apr 6, 2023
@signebedi signebedi changed the title [scripting] expose universalQuery class in __init__.py [scripting] expose universalCompletion class in __init__.py May 25, 2023
@signebedi
Copy link
Owner Author

[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

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