Litellm dev 12 24 2024 p4 (#7407)

* fix(invoke_handler.py): fix mock response iterator to handle tool calling

returns tool call if returned by model response

* fix(prometheus.py): add new 'tokens_by_tag' metric on prometheus

allows tracking 'token usage' by task

* feat(prometheus.py): add input + output token tracking by tag

* feat(prometheus.py): add tag based deployment failure tracking

allows admin to track failure by use-case
This commit is contained in:
Krish Dholakia 2024-12-24 20:24:06 -08:00 committed by GitHub
parent 81be0b4090
commit 39dabb2e89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 209 additions and 12 deletions

View file

@ -745,3 +745,20 @@ def test_stream_chunk_builder_empty_initial_chunk():
id = ChunkProcessor._get_chunk_id(chunks)
assert id == "1"
import json
def get_current_weather(location, unit="fahrenheit"):
"""Get the current weather in a given location"""
if "tokyo" in location.lower():
return json.dumps({"location": "Tokyo", "temperature": "10", "unit": "celsius"})
elif "san francisco" in location.lower():
return json.dumps(
{"location": "San Francisco", "temperature": "72", "unit": "fahrenheit"}
)
elif "paris" in location.lower():
return json.dumps({"location": "Paris", "temperature": "22", "unit": "celsius"})
else:
return json.dumps({"location": location, "temperature": "unknown"})