Merge pull request #3703 from msabramo/msabramo/make-langsmith-integration-work-with-custom-langsmith

Work with custom `LANGSMITH_BASE_URL`
This commit is contained in:
Krish Dholakia 2024-05-16 22:23:09 -07:00 • committed by GitHub
commit d9ce94ae23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View file

@ -71,6 +71,23 @@ response = litellm.completion(
)
print(response)
```
### Make LiteLLM Proxy use Custom `LANGSMITH_BASE_URL`
If you're using a custom LangSmith instance, you can set the
`LANGSMITH_BASE_URL` environment variable to point to your instance.
For example, you can make LiteLLM Proxy log to a local LangSmith instance with
this config:
```yaml
litellm_settings:
success_callback: ["langsmith"]
environment_variables:
LANGSMITH_BASE_URL: "http://localhost:1984"
LANGSMITH_PROJECT: "litellm-proxy"
```
## Support & Talk to Founders
- [Schedule Demo 👋](https://calendly.com/d/4mp-gd3-k5k/berriai-1-1-onboarding-litellm-hosted-version)

View file

@ -44,6 +44,8 @@ class LangsmithLogger:
print_verbose(
f"Langsmith Logging - project_name: {project_name}, run_name {run_name}"
)
langsmith_base_url = os.getenv("LANGSMITH_BASE_URL", "https://api.smith.langchain.com")
try:
print_verbose(
f"Langsmith Logging - Enters logging function for model {kwargs}"
@ -86,8 +88,12 @@ class LangsmithLogger:
"end_time": end_time,
}
url = f"{langsmith_base_url}/runs"
print_verbose(
f"Langsmith Logging - About to send data to {url} ..."
)
response = requests.post(
"https://api.smith.langchain.com/runs",
url=url,
json=data,
headers={"x-api-key": self.langsmith_api_key},
)