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};
12
13use crate::models;
14
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct CustomLlmModel {
17 /// This is the starting state for the conversation.
18 #[serde(rename = "messages", skip_serializing_if = "Option::is_none")]
19 pub messages: Option<Vec<models::OpenAiMessage>>,
20 /// 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.
21 #[serde(rename = "tools", skip_serializing_if = "Option::is_none")]
22 pub tools: Option<Vec<models::AnyscaleModelToolsInner>>,
23 /// 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.
24 #[serde(rename = "toolIds", skip_serializing_if = "Option::is_none")]
25 pub tool_ids: Option<Vec<String>>,
26 #[serde(rename = "knowledgeBase", skip_serializing_if = "Option::is_none")]
27 pub knowledge_base: Option<models::AnyscaleModelKnowledgeBase>,
28 /// This is the ID of the knowledge base the model will use.
29 #[serde(rename = "knowledgeBaseId", skip_serializing_if = "Option::is_none")]
30 pub knowledge_base_id: Option<String>,
31 /// 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.
32 #[serde(rename = "provider")]
33 pub provider: Provider,
34 /// 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`.
35 #[serde(rename = "metadataSendMode", skip_serializing_if = "Option::is_none")]
36 pub metadata_send_mode: Option<MetadataSendMode>,
37 /// These is the URL we'll use for the OpenAI client's `baseURL`. Ex. https://openrouter.ai/api/v1
38 #[serde(rename = "url")]
39 pub url: String,
40 /// This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b
41 #[serde(rename = "model")]
42 pub model: String,
43 /// This is the temperature that will be used for calls. Default is 0 to leverage caching for lower latency.
44 #[serde(rename = "temperature", skip_serializing_if = "Option::is_none")]
45 pub temperature: Option<f64>,
46 /// This is the max number of tokens that the assistant will be allowed to generate in each turn of the conversation. Default is 250.
47 #[serde(rename = "maxTokens", skip_serializing_if = "Option::is_none")]
48 pub max_tokens: Option<f64>,
49 /// 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
50 #[serde(
51 rename = "emotionRecognitionEnabled",
52 skip_serializing_if = "Option::is_none"
53 )]
54 pub emotion_recognition_enabled: Option<bool>,
55 /// 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
56 #[serde(rename = "numFastTurns", skip_serializing_if = "Option::is_none")]
57 pub num_fast_turns: Option<f64>,
58}
59
60impl CustomLlmModel {
61 pub fn new(provider: Provider, url: String, model: String) -> CustomLlmModel {
62 CustomLlmModel {
63 messages: None,
64 tools: None,
65 tool_ids: None,
66 knowledge_base: None,
67 knowledge_base_id: None,
68 provider,
69 metadata_send_mode: None,
70 url,
71 model,
72 temperature: None,
73 max_tokens: None,
74 emotion_recognition_enabled: None,
75 num_fast_turns: None,
76 }
77 }
78}
79/// 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.
80#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
81pub enum Provider {
82 #[serde(rename = "custom-llm")]
83 CustomLlm,
84}
85
86impl Default for Provider {
87 fn default() -> Provider {
88 Self::CustomLlm
89 }
90}
91/// 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`.
92#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
93pub enum MetadataSendMode {
94 #[serde(rename = "off")]
95 Off,
96 #[serde(rename = "variable")]
97 Variable,
98 #[serde(rename = "destructured")]
99 Destructured,
100}
101
102impl Default for MetadataSendMode {
103 fn default() -> MetadataSendMode {
104 Self::Off
105 }
106}