forked from phoenix/litellm-mirror
(Feat) Add langsmith key based logging (#6682)
* add langsmith_api_key to StandardCallbackDynamicParams * create a file for langsmith types * langsmith add key / team based logging * add key based logging for langsmith * fix langsmith key based logging * fix linting langsmith * remove NOQA violation * add unit test coverage for all helpers in test langsmith * test_langsmith_key_based_logging * docs langsmith key based logging * run langsmith tests in logging callback tests * fix logging testing * test_langsmith_key_based_logging * test_add_callback_via_key_litellm_pre_call_utils_langsmith * add debug statement langsmith key based logging * test_langsmith_key_based_logging
This commit is contained in:
parent
1e2ba3e045
commit
c3bc9e6b12
9 changed files with 810 additions and 179 deletions
|
@ -281,6 +281,51 @@ curl -X POST 'http://0.0.0.0:4000/key/generate' \
|
|||
}'
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="Langsmith" value="langsmith">
|
||||
|
||||
1. Create Virtual Key to log to a specific Langsmith Project
|
||||
|
||||
```bash
|
||||
curl -X POST 'http://0.0.0.0:4000/key/generate' \
|
||||
-H 'Authorization: Bearer sk-1234' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"metadata": {
|
||||
"logging": [{
|
||||
"callback_name": "langsmith", # "otel", "gcs_bucket"
|
||||
"callback_type": "success", # "success", "failure", "success_and_failure"
|
||||
"callback_vars": {
|
||||
"langsmith_api_key": "os.environ/LANGSMITH_API_KEY", # API Key for Langsmith logging
|
||||
"langsmith_project": "pr-brief-resemblance-72", # project name on langsmith
|
||||
"langsmith_base_url": "https://api.smith.langchain.com"
|
||||
}
|
||||
}]
|
||||
}
|
||||
}'
|
||||
|
||||
```
|
||||
|
||||
2. Test it - `/chat/completions` request
|
||||
|
||||
Use the virtual key from step 3 to make a `/chat/completions` request
|
||||
|
||||
You should see your logs on your Langsmith project on a successful request
|
||||
|
||||
```shell
|
||||
curl -i http://localhost:4000/v1/chat/completions \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer sk-Fxq5XSyWKeXDKfPdqXZhPg" \
|
||||
-d '{
|
||||
"model": "fake-openai-endpoint",
|
||||
"messages": [
|
||||
{"role": "user", "content": "Hello, Claude"}
|
||||
],
|
||||
"user": "hello",
|
||||
}'
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue