mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
fix(langsmith.py): add /api/v1
to langsmith base url
ensures it works with self hosted langsmith
This commit is contained in:
parent
2017596913
commit
d7f862783d
2 changed files with 15 additions and 3 deletions
|
@ -351,6 +351,16 @@ class LangsmithLogger(CustomBatchLogger):
|
||||||
queue_objects=batch_group.queue_objects,
|
queue_objects=batch_group.queue_objects,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _add_endpoint_to_url(
|
||||||
|
self, url: str, endpoint: str, api_version: str = "/api/v1"
|
||||||
|
) -> str:
|
||||||
|
if api_version not in url:
|
||||||
|
url = f"{url.rstrip('/')}{api_version}"
|
||||||
|
|
||||||
|
if url.endswith("/"):
|
||||||
|
return f"{url}{endpoint}"
|
||||||
|
return f"{url}/{endpoint}"
|
||||||
|
|
||||||
async def _log_batch_on_langsmith(
|
async def _log_batch_on_langsmith(
|
||||||
self,
|
self,
|
||||||
credentials: LangsmithCredentialsObject,
|
credentials: LangsmithCredentialsObject,
|
||||||
|
@ -370,7 +380,7 @@ class LangsmithLogger(CustomBatchLogger):
|
||||||
"""
|
"""
|
||||||
langsmith_api_base = credentials["LANGSMITH_BASE_URL"]
|
langsmith_api_base = credentials["LANGSMITH_BASE_URL"]
|
||||||
langsmith_api_key = credentials["LANGSMITH_API_KEY"]
|
langsmith_api_key = credentials["LANGSMITH_API_KEY"]
|
||||||
url = f"{langsmith_api_base}/runs/batch"
|
url = self._add_endpoint_to_url(langsmith_api_base, "runs/batch")
|
||||||
headers = {"x-api-key": langsmith_api_key}
|
headers = {"x-api-key": langsmith_api_key}
|
||||||
elements_to_log = [queue_object["data"] for queue_object in queue_objects]
|
elements_to_log = [queue_object["data"] for queue_object in queue_objects]
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,9 @@ model_list:
|
||||||
id: "1"
|
id: "1"
|
||||||
- model_name: gpt-3.5-turbo-end-user-test
|
- model_name: gpt-3.5-turbo-end-user-test
|
||||||
litellm_params:
|
litellm_params:
|
||||||
model: openai/random_sleep
|
model: gpt-3.5-turbo
|
||||||
api_base: http://0.0.0.0:8090
|
|
||||||
timeout: 2
|
timeout: 2
|
||||||
num_retries: 0
|
num_retries: 0
|
||||||
|
|
||||||
|
litellm_settings:
|
||||||
|
callbacks: ["langsmith"]
|
Loading…
Add table
Add a link
Reference in a new issue