Fix: window hide & show, toast error for llm (#249)
* fix window hide & show * toast error when llm failed
This commit is contained in:
@@ -132,10 +132,10 @@ main.init = () => {
|
||||
mainWindow.setBrowserView(view);
|
||||
|
||||
view.setBounds({
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
x: Math.round(x),
|
||||
y: Math.round(y),
|
||||
width: Math.round(width),
|
||||
height: Math.round(height),
|
||||
});
|
||||
view.setAutoResize({
|
||||
width: true,
|
||||
@@ -227,8 +227,8 @@ main.init = () => {
|
||||
logger.debug("current view bounds", bounds);
|
||||
|
||||
view.setBounds({
|
||||
x: -bounds.width,
|
||||
y: -bounds.height,
|
||||
x: -Math.round(bounds.width),
|
||||
y: -Math.round(bounds.height),
|
||||
width: 0,
|
||||
height: 0,
|
||||
});
|
||||
@@ -247,9 +247,16 @@ main.init = () => {
|
||||
) => {
|
||||
const view = mainWindow.getBrowserView();
|
||||
if (!view) return;
|
||||
if (!bounds) return;
|
||||
|
||||
logger.debug("view-show", bounds);
|
||||
view.setBounds(bounds);
|
||||
const { x = 0, y = 0, width = 0, height = 0 } = bounds || {};
|
||||
view.setBounds({
|
||||
x: Math.round(x),
|
||||
y: Math.round(y),
|
||||
width: Math.round(width),
|
||||
height: Math.round(height),
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
SheetContent,
|
||||
SheetHeader,
|
||||
SheetClose,
|
||||
toast,
|
||||
} from "@renderer/components/ui";
|
||||
import {
|
||||
SpeechPlayer,
|
||||
@@ -70,6 +71,9 @@ export const AssistantMessageComponent = (props: {
|
||||
.then((speech) => {
|
||||
setSpeech(speech);
|
||||
})
|
||||
.catch((err) => {
|
||||
toast.error(err.message);
|
||||
})
|
||||
.finally(() => {
|
||||
setSpeeching(false);
|
||||
});
|
||||
|
||||
@@ -47,7 +47,7 @@ export const useConversation = () => {
|
||||
return new ChatOpenAI({
|
||||
openAIApiKey: openai.key,
|
||||
configuration: {
|
||||
baseURL: baseUrl,
|
||||
baseURL: baseUrl || openai.baseUrl,
|
||||
},
|
||||
modelName: model,
|
||||
temperature,
|
||||
@@ -162,7 +162,7 @@ export const useConversation = () => {
|
||||
engine = currentEngine.name,
|
||||
model = "tts-1",
|
||||
voice = "alloy",
|
||||
baseUrl = currentEngine.baseUrl,
|
||||
baseUrl,
|
||||
} = configuration || {};
|
||||
|
||||
let client: OpenAI;
|
||||
@@ -176,7 +176,7 @@ export const useConversation = () => {
|
||||
} else {
|
||||
client = new OpenAI({
|
||||
apiKey: openai.key,
|
||||
baseURL: baseUrl,
|
||||
baseURL: baseUrl || openai.baseUrl,
|
||||
dangerouslyAllowBrowser: true,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -121,9 +121,10 @@ export default () => {
|
||||
}, 1000 * 60 * 5);
|
||||
|
||||
chat(message, { conversation })
|
||||
.catch(() => {
|
||||
.catch((err) => {
|
||||
message.status = "error";
|
||||
dispatchMessages({ type: "update", record: message });
|
||||
toast.error(err.message);
|
||||
})
|
||||
.finally(() => {
|
||||
setSubmitting(false);
|
||||
|
||||
Reference in New Issue
Block a user