Skip to content

Commit

Permalink
feat: Modify the shortcut key for sending records as command+enter
Browse files Browse the repository at this point in the history
  • Loading branch information
Leizhenpeng committed Aug 11, 2023
1 parent 158cb19 commit 231b985
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pages/App/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ export default function Chat() {
e.preventDefault();
setInput(tableAdvice);
}
// enter 就发送
if (e.key === 'Enter') {
// 同事按按住command+enter 就发送
if (e.key === 'Enter' && e.metaKey) {
e.preventDefault();
handleSubmit();
}
Expand Down
3 changes: 1 addition & 2 deletions pages/api/advice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ const getTableAdvice = async (tsString: string, lang :string) => {
content: ifZh ? 'According to the following type file structure, after judging the function of this form, assuming the appropriate situation, use human natural language to give an example input, be natural and no more than 20 words. 记住,用中文回答 ' : 'According to the following type file structure, after judging the function of this form, assuming the appropriate situation, use human natural language to give an example input, be natural and no more than 20 words.Must Answer in English',
},
{ role: 'user', content: ifZh ? generateZhTemplate(tsString) : generateTemplate(tsString) }] as any;
console.log(messages);
const chatCompletion = await openai.createChatCompletion({
model: 'gpt-3.5-turbo',
stream: false,
Expand All @@ -83,7 +82,7 @@ const getTableAdvice = async (tsString: string, lang :string) => {
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const { tsString,lang } = JSON.parse(req.body) as Prop;
const result = await getTableAdvice(tsString,lang as string);
console.log(result);
// console.log(result);
res.status(200).send({ result });
};

Expand Down
3 changes: 1 addition & 2 deletions pages/api/describe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const getTableDescription = async (tsString: string,lang='en') => {
model: "gpt-3.5-turbo",
messages: [
{role:"system", content: "According to the following table structure, judge the target of table, describe in natural language,only say the conclusion, no more than 30 words."+(ifZh?" 记住用中文来描述":"Describe in English")},

{role: "user", content: tsString,}],
}) as any;
return chatCompletion.data.choices[0].message.content;
Expand All @@ -31,7 +30,7 @@ const getTableDescription = async (tsString: string,lang='en') => {
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const { tsString,lang } = JSON.parse(req.body) as Prop;
const result = await getTableDescription(tsString,lang);
console.log(result);
// console.log(result);
res.status(200).send({ result });
}

Expand Down

0 comments on commit 231b985

Please sign in to comment.