Skip to content

Commit

Permalink
test(test_completion.py): add test for max token count
Browse files Browse the repository at this point in the history
  • Loading branch information
krrishdholakia committed Feb 6, 2024
1 parent 8bb49a2 commit 9c2e0bd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions litellm/tests/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,15 +542,22 @@ def hf_test_completion_tgi():


def test_completion_openai():
"""
- Tests openai call
- tests max tokens adjustment logic
"""
try:
litellm.set_verbose = True
litellm.drop_params = True
print(f"api key: {os.environ['OPENAI_API_KEY']}")
litellm.api_key = os.environ["OPENAI_API_KEY"]
content = """Alexander III of Macedon (Ancient Greek: Ἀλέξανδρος, romanized: Alexandros; 20/21 July 356 BC – 10/11 June 323 BC), most commonly known as Alexander the Great,[c] was a king of the ancient Greek kingdom of Macedon.[d] He succeeded his father Philip II to the throne in 336 BC at the age of 20 and spent most of his ruling years conducting a lengthy military campaign throughout Western Asia, Central Asia, parts of South Asia, and Egypt. By the age of 30, he had created one of the largest empires in history, stretching from Greece to northwestern India.[1] He was undefeated in battle and is widely considered to be one of history's greatest and most successful military commanders.[2][3]
Until the age of 16, Alexander was tutored by Aristotle. In 335 BC, shortly after his assumption of kingship over Macedon, he campaigned in the Balkans and reasserted control over Thrace and parts of Illyria before marching on the city of Thebes, which was subsequently destroyed in battle. Alexander then led the League of Corinth, and used his authority to launch the pan-Hellenic project envisaged by his father, assuming leadership over all Greeks in their conquest of Persia.["""
response = completion(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "Hey"}],
max_tokens=10,
messages=[{"role": "user", "content": content}],
max_tokens=4000,
metadata={"hi": "bye"},
)
print("This is the response object\n", response)
Expand Down

0 comments on commit 9c2e0bd

Please sign in to comment.