重构部分代码
This commit is contained in:
parent
0df00ba33e
commit
03e1e5662d
4
lingtropy-client/package-lock.json
generated
4
lingtropy-client/package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "lingtropy",
|
"name": "lingtropy",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "lingtropy",
|
"name": "lingtropy",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mdi/font": "^7.4.47",
|
"@mdi/font": "^7.4.47",
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "lingtropy",
|
"name": "lingtropy",
|
||||||
"appId": "com.lingnite.lingtropy",
|
"appId": "com.lingnite.lingtropy",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"description": "文案助手",
|
"description": "文案助手",
|
||||||
"homepage": "https://www.lingnite.com",
|
"homepage": "https://www.lingnite.com",
|
||||||
"author": "沈阳泠启网络科技有限公司",
|
"author": "沈阳泠启网络科技有限公司",
|
||||||
|
|||||||
42
lingtropy-client/src/constants/index.ts
Normal file
42
lingtropy-client/src/constants/index.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// API 相关
|
||||||
|
export const API_ENDPOINTS = {
|
||||||
|
GET_BASE_URL: 'https://aqq-jbjsjuxivc.cn-hangzhou.fcapp.run',
|
||||||
|
FETCH_MODELS: 'https://get-model-list-vcwjgnvcld.cn-hangzhou.fcapp.run'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
// AI 模型相关
|
||||||
|
export const AI_CONFIG = {
|
||||||
|
DEFAULT_MODEL: 'gpt-4o',
|
||||||
|
CONTENT_MAX_TOKENS: 1800, // 约900字
|
||||||
|
TITLE_MAX_TOKENS: 50, // 约20字
|
||||||
|
TEMPERATURE: 0.8,
|
||||||
|
MAX_RETRIES: 2,
|
||||||
|
TIMEOUT: 30000
|
||||||
|
} as const
|
||||||
|
|
||||||
|
// 提示词模板
|
||||||
|
export const PROMPTS = {
|
||||||
|
CONTENT_REWRITE: '你是一个小红书文案写手,能够熟练地根据用户的输入,改写成内容相近,但表达方式不同的新文案。你的文案中需要具备吸人眼球的钩子,能够牢牢抓住用户的注意力。请直接输出新的文案,不要输出其他任何提示性词语, 以纯文本的形式输出。注意:输出的文案不要超过900字。',
|
||||||
|
TITLE_REWRITE: '你是一个小红书标题写手,能够熟练地根据用户的输入,改写成内容相近,但表达方式不同的新标题。你的标题中需要具备吸人眼球的钩子,能够牢牢抓住用户的注意力。请直接输出新的标题,不要输出其他任何提示性词语, 以纯文本的形式输出。注意:输出的标题不要超过20字。'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
// 存储键名
|
||||||
|
export const STORE_KEYS = {
|
||||||
|
API_KEY: 'api-key',
|
||||||
|
LAYOUT_MODE: 'layoutMode',
|
||||||
|
GENERATION_COUNT: 'generationCount'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
// UI 相关
|
||||||
|
export const UI_CONFIG = {
|
||||||
|
DEFAULT_LAYOUT: 'list',
|
||||||
|
DEFAULT_COUNT: 3,
|
||||||
|
MAX_COUNT: 10,
|
||||||
|
MIN_COUNT: 1
|
||||||
|
} as const
|
||||||
|
|
||||||
|
// 应用信息
|
||||||
|
// export const APP_INFO = {
|
||||||
|
// VERSION: '1.0.0',
|
||||||
|
// NAME: 'LingTropy'
|
||||||
|
// } as const
|
||||||
@ -3,6 +3,13 @@ import Constants from './utils/Constants'
|
|||||||
import Store from 'electron-store'
|
import Store from 'electron-store'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import OpenAI from 'openai'
|
import OpenAI from 'openai'
|
||||||
|
import {
|
||||||
|
API_ENDPOINTS,
|
||||||
|
AI_CONFIG,
|
||||||
|
PROMPTS,
|
||||||
|
STORE_KEYS,
|
||||||
|
APP_INFO
|
||||||
|
} from '../constants'
|
||||||
|
|
||||||
const store = new Store()
|
const store = new Store()
|
||||||
/*
|
/*
|
||||||
@ -38,7 +45,7 @@ export default class IPCs {
|
|||||||
|
|
||||||
ipcMain.handle('fetch-models', async () => {
|
ipcMain.handle('fetch-models', async () => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get('https://get-model-list-vcwjgnvcld.cn-hangzhou.fcapp.run') // 从网络获取数据
|
const response = await axios.get(API_ENDPOINTS.FETCH_MODELS)
|
||||||
console.log('获取模型数据成功:', response.data)
|
console.log('获取模型数据成功:', response.data)
|
||||||
return response.data.data
|
return response.data.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -49,7 +56,7 @@ export default class IPCs {
|
|||||||
|
|
||||||
ipcMain.handle('getBaseUrl', async () => {
|
ipcMain.handle('getBaseUrl', async () => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get('https://aqq-jbjsjuxivc.cn-hangzhou.fcapp.run')
|
const response = await axios.get(API_ENDPOINTS.GET_BASE_URL)
|
||||||
console.log('获取baseUrl成功:', response.data)
|
console.log('获取baseUrl成功:', response.data)
|
||||||
return response.data.data
|
return response.data.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -82,12 +89,12 @@ export default class IPCs {
|
|||||||
messages: [
|
messages: [
|
||||||
{
|
{
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content:
|
content: PROMPTS.CONTENT_REWRITE
|
||||||
'你是一个小红书文案写手,能够熟练地根据用户的输入,改写成内容相近,但表达方式不同的新文案。你的文案中需要具备吸人眼球的钩子,能够牢牢抓住用户的注意力。请直接输出新的文案,不要输出其他任何提示性词语, 以纯文本的形式输出。注意:输出的文案不要超过900字。'
|
|
||||||
},
|
},
|
||||||
{ role: 'user', content: rawArticle }
|
{ role: 'user', content: rawArticle }
|
||||||
],
|
],
|
||||||
max_tokens: 1800, // 约900字
|
max_tokens: AI_CONFIG.CONTENT_MAX_TOKENS,
|
||||||
|
temperature: AI_CONFIG.TEMPERATURE,
|
||||||
stream: true
|
stream: true
|
||||||
})
|
})
|
||||||
.then(async (stream) => {
|
.then(async (stream) => {
|
||||||
|
|||||||
@ -3339,7 +3339,7 @@ lie@~3.3.0:
|
|||||||
immediate "~3.0.5"
|
immediate "~3.0.5"
|
||||||
|
|
||||||
"lingtropy@file:":
|
"lingtropy@file:":
|
||||||
version "1.0.1"
|
version "1.0.2"
|
||||||
resolved "file:"
|
resolved "file:"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@mdi/font" "^7.4.47"
|
"@mdi/font" "^7.4.47"
|
||||||
@ -3354,7 +3354,7 @@ lie@~3.3.0:
|
|||||||
vuetify "^3.7.14"
|
vuetify "^3.7.14"
|
||||||
|
|
||||||
"lingtropy2@file:":
|
"lingtropy2@file:":
|
||||||
version "1.0.1"
|
version "1.0.2"
|
||||||
resolved "file:"
|
resolved "file:"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@mdi/font" "^7.4.47"
|
"@mdi/font" "^7.4.47"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user