Skip to content

Commit 8992dea

Browse files
authored
Merge pull request #390 from tomorrmato/add_example_type_hint
added type hint in example code
2 parents 4c370db + 89092cd commit 8992dea

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

example_chat_completion.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Copyright (c) Meta Platforms, Inc. and affiliates.
22
# This software may be used and distributed according to the terms of the Llama 2 Community License Agreement.
33

4-
from typing import Optional
4+
from typing import List, Optional
55

66
import fire
77

8-
from llama import Llama
8+
from llama import Llama, Dialog
99

1010

1111
def main(
@@ -39,7 +39,7 @@ def main(
3939
max_batch_size=max_batch_size,
4040
)
4141

42-
dialogs = [
42+
dialogs: List[Dialog] = [
4343
[{"role": "user", "content": "what is the recipe of mayonnaise?"}],
4444
[
4545
{"role": "user", "content": "I am going to Paris, what should I see?"},

example_text_completion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import fire
55

66
from llama import Llama
7-
7+
from typing import List
88

99
def main(
1010
ckpt_dir: str,
@@ -36,7 +36,7 @@ def main(
3636
max_batch_size=max_batch_size,
3737
)
3838

39-
prompts = [
39+
prompts: List[str] = [
4040
# For these prompts, the expected answer is the natural continuation of the prompt
4141
"I believe the meaning of life is",
4242
"Simply put, the theory of relativity states that ",

llama/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright (c) Meta Platforms, Inc. and affiliates.
22
# This software may be used and distributed according to the terms of the Llama 2 Community License Agreement.
33

4-
from .generation import Llama
4+
from .generation import Llama, Dialog
55
from .model import ModelArgs, Transformer
66
from .tokenizer import Tokenizer

0 commit comments

Comments
 (0)