class_docstr: Reference: https://github.com/petals-infra/chat.petals.dev#post-apiv1generate
  The `PetalsConfig` class encapsulates the configuration for the Petals API. The properties of this class are described below:
  
  - `max_length` (integer): This represents the maximum length of the generated text (including the prefix) in tokens.
  
  - `max_new_tokens` (integer): This represents the maximum number of newly generated tokens (excluding the prefix).
  
  The generation parameters are compatible with `.generate()` from Hugging Face's Transformers library:
  
  - `do_sample` (boolean, optional): If set to 0 (default), the API runs greedy generation. If set to 1, the API performs sampling using the parameters below:
  
  - `temperature` (float, optional): This value sets the temperature for sampling.
  
  - `top_k` (integer, optional): This value sets the limit for top-k sampling.
  
  - `top_p` (float, optional): This value sets the limit for top-p (nucleus) sampling.
  
  - `repetition_penalty` (float, optional): This helps apply the repetition penalty during text generation, as discussed in this paper.
class_docstr_tok: ["Reference",":","https",":","\/\/github.com\/petals-infra\/chat.petals.dev","#","post-apiv1generate","The","`","PetalsConfig","`","class","encapsulates","the","configuration","for","the","Petals","API",".","The","properties","of","this","class","are","described","below",":","-","`","max_length","`","(","integer",")",":","This","represents","the","maximum","length","of","the","generated","text","(","including","the","prefix",")","in","tokens",".","-","`","max_new_tokens","`","(","integer",")",":","This","represents","the","maximum","number","of","newly","generated","tokens","(","excluding","the","prefix",")",".","The","generation","parameters","are","compatible","with","`",".generate","(",")","`","from","Hugging","Face","'s","Transformers","library",":","-","`","do_sample","`","(","boolean",",","optional",")",":","If","set","to","0","(","default",")",",","the","API","runs","greedy","generation",".","If","set","to","1",",","the","API","performs","sampling","using","the","parameters","below",":","-","`","temperature","`","(","float",",","optional",")",":","This","value","sets","the","temperature","for","sampling",".","-","`","top_k","`","(","integer",",","optional",")",":","This","value","sets","the","limit","for","top-k","sampling",".","-","`","top_p","`","(","float",",","optional",")",":","This","value","sets","the","limit","for","top-p","(","nucleus",")","sampling",".","-","`","repetition_penalty","`","(","float",",","optional",")",":","This","helps","apply","the","repetition","penalty","during","text","generation",",","as","discussed","in","this","paper","."]
code: def __init__(
      self,
      max_length: Optional[int] = None,
      max_new_tokens: Optional[
          int
      ] = litellm.max_tokens,  # petals requires max tokens to be set
      do_sample: Optional[bool] = None,
      temperature: Optional[float] = None,
      top_k: Optional[int] = None,
      top_p: Optional[float] = None,
      repetition_penalty: Optional[float] = None,
  ) -> None:
      locals_ = locals()
      for key, value in locals_.items():
          if key != "self" and value is not None:
              setattr(self.__class__, key, value)
  
file_path: litellm/litellm/llms/petals.py
imports: import os, types
  import json
  from enum import Enum
  import requests
  import time
  from typing import Callable, Optional
  import litellm
  from litellm.utils import ModelResponse, Usage
  from .prompt_templates.factory import prompt_factory, custom_prompt
label_desc: Use image node_id 1 to create a new PetalsConfig object  with example: obj = PetalsConfig(max_length, max_new_tokens, do_sample, temperature, top_k, top_p, repetition_penalty)