vapi_client/models/
custom_llm_model.rs

1/*
2 * Vapi API
3 *
4 * API for building voice assistants
5 *
6 * The version of the OpenAPI document: 1.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use serde::{Deserialize, Serialize};
12use utoipa::ToSchema;
13
14
15use crate::models;
16
17#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, ToSchema)]
18pub struct CustomLlmModel {
19    /// This is the starting state for the conversation.
20    #[serde(rename = "messages", skip_serializing_if = "Option::is_none")]
21    pub messages: Option<Vec<models::OpenAiMessage>>,
22    /// These are the tools that the assistant can use during the call. To use existing tools, use `toolIds`.  Both `tools` and `toolIds` can be used together.
23    #[serde(rename = "tools", skip_serializing_if = "Option::is_none")]
24    pub tools: Option<Vec<models::AnyscaleModelToolsInner>>,
25    /// These are the tools that the assistant can use during the call. To use transient tools, use `tools`.  Both `tools` and `toolIds` can be used together.
26    #[serde(rename = "toolIds", skip_serializing_if = "Option::is_none")]
27    pub tool_ids: Option<Vec<String>>,
28    #[serde(rename = "knowledgeBase", skip_serializing_if = "Option::is_none")]
29    pub knowledge_base: Option<models::AnyscaleModelKnowledgeBase>,
30    /// This is the ID of the knowledge base the model will use.
31    #[serde(rename = "knowledgeBaseId", skip_serializing_if = "Option::is_none")]
32    pub knowledge_base_id: Option<String>,
33    /// This is the provider that will be used for the model. Any service, including your own server, that is compatible with the OpenAI API can be used.
34    #[serde(rename = "provider")]
35    pub provider: Provider,
36    /// This determines whether metadata is sent in requests to the custom provider.  - `off` will not send any metadata. payload will look like `{ messages }` - `variable` will send `assistant.metadata` as a variable on the payload. payload will look like `{ messages, metadata }` - `destructured` will send `assistant.metadata` fields directly on the payload. payload will look like `{ messages, ...metadata }`  Further, `variable` and `destructured` will send `call`, `phoneNumber`, and `customer` objects in the payload.  Default is `variable`.
37    #[serde(rename = "metadataSendMode", skip_serializing_if = "Option::is_none")]
38    pub metadata_send_mode: Option<MetadataSendMode>,
39    /// These is the URL we'll use for the OpenAI client's `baseURL`. Ex. https://openrouter.ai/api/v1
40    #[serde(rename = "url")]
41    pub url: String,
42    /// This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b
43    #[serde(rename = "model")]
44    pub model: String,
45    /// This is the temperature that will be used for calls. Default is 0 to leverage caching for lower latency.
46    #[serde(rename = "temperature", skip_serializing_if = "Option::is_none")]
47    pub temperature: Option<f64>,
48    /// This is the max number of tokens that the assistant will be allowed to generate in each turn of the conversation. Default is 250.
49    #[serde(rename = "maxTokens", skip_serializing_if = "Option::is_none")]
50    pub max_tokens: Option<f64>,
51    /// This determines whether we detect user's emotion while they speak and send it as an additional info to model.  Default `false` because the model is usually are good at understanding the user's emotion from text.  @default false
52    #[serde(
53        rename = "emotionRecognitionEnabled",
54        skip_serializing_if = "Option::is_none"
55    )]
56    pub emotion_recognition_enabled: Option<bool>,
57    /// This sets how many turns at the start of the conversation to use a smaller, faster model from the same provider before switching to the primary model. Example, gpt-3.5-turbo if provider is openai.  Default is 0.  @default 0
58    #[serde(rename = "numFastTurns", skip_serializing_if = "Option::is_none")]
59    pub num_fast_turns: Option<f64>,
60}
61
62impl CustomLlmModel {
63    pub fn new(provider: Provider, url: String, model: String) -> CustomLlmModel {
64        CustomLlmModel {
65            messages: None,
66            tools: None,
67            tool_ids: None,
68            knowledge_base: None,
69            knowledge_base_id: None,
70            provider,
71            metadata_send_mode: None,
72            url,
73            model,
74            temperature: None,
75            max_tokens: None,
76            emotion_recognition_enabled: None,
77            num_fast_turns: None,
78        }
79    }
80}
81/// This is the provider that will be used for the model. Any service, including your own server, that is compatible with the OpenAI API can be used.
82#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, ToSchema)]
83pub enum Provider {
84    #[serde(rename = "custom-llm")]
85    CustomLlm,
86}
87
88impl Default for Provider {
89    fn default() -> Provider {
90        Self::CustomLlm
91    }
92}
93/// This determines whether metadata is sent in requests to the custom provider.  - `off` will not send any metadata. payload will look like `{ messages }` - `variable` will send `assistant.metadata` as a variable on the payload. payload will look like `{ messages, metadata }` - `destructured` will send `assistant.metadata` fields directly on the payload. payload will look like `{ messages, ...metadata }`  Further, `variable` and `destructured` will send `call`, `phoneNumber`, and `customer` objects in the payload.  Default is `variable`.
94#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, ToSchema)]
95pub enum MetadataSendMode {
96    #[serde(rename = "off")]
97    Off,
98    #[serde(rename = "variable")]
99    Variable,
100    #[serde(rename = "destructured")]
101    Destructured,
102}
103
104impl Default for MetadataSendMode {
105    fn default() -> MetadataSendMode {
106        Self::Off
107    }
108}