Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
chore: update best model of chatgpt
Browse files Browse the repository at this point in the history
  • Loading branch information
clement2026 committed Feb 3, 2024
1 parent e90fa18 commit 8d67817
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
13 changes: 6 additions & 7 deletions src/home/chat-window/text-area.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import {appState, Chat} from "../../state/app-state.ts"
import {controlState, SendMessageOption} from "../../state/control-state.ts"
import {cx} from "../../util/util.tsx"
import {searchLinuxTerminalHistoryPotision} from "../../data-structure/message.tsx";
import {matchKeyComobo} from "../../state/shortcuts.ts";
import {bestModel, matchKeyCombo} from "../../state/shortcuts.ts";
import IosSpinner from "../../assets/svg/ios-spinner.svg?react"

type Props = {
chatProxy: Chat
}

const bestModel = "gpt-4-1106-preview"

const largeTextAreaMinHeight = "min-h-96"
const smallTextAreaMinHeight = "min-h-24"
Expand Down Expand Up @@ -108,7 +107,7 @@ const TextArea: React.FC<Props> = ({chatProxy}) => {
}
} else {
const sc = appState.pref.shortcuts
if (matchKeyComobo(sc.newLine, event)) {
if (matchKeyCombo(sc.newLine, event)) {
if (event.key === 'Enter' && !event.ctrlKey && !event.metaKey && !event.altKey) {
// try our best to use native 'new-line', in order to preserve edit stack(ctrl/cmd + z)
} else {
Expand All @@ -121,16 +120,16 @@ const TextArea: React.FC<Props> = ({chatProxy}) => {
target.value.slice(caretPosition);
setTimeout(() => target.selectionStart = target.selectionEnd = caretPosition + 1)
}
} else if (matchKeyComobo(sc.send, event)) {
} else if (matchKeyCombo(sc.send, event)) {
sendAndClearText()
event.preventDefault()
} else if (matchKeyComobo(sc.sendWithBestModel, event)) {
} else if (matchKeyCombo(sc.sendWithBestModel, event)) {
sendAndClearText({model: bestModel})
event.preventDefault()
} else if (matchKeyComobo(sc.sendZeroAttachedMessage, event)) {
} else if (matchKeyCombo(sc.sendZeroAttachedMessage, event)) {
sendAndClearText({ignoreAttachedMessage: true})
event.preventDefault()
} else if (matchKeyComobo(sc.sendWithBestModelAndZeroAttachedMessage, event)) {
} else if (matchKeyCombo(sc.sendWithBestModelAndZeroAttachedMessage, event)) {
sendAndClearText({
ignoreAttachedMessage: true,
model: bestModel
Expand Down
8 changes: 5 additions & 3 deletions src/state/shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,21 @@ export const defaultShortcuts = (): Shortcuts => ({
mKeys: ["Control"]
},
sendWithBestModel: {
name: "Send with gpt-4-1106-preview model",
name: `Send with ${bestModel} model`,
key: "Enter",
mKeys: ["Meta"]
},
sendWithBestModelAndZeroAttachedMessage: {
name: "Send with gpt-4-1106-preview model and 0 attached message",
name: `Send with ${bestModel} model and 0 attached message`,
key: "Enter",
mKeys: ["Meta", "Control"]
}
})

export const bestModel = "gpt-4-turbo-preview"

const mods: ModifierKey[] = ["Meta", "Control", "Alt", "Shift"]
export const matchKeyComobo = (keyCombo: KeyCombo, e: React.KeyboardEvent<HTMLTextAreaElement>): boolean => {
export const matchKeyCombo = (keyCombo: KeyCombo, e: React.KeyboardEvent<HTMLTextAreaElement>): boolean => {
if (e.key !== keyCombo.key) {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2320,7 +2320,7 @@ postcss-value-parser@^4.0.0, postcss-value-parser@^4.2.0:

[email protected]:
version "8.4.32"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.32.tgz#1dac6ac51ab19adb21b8b34fd2d93a86440ef6c9"
resolved "https://registry.npmmirror.com/postcss/-/postcss-8.4.32.tgz#1dac6ac51ab19adb21b8b34fd2d93a86440ef6c9"
integrity sha512-D/kj5JNu6oo2EIy+XL/26JEDTlIbB8hw85G8StOE6L74RQAVVP5rej6wxCNqyMbR4RkPfqvezVbPw81Ngd6Kcw==
dependencies:
nanoid "^3.3.7"
Expand Down

0 comments on commit 8d67817

Please sign in to comment.