add latency to docs

This commit is contained in:
Krrish Dholakia
2023-09-20 20:47:05 -07:00
parent 04abf986fc
commit 35fda2cd05
2 changed files with 19 additions and 2 deletions
+18 -1
View File
@@ -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
```
+1 -1
View File
@@ -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: