1313// limitations under the License.
1414
1515import React from "react" ;
16- import { Button , Card , Col , Input , Row , Select } from "antd" ;
16+ import { Button , Card , Col , Input , InputNumber , Row , Select , Slider } from "antd" ;
1717import * as ProviderBackend from "./backend/ProviderBackend" ;
1818import * as Setting from "./Setting" ;
1919import i18next from "i18next" ;
@@ -51,6 +51,8 @@ class ProviderEditPage extends React.Component {
5151 parseProviderField ( key , value ) {
5252 if ( [ "" ] . includes ( key ) ) {
5353 value = Setting . myParseInt ( value ) ;
54+ } else if ( [ "temperature" , "topP" , "frequencyPenalty" , "presencePenalty" ] . includes ( key ) ) {
55+ value = Setting . myParseFloat ( value ) ;
5456 }
5557 return value ;
5658 }
@@ -65,6 +67,44 @@ class ProviderEditPage extends React.Component {
6567 } ) ;
6668 }
6769
70+ InputSlider ( props ) {
71+ const {
72+ min,
73+ max,
74+ step,
75+ value,
76+ onChange,
77+ } = props ;
78+
79+ return (
80+ < >
81+ < Col span = { 2 } >
82+ < InputNumber
83+ min = { min }
84+ max = { max }
85+ step = { step }
86+ style = { { width : "100%" } }
87+ value = { value }
88+ onChange = { onChange }
89+ />
90+ </ Col >
91+ < Col span = { 20 } >
92+ < Slider
93+ min = { min }
94+ max = { max }
95+ step = { step }
96+ style = { {
97+ marginLeft : "1%" ,
98+ marginRight : "1%" ,
99+ } }
100+ value = { value }
101+ onChange = { onChange }
102+ />
103+ </ Col >
104+ </ >
105+ ) ;
106+ }
107+
68108 renderProvider ( ) {
69109 return (
70110 < Card size = "small" title = {
@@ -171,6 +211,74 @@ class ProviderEditPage extends React.Component {
171211 </ Row >
172212 )
173213 }
214+ {
215+ ( this . state . provider . category === "Model" && this . state . provider . type === "OpenAI" ) ? (
216+ < >
217+ < Row style = { { marginTop : "20px" } } >
218+ < Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
219+ { i18next . t ( "provider:Temperature" ) } :
220+ </ Col >
221+ < this . InputSlider
222+ min = { 0 }
223+ max = { 2 }
224+ step = { 0.01 }
225+ value = { this . state . provider . temperature }
226+ onChange = { ( value ) => {
227+ this . updateProviderField ( "temperature" , value ) ;
228+ } }
229+ isMobile = { Setting . isMobile ( ) }
230+ />
231+ </ Row >
232+ < Row style = { { marginTop : "20px" } } >
233+ < Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
234+ { i18next . t ( "provider:Top P" ) } :
235+ </ Col >
236+ < this . InputSlider
237+ min = { 0 }
238+ max = { 1 }
239+ step = { 0.01 }
240+ value = { this . state . provider . topP }
241+ onChange = { ( value ) => {
242+ this . updateProviderField ( "topP" , value ) ;
243+ } }
244+ isMobile = { Setting . isMobile ( ) }
245+ />
246+ </ Row >
247+ < Row style = { { marginTop : "20px" } } >
248+ < Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
249+ { i18next . t ( "provider:Frequency penalty" ) } :
250+ </ Col >
251+ < this . InputSlider
252+ label = { i18next . t ( "provider:Frequency penalty" ) }
253+ min = { - 2 }
254+ max = { 2 }
255+ step = { 0.01 }
256+ value = { this . state . provider . frequencyPenalty }
257+ onChange = { ( value ) => {
258+ this . updateProviderField ( "frequencyPenalty" , value ) ;
259+ } }
260+ isMobile = { Setting . isMobile ( ) }
261+ />
262+ </ Row >
263+ < Row style = { { marginTop : "20px" } } >
264+ < Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
265+ { i18next . t ( "provider:Presence penalty" ) } :
266+ </ Col >
267+ < this . InputSlider
268+ label = { i18next . t ( "provider:Presence penalty" ) }
269+ min = { - 2 }
270+ max = { 2 }
271+ step = { 0.01 }
272+ value = { this . state . provider . presencePenalty }
273+ onChange = { ( value ) => {
274+ this . updateProviderField ( "presencePenalty" , value ) ;
275+ } }
276+ isMobile = { Setting . isMobile ( ) }
277+ />
278+ </ Row >
279+ </ >
280+ ) : null
281+ }
174282 < Row style = { { marginTop : "20px" } } >
175283 < Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
176284 { i18next . t ( "general:Provider URL" ) } :
0 commit comments