Skip to content

Commit ad30e69

Browse files
authored
Add openai store parameter support (#967)
* Add support for openai store param See `store` param here: https://platform.openai.com/docs/api-reference/chat/create#chat-create-store * test store param
1 parent 4296ce5 commit ad30e69

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/langchain/llm/parameters/chat.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class Chat < SimpleDelegator
3030
presence_penalty: {}, # Range: [-2, 2]
3131
repetition_penalty: {}, # Range: (0, 2]
3232
seed: {}, # OpenAI only
33+
store: {}, # store messages with OpenAI
3334

3435
# Function-calling
3536
tools: {default: []},

spec/langchain/llm/parameters/chat_spec.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
presence_penalty: 1,
2222
repetition_penalty: 1,
2323
seed: 1,
24+
store: false,
2425
tools: [{type: "function", function: {name: "Temp", parameters: {substance: "H20"}}}],
2526
tool_choice: "auto",
2627
logit_bias: {"2435": -100, "640": -100}
@@ -36,7 +37,7 @@
3637

3738
context "delegations" do
3839
it "filters parameters to those provided" do
39-
params_with_extras = valid_params.merge(blah: 1, beep: "beep", boop: "boop")
40+
params_with_extras = valid_params.merge(blah: 1, beep: "beep", boop: "boop", store: true)
4041
chat_params = described_class.new
4142
chat_params.alias_field(:max_tokens, as: :max_tokens_to_sample)
4243
expect(chat_params.to_params(params_with_extras)).to match(
@@ -55,6 +56,7 @@
5556
presence_penalty: 1,
5657
repetition_penalty: 1,
5758
seed: 1,
59+
store: true,
5860
tools: [{type: "function", function: {name: "Temp", parameters: {substance: "H20"}}}],
5961
tool_choice: "auto",
6062
logit_bias: {"2435": -100, "640": -100}
@@ -69,4 +71,18 @@
6971
expect(chat_params.to_params(valid_params)[:max_tokens]).to eq(100)
7072
end
7173
end
74+
75+
context "store parameter" do
76+
it "passes store parameter to to_params" do
77+
chat_params = described_class.new
78+
params = chat_params.to_params(store: true)
79+
expect(params[:store]).to eq(true)
80+
end
81+
82+
it "defaults to nil" do
83+
chat_params = described_class.new
84+
params = chat_params.to_params({})
85+
expect(params[:store]).to be_nil
86+
end
87+
end
7288
end

0 commit comments

Comments
 (0)