Remove temperature & token usage in chatgpt api setting

This commit is contained in:
wong2
2023-06-06 19:50:41 +08:00
parent 771378dcc2
commit 21fc6efc80
2 changed files with 2 additions and 32 deletions

View File

@@ -83,7 +83,7 @@ export class ChatGPTApiBot extends AbstractChatGPTApiBot {
}
async fetchCompletionApi(signal?: AbortSignal) {
const { openaiApiKey, openaiApiHost, chatgptApiModel, chatgptApiTemperature } = this.config
const { openaiApiKey, openaiApiHost, chatgptApiModel } = this.config
const resp = await fetch(`${openaiApiHost}/v1/chat/completions`, {
method: 'POST',
signal,
@@ -94,7 +94,6 @@ export class ChatGPTApiBot extends AbstractChatGPTApiBot {
body: JSON.stringify({
model: chatgptApiModel,
messages: this.buildMessages(),
temperature: chatgptApiTemperature,
stream: true,
}),
})

View File

@@ -1,8 +1,6 @@
import { FC, useEffect, useState } from 'react'
import { FC } from 'react'
import { CHATGPT_API_MODELS } from '~app/consts'
import { getTokenUsage } from '~services/storage'
import { UserConfig } from '~services/user-config'
import { formatAmount, formatDecimal } from '~utils/format'
import { Input } from '../Input'
import Select from '../Select'
@@ -12,12 +10,6 @@ interface Props {
}
const ChatGPTAPISettings: FC<Props> = ({ userConfig, updateConfigValue }) => {
const [tokenUsed, setTokenUsed] = useState(0)
useEffect(() => {
getTokenUsage().then((used) => setTokenUsed(used))
})
return (
<div className="flex flex-col gap-2">
<div className="flex flex-col gap-1">
@@ -47,27 +39,6 @@ const ChatGPTAPISettings: FC<Props> = ({ userConfig, updateConfigValue }) => {
onChange={(v) => updateConfigValue({ chatgptApiModel: v })}
/>
</div>
<div className="flex flex-col gap-1 w-[300px]">
<p className="font-medium text-sm">Conversation Style (temperature: {userConfig.chatgptApiTemperature})</p>
<input
type="range"
min={0}
max={2}
step={0.2}
value={userConfig.chatgptApiTemperature}
onChange={(e) => updateConfigValue({ chatgptApiTemperature: Number(e.currentTarget.value) })}
/>
<div className="flex flex-row justify-between text-xs">
<span>Precise</span>
<span>Balanced</span>
<span>Creative</span>
</div>
</div>
{tokenUsed > 0 && (
<p className="text-sm mt-2 italic">
Usage: {formatDecimal(tokenUsed)} tokens (~{formatAmount((tokenUsed / 1000) * 0.002)})
</p>
)}
</div>
)
}