From 35fda2cd05b16afc09ccc3abb0663216808763ef Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Wed, 20 Sep 2023 20:47:03 -0700 Subject: [PATCH] add latency to docs --- docs/my-website/docs/completion/output.md | 19 ++++++++++++++++++- litellm/tests/test_completion.py | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/docs/my-website/docs/completion/output.md b/docs/my-website/docs/completion/output.md index 6f7f503ff3..3016cd7da7 100644 --- a/docs/my-website/docs/completion/output.md +++ b/docs/my-website/docs/completion/output.md @@ -1,4 +1,6 @@ -# Output Format +# Output + +## Format Here's the exact json output and type you can expect from all litellm `completion` calls for all models ```python @@ -47,4 +49,19 @@ Here's what an example response looks like 'model': 'claude-instant-1', 'usage': {'prompt_tokens': 18, 'completion_tokens': 23, 'total_tokens': 41} } +``` + +## Additional Attributes + +You can also access information like latency. + +``` +import litellm +os.environ["ANTHROPIC_API_KEY"] = "sk-litellm-5b46387675a944d2" + +messages=[{"role": "user", "content": "Hey!"}] + +response = completion(model="claude-2", messages=messages) + +print(response.response_ms) # 616.25 ``` \ No newline at end of file diff --git a/litellm/tests/test_completion.py b/litellm/tests/test_completion.py index a0b39b8f0e..c1c1133f6e 100644 --- a/litellm/tests/test_completion.py +++ b/litellm/tests/test_completion.py @@ -829,11 +829,11 @@ def test_completion_ai21(): response = completion(model=model_name, messages=messages) # Add any assertions here to check the response print(response["response_ms"]) + print(dir(response)) print(response.response_ms) except Exception as e: pytest.fail(f"Error occurred: {e}") -test_completion_ai21() # test config file with completion # # def test_completion_openai_config(): # try: