Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
maxisawesome committed Apr 19, 2024
1 parent eec82a1 commit 6fc714b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions llmfoundry/models/inference_api_wrapper/gemini_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
import os
import random
from time import sleep
from typing import Any, List, Optional, Union
from typing import TYPE_CHECKING, Any, List, Optional, Union

from composer.core.types import Batch
from composer.utils.import_helpers import MissingConditionalImportError
from omegaconf import DictConfig
from openai.types.chat.chat_completion import ChatCompletion
from transformers import AutoTokenizer

log = logging.getLogger(__name__)
Expand All @@ -20,6 +19,9 @@
from llmfoundry.models.inference_api_wrapper.interface import \
InferenceAPIEvalWrapper

if TYPE_CHECKING:
from openai.types.chat.chat_completion import ChatCompletion

MAX_RETRIES = 3

__all__ = [
Expand Down Expand Up @@ -65,7 +67,7 @@ def generate_completion(
self,
prompt: str, #
num_tokens: int,
generation_kwargs: Optional[dict] = None) -> ChatCompletion:
generation_kwargs: Optional[dict] = None) -> 'ChatCompletion':
if generation_kwargs is None:
generation_kwargs = {}
if isinstance(prompt, str):
Expand All @@ -81,7 +83,7 @@ def generate_completion(
else:
raise ValueError(f'Prompt must be str: {prompt}')

def completion_to_string(self, completion: ChatCompletion):
def completion_to_string(self, completion: 'ChatCompletion'):
try:
# sometimes gemini will block outputs due to content filters
return [completion.text]
Expand Down

0 comments on commit 6fc714b

Please sign in to comment.