99 lines
3.4 KiB
Plaintext
99 lines
3.4 KiB
Plaintext
---
|
|
# id: moonshot
|
|
title: Moonshot
|
|
sidebar_label: Moonshot
|
|
---
|
|
|
|
DeepEval's integration with Moonshot AI allows you to use any Moonshot models to power all of DeepEval's metrics.
|
|
|
|
### Command Line
|
|
|
|
To configure your Moonshot model through the CLI, run the following command:
|
|
|
|
```bash
|
|
deepeval set-moonshot \
|
|
--model="kimi-k2-0711-preview" \
|
|
--temperature=0
|
|
```
|
|
|
|
:::info
|
|
The CLI command above sets Moonshot as the default provider for all metrics, unless overridden in Python code. To use a different default model provider, you must first unset Moonshot:
|
|
|
|
```bash
|
|
deepeval unset-moonshot
|
|
```
|
|
|
|
:::
|
|
|
|
:::tip[Persisting settings]
|
|
You can persist CLI settings with the optional `--save` flag.
|
|
See [Flags and Configs -> Persisting CLI settings](/docs/evaluation-flags-and-configs#persisting-cli-settings-with---save).
|
|
:::
|
|
|
|
### Python
|
|
|
|
Alternatively, you can define `KimiModel` directly in python code:
|
|
|
|
<Tabs items={["Python", "ENV"]}>
|
|
<Tab value="Python">
|
|
|
|
```python
|
|
from deepeval.models import KimiModel
|
|
from deepeval.metrics import AnswerRelevancyMetric
|
|
|
|
model = KimiModel(
|
|
model="kimi-k2-0711-preview",
|
|
api_key="your-api-key",
|
|
temperature=0
|
|
)
|
|
|
|
answer_relevancy = AnswerRelevancyMetric(model=model)
|
|
```
|
|
|
|
</Tab>
|
|
<Tab value="ENV">
|
|
|
|
To use any Moonshot model directly in `deepeval`, set the `USE_MOONSHOT_MODEL=1` in your `env` and simply pass the name of your desired model in your metric initialization:
|
|
|
|
```python
|
|
from deepeval.metrics import AnswerRelevancyMetric
|
|
|
|
answer_relevancy = AnswerRelevancyMetric(
|
|
model="kimi-k2-0711-preview",
|
|
)
|
|
```
|
|
|
|
You should also set the other necessary vars like `MOONSHOT_API_KEY` to be able to use the Moonshot models as shown above.
|
|
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
There are **ZERO** mandatory and **SIX** optional parameters when creating an `KimiModel`:
|
|
|
|
- [Optional] `model`: A string specifying the name of the Kimi model to use. Defaults to `MOONSHOT_MODEL_NAME` if not passed; raises an error at runtime if unset.
|
|
- [Optional] `api_key`: A string specifying your Kimi API key for authentication. Defaults to `MOONSHOT_API_KEY` if not passed; raises an error at runtime if unset.
|
|
- [Optional] `temperature`: A float specifying the model temperature. Defaults to `TEMPERATURE` if not passed; falls back to `0.0` if unset and raises if < 0.
|
|
- [Optional] `cost_per_input_token`: A float specifying the cost for each input token for the provided model. Defaults to `MOONSHOT_COST_PER_INPUT_TOKEN` if available in `deepeval`'s model cost registry, else `None`.
|
|
- [Optional] `cost_per_output_token`: A float specifying the cost for each output token for the provided model. Defaults to `MOONSHOT_COST_PER_OUTPUT_TOKEN` if available in `deepeval`'s model cost registry, else `None`.
|
|
- [Optional] `generation_kwargs`: A dictionary of additional generation parameters forwarded to the OpenAI `chat.completions.create(...)` call.
|
|
|
|
:::tip
|
|
Any `**kwargs` you would like to use for your model can be passed through the `generation_kwargs` parameter. However, we request you to double check the params supported by the model and your model provider in their [official docs](https://docs.together.ai/docs/inference-parameters).
|
|
:::
|
|
|
|
### Available Moonshot Models
|
|
|
|
Below is a comprehensive list of available Moonshot models:
|
|
|
|
- `kimi-k2-0711-preview`
|
|
- `kimi-thinking-preview`
|
|
- `moonshot-v1-8k`
|
|
- `moonshot-v1-32k`
|
|
- `moonshot-v1-128k`
|
|
- `moonshot-v1-8k-vision-preview`
|
|
- `moonshot-v1-32k-vision-preview`
|
|
- `moonshot-v1-128k-vision-preview`
|
|
- `kimi-latest-8k`
|
|
- `kimi-latest-32k`
|
|
- `kimi-latest-128k`
|