openai_struct/models/finish_reason.rs
1/*
2 * OpenAI API
3 *
4 * The OpenAI REST API. Please see pub https://platform.openai.com/docs/api-reference for more details.
5 *
6 * OpenAPI spec pub version: 2.3.0
7 *
8 * Generated pub by: https://github.com/swagger-api/swagger-codegen.git
9 */
10
11#[allow(unused_imports)]
12use serde_json::Value;
13
14/// The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `content_filter` if content was omitted due to a flag from our content filters, `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.
15
16/// # on openai.yaml
17///
18/// ```yaml
19/// finish_reason:
20/// type: string
21/// description: >
22/// The reason the model stopped generating tokens. This will be
23/// `stop` if the model hit a natural stop point or a provided
24/// stop sequence,
25///
26/// `length` if the maximum number of tokens specified in the
27/// request was reached,
28///
29/// `content_filter` if content was omitted due to a flag from our
30/// content filters,
31///
32/// `tool_calls` if the model called a tool, or `function_call`
33/// (deprecated) if the model called a function.
34/// enum:
35/// - stop
36/// - length
37/// - tool_calls
38/// - content_filter
39/// - function_call
40/// ```
41#[derive(Debug, Serialize, Deserialize)]
42#[serde(rename_all = "snake_case")]
43pub enum FinishReason {
44 Stop,
45 Length,
46 ContentFilter,
47 ToolCalls,
48 FunctionCall,
49}
50
51#[test]
52fn test_finish_reason() {
53 assert_eq!(
54 serde_json::to_string(&FinishReason::ContentFilter)
55 .unwrap()
56 .as_str(),
57 "\"content_filter\""
58 );
59}