Skip to content

Commit 55c3ce1

Browse files
author
Nicholas Cecere
committed
Add merge_reasoning_content_in_choices option to model resource
1 parent fc52482 commit 55c3ce1

File tree

5 files changed

+64
-45
lines changed

5 files changed

+64
-45
lines changed

CHANGELOG.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,23 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.2.6] - 2025-03-13
9+
10+
### Added
11+
- Added new `merge_reasoning_content_in_choices` option to model resource
12+
13+
## [0.2.5] - 2025-03-13
14+
15+
### Fixed
16+
- Fixed issue where `thinking_budget_tokens` was being added to models that don't have `thinking_enabled = true`
17+
818
## [0.2.4] - 2025-03-13
919

1020
### Added
1121
- Added new `thinking` capability to model resource with configurable parameters:
1222
- `thinking_enabled` - Boolean to enable/disable thinking capability (default: false)
1323
- `thinking_budget_tokens` - Integer to set token budget for thinking (default: 1024)
1424

15-
### Fixed
16-
- Fixed issue where `thinking_budget_tokens` was being added to models that don't have `thinking_enabled = true`
17-
1825
## [0.2.2] - 2025-02-06
1926

2027
### Added

docs/resources/model.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ resource "litellm_model" "gpt4" {
1717
reasoning_effort = "medium"
1818
thinking_enabled = true
1919
thinking_budget_tokens = 1024
20+
merge_reasoning_content_in_choices = true
2021
tpm = 100000
2122
rpm = 1000
2223
@@ -70,6 +71,8 @@ The following arguments are supported:
7071

7172
* `thinking_budget_tokens` - (Optional) Sets the token budget for the model's thinking capability. Default is `1024`.
7273

74+
* `merge_reasoning_content_in_choices` - (Optional) When set to `true`, merges reasoning content into the model's choices.
75+
7376
* `input_cost_per_million_tokens` - (Optional) Cost per million input tokens. This will be automatically converted to the per-token cost required by the API.
7477

7578
* `output_cost_per_million_tokens` - (Optional) Cost per million output tokens. This will be automatically converted to the per-token cost required by the API.

litellm/resource_model.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ func resourceLiteLLMModel() *schema.Resource {
5252
return !d.Get("thinking_enabled").(bool)
5353
},
5454
},
55+
"merge_reasoning_content_in_choices": {
56+
Type: schema.TypeBool,
57+
Optional: true,
58+
},
5559
"model_api_key": {
5660
Type: schema.TypeString,
5761
Optional: true,

litellm/resource_model_crud.go

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,28 @@ func createOrUpdateModel(d *schema.ResourceData, m interface{}, isUpdate bool) e
4747
modelReq := ModelRequest{
4848
ModelName: d.Get("model_name").(string),
4949
LiteLLMParams: LiteLLMParams{
50-
CustomLLMProvider: customLLMProvider,
51-
TPM: d.Get("tpm").(int),
52-
RPM: d.Get("rpm").(int),
53-
APIKey: d.Get("model_api_key").(string),
54-
APIBase: d.Get("model_api_base").(string),
55-
APIVersion: d.Get("api_version").(string),
56-
Model: modelName,
57-
InputCostPerToken: inputCostPerToken,
58-
OutputCostPerToken: outputCostPerToken,
59-
InputCostPerPixel: d.Get("input_cost_per_pixel").(float64),
60-
OutputCostPerPixel: d.Get("output_cost_per_pixel").(float64),
61-
InputCostPerSecond: d.Get("input_cost_per_second").(float64),
62-
OutputCostPerSecond: d.Get("output_cost_per_second").(float64),
63-
AWSAccessKeyID: d.Get("aws_access_key_id").(string),
64-
AWSSecretAccessKey: d.Get("aws_secret_access_key").(string),
65-
AWSRegionName: d.Get("aws_region_name").(string),
66-
VertexProject: d.Get("vertex_project").(string),
67-
VertexLocation: d.Get("vertex_location").(string),
68-
VertexCredentials: d.Get("vertex_credentials").(string),
69-
ReasoningEffort: d.Get("reasoning_effort").(string),
70-
Thinking: thinking,
50+
CustomLLMProvider: customLLMProvider,
51+
TPM: d.Get("tpm").(int),
52+
RPM: d.Get("rpm").(int),
53+
APIKey: d.Get("model_api_key").(string),
54+
APIBase: d.Get("model_api_base").(string),
55+
APIVersion: d.Get("api_version").(string),
56+
Model: modelName,
57+
InputCostPerToken: inputCostPerToken,
58+
OutputCostPerToken: outputCostPerToken,
59+
InputCostPerPixel: d.Get("input_cost_per_pixel").(float64),
60+
OutputCostPerPixel: d.Get("output_cost_per_pixel").(float64),
61+
InputCostPerSecond: d.Get("input_cost_per_second").(float64),
62+
OutputCostPerSecond: d.Get("output_cost_per_second").(float64),
63+
AWSAccessKeyID: d.Get("aws_access_key_id").(string),
64+
AWSSecretAccessKey: d.Get("aws_secret_access_key").(string),
65+
AWSRegionName: d.Get("aws_region_name").(string),
66+
VertexProject: d.Get("vertex_project").(string),
67+
VertexLocation: d.Get("vertex_location").(string),
68+
VertexCredentials: d.Get("vertex_credentials").(string),
69+
ReasoningEffort: d.Get("reasoning_effort").(string),
70+
Thinking: thinking,
71+
MergeReasoningContentInChoices: d.Get("merge_reasoning_content_in_choices").(bool),
7172
},
7273
ModelInfo: ModelInfo{
7374
ID: modelID,
@@ -166,6 +167,9 @@ func resourceLiteLLMModelRead(d *schema.ResourceData, m interface{}) error {
166167
// Don't set thinking_budget_tokens when thinking is not enabled
167168
}
168169

170+
// Handle merge_reasoning_content_in_choices
171+
d.Set("merge_reasoning_content_in_choices", modelResp.LiteLLMParams.MergeReasoningContentInChoices)
172+
169173
return nil
170174
}
171175

litellm/types.go

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,28 @@ type TeamResponse struct {
4545

4646
// LiteLLMParams represents the parameters for LiteLLM.
4747
type LiteLLMParams struct {
48-
CustomLLMProvider string `json:"custom_llm_provider"`
49-
TPM int `json:"tpm,omitempty"`
50-
RPM int `json:"rpm,omitempty"`
51-
ReasoningEffort string `json:"reasoning_effort,omitempty"`
52-
Thinking map[string]interface{} `json:"thinking,omitempty"`
53-
APIKey string `json:"api_key,omitempty"`
54-
APIBase string `json:"api_base,omitempty"`
55-
APIVersion string `json:"api_version,omitempty"`
56-
Model string `json:"model"`
57-
InputCostPerToken float64 `json:"input_cost_per_token,omitempty"`
58-
OutputCostPerToken float64 `json:"output_cost_per_token,omitempty"`
59-
InputCostPerPixel float64 `json:"input_cost_per_pixel,omitempty"`
60-
OutputCostPerPixel float64 `json:"output_cost_per_pixel,omitempty"`
61-
InputCostPerSecond float64 `json:"input_cost_per_second,omitempty"`
62-
OutputCostPerSecond float64 `json:"output_cost_per_second,omitempty"`
63-
AWSAccessKeyID string `json:"aws_access_key_id,omitempty"`
64-
AWSSecretAccessKey string `json:"aws_secret_access_key,omitempty"`
65-
AWSRegionName string `json:"aws_region_name,omitempty"`
66-
VertexProject string `json:"vertex_project,omitempty"`
67-
VertexLocation string `json:"vertex_location,omitempty"`
68-
VertexCredentials string `json:"vertex_credentials,omitempty"`
48+
CustomLLMProvider string `json:"custom_llm_provider"`
49+
TPM int `json:"tpm,omitempty"`
50+
RPM int `json:"rpm,omitempty"`
51+
ReasoningEffort string `json:"reasoning_effort,omitempty"`
52+
Thinking map[string]interface{} `json:"thinking,omitempty"`
53+
MergeReasoningContentInChoices bool `json:"merge_reasoning_content_in_choices,omitempty"`
54+
APIKey string `json:"api_key,omitempty"`
55+
APIBase string `json:"api_base,omitempty"`
56+
APIVersion string `json:"api_version,omitempty"`
57+
Model string `json:"model"`
58+
InputCostPerToken float64 `json:"input_cost_per_token,omitempty"`
59+
OutputCostPerToken float64 `json:"output_cost_per_token,omitempty"`
60+
InputCostPerPixel float64 `json:"input_cost_per_pixel,omitempty"`
61+
OutputCostPerPixel float64 `json:"output_cost_per_pixel,omitempty"`
62+
InputCostPerSecond float64 `json:"input_cost_per_second,omitempty"`
63+
OutputCostPerSecond float64 `json:"output_cost_per_second,omitempty"`
64+
AWSAccessKeyID string `json:"aws_access_key_id,omitempty"`
65+
AWSSecretAccessKey string `json:"aws_secret_access_key,omitempty"`
66+
AWSRegionName string `json:"aws_region_name,omitempty"`
67+
VertexProject string `json:"vertex_project,omitempty"`
68+
VertexLocation string `json:"vertex_location,omitempty"`
69+
VertexCredentials string `json:"vertex_credentials,omitempty"`
6970
}
7071

7172
// ModelInfo represents information about a model.

0 commit comments

Comments
 (0)