Skip to content

Commit

Permalink
refactor: hyperchat v2
Browse files Browse the repository at this point in the history
  • Loading branch information
YanceyOfficial committed Oct 18, 2024
1 parent 3a126cd commit a3c6124
Show file tree
Hide file tree
Showing 10 changed files with 235 additions and 254 deletions.
441 changes: 218 additions & 223 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hyperchat"
version = "1.0.5"
version = "2.0.0"
description = "ChatGPT AI Bot."
authors = ["Yancey Leo"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"productName": "Hyper Chat",
"mainBinaryName": "Hyper Chat",
"version": "1.0.5",
"version": "2.0.0",
"identifier": "app.yancey.hyperchat",
"plugins": {
"updater": {
Expand Down
14 changes: 1 addition & 13 deletions src/containers/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,18 +196,6 @@ const Settings: FC = () => {
placeholder="Eg: davinci-002"
/>

<TextField
id="azure-deployment-name-speech-recognition-input"
label="Speech Recognition Deployment Name"
size="small"
type="text"
className="w-80"
{...formik.getFieldProps(
'azureDeploymentNameSpeechRecognition'
)}
placeholder="Eg: whisper"
/>

<TextField
id="azure-deployment-name-text-to-image-input"
label="Text to Image Deployment Name"
Expand Down Expand Up @@ -239,7 +227,7 @@ const Settings: FC = () => {
{...formik.getFieldProps(
'azureDeploymentNameAudioGeneration'
)}
placeholder="Eg: gpt-4o-realtime-preview"
placeholder="Eg: whisper-1"
/>

<Divider />
Expand Down
2 changes: 1 addition & 1 deletion src/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class HyperChatDB extends Dexie {
conversations:
'&conversationId, summary, fileName, product, createdAt, updatedAt, *messages, *configuration',
settings:
'&&settingsId, company, openaiSecretKey, openaiOrganizationId, openaiAuthorName, azureEndPoint, azureSecretKey, azureDeploymentNameChatCompletion, azureDeploymentNameCompletion, azureDeploymentNameSpeechRecognition, azureDeploymentNameTextToImage, azureDeploymentNameEmbedding, azureDeploymentNameAudioGeneration, azureSpeechSecretKey, azureSpeechRegion, themeMode, assistantAvatarFilename'
'&&settingsId, company, openaiSecretKey, openaiOrganizationId, openaiAuthorName, azureEndPoint, azureSecretKey, azureDeploymentNameChatCompletion, azureDeploymentNameCompletion, azureDeploymentNameTextToImage, azureDeploymentNameEmbedding, azureDeploymentNameAudioGeneration, azureSpeechSecretKey, azureSpeechRegion, themeMode, assistantAvatarFilename'
})
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/hooks/useAudio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const useAudio = () => {
setLoading(true)

const transcription = await openAiClient.audio.transcriptions.create({
file: binary,
file: binary as File,
model,
prompt: rest.text,
response_format: responseFormat as AudioResponseFormat,
Expand Down Expand Up @@ -67,7 +67,7 @@ const useAudio = () => {
setLoading(true)

const translation = await openAiClient.audio.translations.create({
file: binary,
file: binary as File,
model,
prompt: rest.text,
response_format: responseFormat as AudioResponseFormat,
Expand Down Expand Up @@ -99,13 +99,13 @@ const useAudio = () => {
saveUserMessage([rest])
setLoading(true)

const buffer = await binary.arrayBuffer()
const buffer = await (binary as File).arrayBuffer()
const uint8Array = new Uint8Array(buffer)
const transcription = await azureClient.getAudioTranscription(
settings.azureDeploymentNameSpeechRecognition,
settings.azureDeploymentNameAudioGeneration,
uint8Array,
{
prompt,
prompt: rest.text,
temperature,
language: language === '' ? undefined : language
}
Expand Down Expand Up @@ -136,13 +136,13 @@ const useAudio = () => {
saveUserMessage([rest])
setLoading(true)

const buffer = await binary.arrayBuffer()
const buffer = await (binary as File).arrayBuffer()
const uint8Array = new Uint8Array(buffer)
const translation = await azureClient.getAudioTranslation(
settings.azureDeploymentNameSpeechRecognition,
settings.azureDeploymentNameAudioGeneration,
uint8Array,
{
prompt,
prompt: rest.text,
temperature
}
)
Expand Down
7 changes: 4 additions & 3 deletions src/hooks/useSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const useSettings = () => {
const { updateOneById, insertOne, toArray } = useDB('settings')

const initialSettings = async () => {
const defaultData = {
const defaultData: Settings = {
settingsId: v4(),
company: Companies.OpenAI,
openaiSecretKey: '',
Expand All @@ -25,12 +25,13 @@ const useSettings = () => {
azureEndPoint: '',
azureDeploymentNameChatCompletion: '',
azureDeploymentNameCompletion: '',
azureDeploymentNameSpeechRecognition: '',
azureDeploymentNameTextToImage: '',
azureDeploymentNameEmbedding: '',
azureDeploymentNameAudioGeneration: '',
themeMode: ThemeMode.system,
assistantAvatarFilename: ''
assistantAvatarFilename: '',
azureSpeechSecretKey: '',
azureSpeechRegion: ''
}

await insertOne(defaultData)
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/useStoreMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ const useStoreMessages = () => {
async (
content: (ChatCompletionContentPart | AudioContentPart)[],
tokensCount?: number,
fileName?: string
) => {
if (!currConversation) return

Expand All @@ -139,7 +138,6 @@ const useStoreMessages = () => {
role: Roles.User,
content,
tokensCount: tokensCount || 0,
fileName,
createdAt: +new Date()
}

Expand Down
1 change: 0 additions & 1 deletion src/types/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export interface Settings {
azureEndPoint: string
azureDeploymentNameChatCompletion: string
azureDeploymentNameCompletion: string
azureDeploymentNameSpeechRecognition: string
azureDeploymentNameTextToImage: string
azureDeploymentNameEmbedding: string
azureDeploymentNameAudioGeneration: string
Expand Down

0 comments on commit a3c6124

Please sign in to comment.