Merge pull request #4853 from BerriAI/litellm_support_tags

[Feat] - Support Logging tags on langsmith
This commit is contained in:
Ishaan Jaff 2024-07-24 09:51:56 -07:00 committed by GitHub
commit ac7f6598f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 1 deletions

View file

@ -56,7 +56,7 @@ response = litellm.completion(
```
## Advanced
### Set Custom Project & Run names
### Set Langsmith fields - Custom Projec, Run names, tags
```python
import litellm
@ -77,6 +77,7 @@ response = litellm.completion(
metadata={
"run_name": "litellmRUN", # langsmith run name
"project_name": "litellm-completion", # langsmith project name
"tags": ["model1", "prod-2"] # tags to log on langsmith
}
)
print(response)

View file

@ -79,6 +79,7 @@ class LangsmithLogger(CustomLogger):
project_name = metadata.get("project_name", self.langsmith_project)
run_name = metadata.get("run_name", self.langsmith_default_run_name)
run_id = metadata.get("id", None)
tags = metadata.get("tags", []) or []
verbose_logger.debug(
f"Langsmith Logging - project_name: {project_name}, run_name {run_name}"
)
@ -122,6 +123,7 @@ class LangsmithLogger(CustomLogger):
"session_name": project_name,
"start_time": start_time,
"end_time": end_time,
"tags": tags,
}
if run_id:

View file

@ -36,6 +36,7 @@ async def test_async_langsmith_logging():
temperature=0.2,
metadata={
"id": run_id,
"tags": ["tag1", "tag2"],
"user_api_key": "6eb81e014497d89f3cc1aa9da7c2b37bda6b7fea68e4b710d33d94201e68970c",
"user_api_key_alias": "ishaans-langmsith-key",
"user_api_end_user_max_budget": None,