Skip to content

Commit

Permalink
Updated docs (#745)
Browse files Browse the repository at this point in the history
  • Loading branch information
jverre authored Nov 27, 2024
1 parent 9c71bcb commit 8adcfa4
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def evaluation_task(x):
"retrieved_contexts": x["contexts"],
}


# Create scoring metric wrapper
class AnswerRelevancyWrapper(base_metric.BaseMetric):
def __init__(self, metric):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ hallucination_metric = Hallucination(

## Using a model supported by LiteLLM

In order to use many models supported by LiteLLM, you also need to pass additional parameters. You can pass these when initializing your metric and they will be passed to the `litellm` call:
In order to use many models supported by LiteLLM, you also need to pass additional parameters. For this, you can use the [LiteLLMChatModel](https://www.comet.com/docs/opik/python-sdk-reference/Objects/LiteLLMChatModel.html) class and passing it to the metric:

```python
from opik.evaluation.metrics import Hallucination
from opik.evaluation.models import LiteLLMChatModel

model = LiteLLMChatModel(
name="<model_name>",
base_url="<base_url>"
)

hallucination_metric = Hallucination(
model="gpt-4-turbo",
api_base="https://your-custom-llm-provider.com/v1"
model=model
)
```

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
id: get-span-stats
title: "Get span stats"
description: "Get span stats"
sidebar_label: "Get span stats"
hide_title: true
hide_table_of_contents: true
api: eJzFV21vI7cR/itTfmoPa8l3bVpkUQRwHMMxcrgzbF+K4mScR9yRlhGXZMihFEXQfy+Gu7Ilv/T8IUC+6IWcefjMM8MhuVGM86Tqz+o6oEvqtlINJR1NYOOdqtU5MaSADhIjJ1UpHyiiTF40qlZzYnG8HiYDRuyIKQrkRjnsSNUqRP8Laf5iGlUpI6i/ZoprVamkW+pQ1RvF6yCmiaNxc1WpmY8dsqpVzqZR2231BK38fSXevj9H1PQHcSmWr8YhlzuRek6OIlpVKfZevqzt1O0+7szYIuKrw7utVKQUvEuUZP7d8bF8Heby+j6PECn5HLW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9Wu7EjuQtMVLVzwcytj+b3UuF7DhjM0YLWEyWG2/vF5McPHhgXJEUlzCL12RaeB2g71qVPQ+Opr8Ohfor93feEkSLcQYg0M7+N4MZDWhnWrWiYk1T0vYJF7J1YB1uzKttAY+GnrdELqWMxo8YwTDOzd9CYFCyuqYFVSw5avyS574B8D3RkT3y6en+3ZzsARSlgaEsHMw3tMjMUxHDVQ80P9y11XpoPXFHwybAvt8zD1vxSe5Jj1BpNLtEe3klA3RK8Gx0fAA0tHsvsyMf5eHBN4/cXp2cfrs+O3o2ORy13VnDlmOmb9tvR8ei4XGh84g7dPvXHL5ODdr95uNc+tRxOY6bfeBwsGicrFLab4Rj8rJZvy2leDkI5/MrzqBquubeVkk0rdpvNFBN9ina7leH+qi5HZGMSTi01qp6hTVSpBa0fP4aG+4EqR+JXHIb3zmtc9p44rzLvL8GvMX14mDxY38qfaMRc1Z9vt5Xqd1VRoXc70ZoC73k9eWkIyv2F5PzsRm23/wNpGATh
sidebar_class_name: "get api-method"
info_path: reference/rest_api/opik-rest-api
custom_edit_url: null
hide_send_button: true
---

import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";
import ParamsDetails from "@theme/ParamsDetails";
import RequestSchema from "@theme/RequestSchema";
import StatusCodes from "@theme/StatusCodes";
import OperationTabs from "@theme/OperationTabs";
import TabItem from "@theme/TabItem";
import Heading from "@theme/Heading";

<Heading
as={"h1"}
className={"openapi__heading"}
children={"Get span stats"}
>
</Heading>

<MethodEndpoint
method={"get"}
path={"/v1/private/spans/stats"}
context={"endpoint"}
>

</MethodEndpoint>



Get span stats

<Heading
id={"request"}
as={"h2"}
className={"openapi-tabs__heading"}
children={"Request"}
>
</Heading>

<ParamsDetails
parameters={[{"name":"project_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"project_name","in":"query","schema":{"type":"string"}},{"name":"trace_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"type","in":"query","schema":{"type":"string","enum":["general","tool","llm"]}},{"name":"filters","in":"query","schema":{"type":"string"}}]}
>

</ParamsDetails>

<RequestSchema
title={"Body"}
body={undefined}
>

</RequestSchema>

<StatusCodes
id={undefined}
label={undefined}
responses={{"200":{"description":"Span stats resource","content":{"application/json":{"schema":{"type":"object","properties":{"stats":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string","enum":["COUNT","PERCENTAGE","AVG"]}},"discriminator":{"propertyName":"type","mapping":{"PERCENTAGE":{"type":"object","allOf":["circular(ProjectStatItemObject_Public)",{"type":"object","properties":{"value":{"type":"object","properties":{"p50":{"type":"number"},"p90":{"type":"number"},"p99":{"type":"number"}},"title":"PercentageValues_Public"}}}],"title":"PercentageValueStat_Public"},"COUNT":{"type":"object","allOf":["circular(ProjectStatItemObject_Public)",{"type":"object","properties":{"value":{"type":"integer","format":"int64"}}}],"title":"CountValueStat_Public"},"AVG":{"type":"object","allOf":["circular(ProjectStatItemObject_Public)",{"type":"object","properties":{"value":{"type":"number","format":"double"}}}],"title":"AvgValueStat_Public"}}},"title":"ProjectStatItemObject_Public"}}},"title":"ProjectStats_Public"}}}}}}
>

</StatusCodes>



Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
id: get-trace-stats
title: "Get trace stats"
description: "Get trace stats"
sidebar_label: "Get trace stats"
hide_title: true
hide_table_of_contents: true
api: eJzFV1Fv2zYQ/is3Pm2BbCfduqHCMMBLgyxYkASJ02Gog5qmzhZrilTJo13X8H8fjpJju06WvvXFssi7j999PB5PK0FyGkT+Xgy8VBjEQyYKDMrrmrSzIhfnSEA8B4EkBZEJV6OXPHtRiFxMkZLrXTtbSy8rJPSMuhJWVihyUXv3ERV90IXIhGbcTxH9UmQiqBIrKfKVoGXNpoG8tlORiYnzlSSRixh1Idbr7AAtvX4j3q7/RJtE8JtdHzLhMdTOBgw8/+r4mB/7Sg22KoHH4KJXzE45S2iJ7WVdG62Sdr2PgZ1Wh4u6McfGSnpWmnSzZKP+1kx6L5m0JqzCy+5N5AeRZe3AofpoY8V5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0KNRQOmzxs8yfZj/5E6dHDCGqPE/25CwMHYaFJlaxhDJzRjwomsTdi7R3NLB0DJRM/ZbSacR6zGRaaYByJnIVCh9rIJRawKNFC6ebIDQ/ws6XDZ+L+9nK0Y9sCeU5gKFMF0wVudqZNiLbXk4q2DZc4T8UHbrF2QZNLfeZ+aX6uPPE9arRCG3AHr19LVSK86h7vAbUlXqbZrvPTXusaepcXp2dXd2edV93jbkmVYVy+ZpqifdI97h6njsYFqqTdpX7Q+e/V+9W2s33CtL2QCT9TrzZSW14j8V21N+F7MT9JF3q6C9ml+QLJ2lb3IRN8btlwtRrLgPferNc83PTrfEsWOsixwULkE2kCZmKGy6+/NtoeQaRb8QWH9oPiW1y23xBb6wd+8ZrNRf7+YZ2JJv0T18atrxTWtON18E3AKI+tw/nZQKzX/wHLJbTI
sidebar_class_name: "get api-method"
info_path: reference/rest_api/opik-rest-api
custom_edit_url: null
hide_send_button: true
---

import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";
import ParamsDetails from "@theme/ParamsDetails";
import RequestSchema from "@theme/RequestSchema";
import StatusCodes from "@theme/StatusCodes";
import OperationTabs from "@theme/OperationTabs";
import TabItem from "@theme/TabItem";
import Heading from "@theme/Heading";

<Heading
as={"h1"}
className={"openapi__heading"}
children={"Get trace stats"}
>
</Heading>

<MethodEndpoint
method={"get"}
path={"/v1/private/traces/stats"}
context={"endpoint"}
>

</MethodEndpoint>



Get trace stats

<Heading
id={"request"}
as={"h2"}
className={"openapi-tabs__heading"}
children={"Request"}
>
</Heading>

<ParamsDetails
parameters={[{"name":"project_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"project_name","in":"query","schema":{"type":"string"}},{"name":"filters","in":"query","schema":{"type":"string"}}]}
>

</ParamsDetails>

<RequestSchema
title={"Body"}
body={undefined}
>

</RequestSchema>

<StatusCodes
id={undefined}
label={undefined}
responses={{"200":{"description":"Trace stats resource","content":{"application/json":{"schema":{"type":"object","properties":{"stats":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string","enum":["COUNT","PERCENTAGE","AVG"]}},"discriminator":{"propertyName":"type","mapping":{"PERCENTAGE":{"type":"object","allOf":["circular(ProjectStatItemObject_Public)",{"type":"object","properties":{"value":{"type":"object","properties":{"p50":{"type":"number"},"p90":{"type":"number"},"p99":{"type":"number"}},"title":"PercentageValues_Public"}}}],"title":"PercentageValueStat_Public"},"COUNT":{"type":"object","allOf":["circular(ProjectStatItemObject_Public)",{"type":"object","properties":{"value":{"type":"integer","format":"int64"}}}],"title":"CountValueStat_Public"},"AVG":{"type":"object","allOf":["circular(ProjectStatItemObject_Public)",{"type":"object","properties":{"value":{"type":"number","format":"double"}}}],"title":"AvgValueStat_Public"}}},"title":"ProjectStatItemObject_Public"}}},"title":"ProjectStats_Public"}}}}}}
>

</StatusCodes>



Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,12 @@ const sidebar: SidebarsConfig = {
label: "Find Feedback Score names",
className: "api-method get",
},
{
type: "doc",
id: "reference/rest_api/get-span-stats",
label: "Get span stats",
className: "api-method get",
},
{
type: "doc",
id: "reference/rest_api/score-batch-of-spans",
Expand Down Expand Up @@ -454,6 +460,12 @@ const sidebar: SidebarsConfig = {
label: "Find Feedback Score names",
className: "api-method get",
},
{
type: "doc",
id: "reference/rest_api/get-trace-stats",
label: "Get trace stats",
className: "api-method get",
},
{
type: "doc",
id: "reference/rest_api/score-batch-of-traces",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
LiteLLMChatModel
================

.. autoclass:: opik.evaluation.models.LiteLLMChatModel
:members:
:inherited-members:
:special-members: __init__
2 changes: 1 addition & 1 deletion apps/opik-documentation/python-sdk-docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ You can learn more about the `opik` python SDK in the following sections:
Objects/ExperimentItem.rst
Objects/Prompt.rst
Objects/OpikBaseModel.rst

Objects/LiteLLMChatModel.rst
.. toctree::
:maxdepth: 1
:caption: Command Line Interface
Expand Down

0 comments on commit 8adcfa4

Please sign in to comment.