update
This commit is contained in:
24
cmd/main.go
24
cmd/main.go
@@ -103,8 +103,14 @@ func main() {
|
||||
|
||||
fmt.Println("\n========== LLM生成的JSON ==========")
|
||||
// 解析LLM返回的响应,提取```json{内容}```中的JSON部分
|
||||
if response == nil {
|
||||
println("LLM生成的JSON失败")
|
||||
return
|
||||
}
|
||||
|
||||
parsedJSON := extractJSONFromResponse(response.Choices[0].Message.Content)
|
||||
fmt.Println(parsedJSON)
|
||||
|
||||
fmt.Println("==================================")
|
||||
|
||||
// 使用解析出的JSON调用税务健康API
|
||||
@@ -122,12 +128,20 @@ func main() {
|
||||
}
|
||||
// 构建税务评估请求
|
||||
request := api.TaxEvalRequest{
|
||||
ReqNo: fmt.Sprintf("REQ%v", time.Now().Unix()), // 使用时间戳生成请求号
|
||||
ReqNo: fmt.Sprintf("%v", time.Now().Unix()), // 使用时间戳生成请求号
|
||||
Detail: api.TaxEvalDetail{
|
||||
CompanyName: "郑州惠兴", // 可以从数据中提取公司名称
|
||||
Data: companyData,
|
||||
Period: "Q1",
|
||||
Year: "2022",
|
||||
CompanyName: "郑州惠兴", // 可以从数据中提取公司名称
|
||||
Data: companyData,
|
||||
Period: "Q1",
|
||||
Year: "2022",
|
||||
CIT: 100.0,
|
||||
InputVAT: 30.0,
|
||||
OutputVAT: 80.0,
|
||||
PreCIT: 90.0,
|
||||
PreVAT: 45.0,
|
||||
PreInputVAT: 25.0,
|
||||
PreOutputVAT: 70.0,
|
||||
VAT: 50.0,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
181
cmd/wasm/main.go
181
cmd/wasm/main.go
@@ -10,6 +10,12 @@ import (
|
||||
"wasm-go/internal/prompt"
|
||||
)
|
||||
|
||||
func createErrorJSValue(msg string) js.Value {
|
||||
errorObj := map[string]string{"error": msg}
|
||||
jsonBytes, _ := json.Marshal(errorObj)
|
||||
return js.Global().Get("JSON").Call("parse", string(jsonBytes))
|
||||
}
|
||||
|
||||
var DefaultLLMConfig = LLMConfig{
|
||||
Provider: "openai",
|
||||
BaseURL: "https://api.deepseek.com",
|
||||
@@ -25,7 +31,7 @@ func main() {
|
||||
js.Global().Set("callLLMAsync", js.FuncOf(callLLMAsync))
|
||||
js.Global().Set("callTaxHealthAsync", js.FuncOf(callTaxHealthAsync))
|
||||
js.Global().Set("queryTaxResultAsync", js.FuncOf(queryTaxResultAsync))
|
||||
|
||||
js.Global().Set("getPrompt", js.FuncOf(getPrompt))
|
||||
// 保持程序运行
|
||||
select {} // 无限循环,保持程序运行
|
||||
}
|
||||
@@ -83,9 +89,7 @@ func analyzeCompanyIndustryAsync(this js.Value, args []js.Value) interface{} {
|
||||
jsonResult, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
// 序列化失败,返回错误
|
||||
reject.Invoke(js.ValueOf(map[string]string{
|
||||
"error": "JSON序列化失败: " + err.Error(),
|
||||
}))
|
||||
reject.Invoke(createErrorJSValue("JSON序列化失败: " + err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -94,9 +98,7 @@ func analyzeCompanyIndustryAsync(this js.Value, args []js.Value) interface{} {
|
||||
resolve.Invoke(jsResult)
|
||||
case err := <-errorChan:
|
||||
// 将错误转换为JavaScript值
|
||||
reject.Invoke(js.ValueOf(map[string]string{
|
||||
"error": err.Error(),
|
||||
}))
|
||||
reject.Invoke(createErrorJSValue(err.Error()))
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -141,23 +143,24 @@ func parseExcelAsync(this js.Value, args []js.Value) interface{} {
|
||||
return
|
||||
}
|
||||
|
||||
// 创建一个map来存储所有工作表的数据
|
||||
sheets := make(map[string][][]string)
|
||||
sheetErrors := make(map[string]string)
|
||||
|
||||
// 读取每个工作表的数据
|
||||
for _, sheetName := range sheetNames {
|
||||
sheetData, err := reader.GetSheetData(sheetName)
|
||||
if err != nil {
|
||||
// 记录错误但继续处理其他工作表
|
||||
sheetErrors[sheetName] = err.Error()
|
||||
continue
|
||||
}
|
||||
sheets[sheetName] = sheetData
|
||||
}
|
||||
|
||||
// 将结果转换为适当的格式
|
||||
result := map[string]interface{}{
|
||||
"sheets": sheets,
|
||||
}
|
||||
if len(sheetErrors) > 0 {
|
||||
result["errors"] = sheetErrors
|
||||
}
|
||||
|
||||
resultChan <- result
|
||||
}()
|
||||
@@ -176,24 +179,16 @@ func parseExcelAsync(this js.Value, args []js.Value) interface{} {
|
||||
go func() {
|
||||
select {
|
||||
case result := <-resultChan:
|
||||
// 将复杂结构体序列化为JSON
|
||||
jsonResult, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
// 序列化失败,返回错误
|
||||
reject.Invoke(js.ValueOf(map[string]string{
|
||||
"error": "JSON序列化失败: " + err.Error(),
|
||||
}))
|
||||
reject.Invoke(createErrorJSValue("JSON序列化失败: " + err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
// 将JSON字符串解析为JavaScript对象
|
||||
jsResult := js.Global().Get("JSON").Call("parse", string(jsonResult))
|
||||
resolve.Invoke(jsResult)
|
||||
case err := <-errorChan:
|
||||
// 将错误转换为JavaScript值
|
||||
reject.Invoke(js.ValueOf(map[string]string{
|
||||
"error": err.Error(),
|
||||
}))
|
||||
reject.Invoke(createErrorJSValue(err.Error()))
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -203,6 +198,83 @@ func parseExcelAsync(this js.Value, args []js.Value) interface{} {
|
||||
return promise
|
||||
}
|
||||
|
||||
// getPrompt 获取提示词
|
||||
func getPrompt(this js.Value, args []js.Value) interface{} {
|
||||
period := args[0].String()
|
||||
// 根据period映射相应的prompt
|
||||
var pmt string
|
||||
switch period {
|
||||
case "Q1", "第一季度":
|
||||
pmt = prompt.Quarterly2Prompt
|
||||
case "Q2", "第二季度":
|
||||
pmt = prompt.Quarterly2Prompt
|
||||
case "Q3", "第三季度":
|
||||
pmt = prompt.Quarterly3Prompt
|
||||
case "年度":
|
||||
pmt = prompt.AnnualPrompt
|
||||
default:
|
||||
pmt = `你是一个专业的财务数据分析师。请分析以下财务报表数据,并将其转换为适合税务健康评估的JSON格式。只需要返回JSON数据,不要包含其他解释文字。返回格式应该是一个包含财务指标及其数值的对象,例如:{"LC0000003E_T0I0331": 741213833.14, "LC0000003E_T0I0101": 578064138.06}`
|
||||
}
|
||||
// 创建一个通道来处理结果
|
||||
resultChan := make(chan interface{}, 1)
|
||||
errorChan := make(chan error, 1)
|
||||
|
||||
go func() {
|
||||
allows := []string{"Q1", "第一季度", "Q2", "第二季度", "Q3", "第三季度", "年度"}
|
||||
isValid := false
|
||||
for _, allowed := range allows {
|
||||
if allowed == period {
|
||||
isValid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if isValid {
|
||||
result := map[string]interface{}{
|
||||
"prompt": pmt,
|
||||
"period": period,
|
||||
}
|
||||
resultChan <- result
|
||||
} else {
|
||||
errorChan <- fmt.Errorf("所选周期错误,支持的周期: Q1, 第一季度, Q2, 第二季度, Q3, 第三季度, 年度")
|
||||
return
|
||||
}
|
||||
|
||||
}()
|
||||
|
||||
// 创建Promise
|
||||
promise := js.Global().Get("Promise").New(js.FuncOf(func(this js.Value, promiseArgs []js.Value) interface{} {
|
||||
if len(promiseArgs) < 2 {
|
||||
// 如果参数不足,返回一个立即拒绝的Promise
|
||||
return nil
|
||||
}
|
||||
|
||||
resolve := promiseArgs[0]
|
||||
reject := promiseArgs[1]
|
||||
|
||||
// 启动一个goroutine来处理结果
|
||||
go func() {
|
||||
select {
|
||||
case result := <-resultChan:
|
||||
jsonResult, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
reject.Invoke(createErrorJSValue("JSON序列化失败: " + err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
jsResult := js.Global().Get("JSON").Call("parse", string(jsonResult))
|
||||
resolve.Invoke(jsResult)
|
||||
case err := <-errorChan:
|
||||
reject.Invoke(createErrorJSValue(err.Error()))
|
||||
}
|
||||
}()
|
||||
|
||||
return nil
|
||||
}))
|
||||
|
||||
return promise
|
||||
|
||||
}
|
||||
|
||||
// convertExcelToJsonViaLLM 将Excel数据通过LLM转换为JSON格式的函数
|
||||
func convertExcelToJsonViaLLM(this js.Value, args []js.Value) interface{} {
|
||||
// 获取Excel文件的ArrayBuffer和参数
|
||||
@@ -214,7 +286,7 @@ func convertExcelToJsonViaLLM(this js.Value, args []js.Value) interface{} {
|
||||
var pmt string
|
||||
switch period {
|
||||
case "Q1", "第一季度":
|
||||
pmt = prompt.Quarterly2Prompt
|
||||
pmt = prompt.Quarterly1Prompt
|
||||
case "Q2", "第二季度":
|
||||
pmt = prompt.Quarterly2Prompt
|
||||
case "Q3", "第三季度":
|
||||
@@ -255,20 +327,23 @@ func convertExcelToJsonViaLLM(this js.Value, args []js.Value) interface{} {
|
||||
return
|
||||
}
|
||||
|
||||
// 创建一个map来存储所有工作表的数据
|
||||
sheets := make(map[string][][]string)
|
||||
sheetErrors := make(map[string]string)
|
||||
|
||||
// 读取每个工作表的数据
|
||||
for _, sheetName := range sheetNames {
|
||||
sheetData, err := reader.GetSheetData(sheetName)
|
||||
if err != nil {
|
||||
// 记录错误但继续处理其他工作表
|
||||
sheetErrors[sheetName] = err.Error()
|
||||
continue
|
||||
}
|
||||
sheets[sheetName] = sheetData
|
||||
}
|
||||
|
||||
// 将Excel数据转换为markdown格式,便于LLM理解
|
||||
if len(sheetErrors) > 0 {
|
||||
errorChan <- fmt.Errorf("部分工作表读取失败: %v", sheetErrors)
|
||||
return
|
||||
}
|
||||
|
||||
var allMarkdownTables strings.Builder
|
||||
allMarkdownTables.WriteString("以下是Excel表格的数据:\n\n")
|
||||
|
||||
@@ -343,24 +418,16 @@ func convertExcelToJsonViaLLM(this js.Value, args []js.Value) interface{} {
|
||||
go func() {
|
||||
select {
|
||||
case result := <-resultChan:
|
||||
// 将复杂结构体序列化为JSON
|
||||
jsonResult, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
// 序列化失败,返回错误
|
||||
reject.Invoke(js.ValueOf(map[string]string{
|
||||
"error": "JSON序列化失败: " + err.Error(),
|
||||
}))
|
||||
reject.Invoke(createErrorJSValue("JSON序列化失败: " + err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
// 将JSON字符串解析为JavaScript对象
|
||||
jsResult := js.Global().Get("JSON").Call("parse", string(jsonResult))
|
||||
resolve.Invoke(jsResult)
|
||||
case err := <-errorChan:
|
||||
// 将错误转换为JavaScript值
|
||||
reject.Invoke(js.ValueOf(map[string]string{
|
||||
"error": err.Error(),
|
||||
}))
|
||||
reject.Invoke(createErrorJSValue(err.Error()))
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -497,24 +564,16 @@ func callLLMAsync(this js.Value, args []js.Value) interface{} {
|
||||
go func() {
|
||||
select {
|
||||
case result := <-resultChan:
|
||||
// 将复杂结构体序列化为JSON
|
||||
jsonResult, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
// 序列化失败,返回错误
|
||||
reject.Invoke(js.ValueOf(map[string]string{
|
||||
"error": "JSON序列化失败: " + err.Error(),
|
||||
}))
|
||||
reject.Invoke(createErrorJSValue("JSON序列化失败: " + err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
// 将JSON字符串解析为JavaScript对象
|
||||
jsResult := js.Global().Get("JSON").Call("parse", string(jsonResult))
|
||||
resolve.Invoke(jsResult)
|
||||
case err := <-errorChan:
|
||||
// 将错误转换为JavaScript值
|
||||
reject.Invoke(js.ValueOf(map[string]string{
|
||||
"error": err.Error(),
|
||||
}))
|
||||
reject.Invoke(createErrorJSValue(err.Error()))
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -550,7 +609,6 @@ func callTaxHealthAsync(this js.Value, args []js.Value) interface{} {
|
||||
companyName, _ := requestData["company_name"].(string)
|
||||
period, _ := requestData["period"].(string)
|
||||
year, _ := requestData["year"].(string)
|
||||
isVerify, _ := requestData["is_verify"].(bool)
|
||||
cit, _ := requestData["cit"].(float64)
|
||||
vat, _ := requestData["vat"].(float64)
|
||||
inputVat, _ := requestData["input_vat"].(float64)
|
||||
@@ -583,7 +641,7 @@ func callTaxHealthAsync(this js.Value, args []js.Value) interface{} {
|
||||
|
||||
// 创建税务健康服务客户端
|
||||
// 注意:在真实的实现中,这些应该是安全存储的
|
||||
taxHealthService := api.NewTaxHealthService("1560142251348287489", "00d502fcac7a2b0e227751cd6d8b0c725c55f71adcaccc6a50c4d63c73db6c8add")
|
||||
taxHealthService := api.NewTaxHealthService("1554047490758508546", "00d502fcac7a2b0e227751cd6d8b0c725c55f71adcaccc6a50c4d63c73db6c8add")
|
||||
|
||||
// 构建税务评估请求
|
||||
request := api.TaxEvalRequest{
|
||||
@@ -593,7 +651,6 @@ func callTaxHealthAsync(this js.Value, args []js.Value) interface{} {
|
||||
CompanyName: companyName,
|
||||
Period: period,
|
||||
Year: year,
|
||||
IsVerify: isVerify,
|
||||
CIT: cit,
|
||||
VAT: vat,
|
||||
InputVAT: inputVat,
|
||||
@@ -653,24 +710,16 @@ func callTaxHealthAsync(this js.Value, args []js.Value) interface{} {
|
||||
go func() {
|
||||
select {
|
||||
case result := <-resultChan:
|
||||
// 将复杂结构体序列化为JSON
|
||||
jsonResult, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
// 序列化失败,返回错误
|
||||
reject.Invoke(js.ValueOf(map[string]string{
|
||||
"error": "JSON序列化失败: " + err.Error(),
|
||||
}))
|
||||
reject.Invoke(createErrorJSValue("JSON序列化失败: " + err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
// 将JSON字符串解析为JavaScript对象
|
||||
jsResult := js.Global().Get("JSON").Call("parse", string(jsonResult))
|
||||
resolve.Invoke(jsResult)
|
||||
case err := <-errorChan:
|
||||
// 将错误转换为JavaScript值
|
||||
reject.Invoke(js.ValueOf(map[string]string{
|
||||
"error": err.Error(),
|
||||
}))
|
||||
reject.Invoke(createErrorJSValue(err.Error()))
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -692,7 +741,7 @@ func queryTaxResultAsync(this js.Value, args []js.Value) interface{} {
|
||||
// 在goroutine中执行异步操作
|
||||
go func() {
|
||||
// 创建税务健康服务客户端
|
||||
taxHealthService := api.NewTaxHealthService("1560142251348287489", "00d502fcac7a2b0e227751cd6d8b0c725c55f71adcaccc6a50c4d63c73db6c8add")
|
||||
taxHealthService := api.NewTaxHealthService("1554047490758508546", "00d502fcac7a2b0e227751cd6d8b0c725c55f71adcaccc6a50c4d63c73db6c8add")
|
||||
|
||||
// 查询税务评估结果
|
||||
queryResponse, err := taxHealthService.QueryTaxEvalResult(orderNo)
|
||||
@@ -723,24 +772,16 @@ func queryTaxResultAsync(this js.Value, args []js.Value) interface{} {
|
||||
go func() {
|
||||
select {
|
||||
case result := <-resultChan:
|
||||
// 将复杂结构体序列化为JSON
|
||||
jsonResult, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
// 序列化失败,返回错误
|
||||
reject.Invoke(js.ValueOf(map[string]string{
|
||||
"error": "JSON序列化失败: " + err.Error(),
|
||||
}))
|
||||
reject.Invoke(createErrorJSValue("JSON序列化失败: " + err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
// 将JSON字符串解析为JavaScript对象
|
||||
jsResult := js.Global().Get("JSON").Call("parse", string(jsonResult))
|
||||
resolve.Invoke(jsResult)
|
||||
case err := <-errorChan:
|
||||
// 将错误转换为JavaScript值
|
||||
reject.Invoke(js.ValueOf(map[string]string{
|
||||
"error": err.Error(),
|
||||
}))
|
||||
reject.Invoke(createErrorJSValue(err.Error()))
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
@@ -166,8 +166,7 @@ func (s *CompanyInfoService) GetCompanyInfo(companyName string, apis []string) (
|
||||
// EvaluateTaxHealth 执行税务健康测评
|
||||
func (s *TaxHealthService) EvaluateTaxHealth(request TaxEvalRequest) (*TaxEvalResponse, error) {
|
||||
// 生成随机数和时间戳
|
||||
r, _ := rand.Int(rand.Reader, big.NewInt(10000))
|
||||
nonce := strconv.FormatInt(r.Int64(), 10)
|
||||
nonce := "123456"
|
||||
timestamp := strconv.FormatInt(time.Now().Unix()*1000, 10)
|
||||
apiURL := "https://api.cmdp.cn/v1/eval/tax-risk"
|
||||
// 序列化请求体
|
||||
@@ -210,9 +209,8 @@ func (s *TaxHealthService) EvaluateTaxHealth(request TaxEvalRequest) (*TaxEvalRe
|
||||
// QueryTaxEvalResult 查询税务测评结果
|
||||
func (s *TaxHealthService) QueryTaxEvalResult(orderNo string) (*TaxEvalQueryResponse, error) {
|
||||
// 生成随机数和时间戳
|
||||
r, _ := rand.Int(rand.Reader, big.NewInt(10000))
|
||||
nonce := strconv.FormatInt(time.Now().UnixNano(), 36) + strconv.FormatInt(r.Int64(), 10)
|
||||
timestamp := strconv.FormatInt(time.Now().Unix(), 10)
|
||||
nonce := "123456"
|
||||
timestamp := strconv.FormatInt(time.Now().Unix()*1000, 10)
|
||||
|
||||
apiURL := fmt.Sprintf("https://api.cmdp.cn/v1/eval/order/%s", orderNo)
|
||||
|
||||
|
||||
@@ -25,11 +25,10 @@ func TestCreateTaxEvalRequest(t *testing.T) {
|
||||
request := TaxEvalRequest{
|
||||
ReqNo: fmt.Sprintf("%v", time.Now().Unix()), // 使用时间戳生成请求号
|
||||
Detail: TaxEvalDetail{
|
||||
FileURL: "",
|
||||
Data: companyData,
|
||||
CompanyName: "顺丰", // 可以从数据中提取公司名称
|
||||
CompanyName: "郑州惠兴", // 可以从数据中提取公司名称
|
||||
Period: "Q1",
|
||||
Year: "2023",
|
||||
Year: "2022",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
198
web/index.html
198
web/index.html
@@ -13,7 +13,6 @@
|
||||
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.container {
|
||||
background-color: white;
|
||||
border-radius: 15px;
|
||||
@@ -292,6 +291,84 @@
|
||||
.config-panel.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.prompt-description, .prompt-input-section, .prompt-params-section,
|
||||
.prompt-expected-section, .prompt-result-section, .prompt-usage {
|
||||
margin-bottom: 25px;
|
||||
padding: 20px;
|
||||
background-color: white;
|
||||
border-radius: 10px;
|
||||
border-left: 5px solid #2196F3;
|
||||
}
|
||||
|
||||
.prompt-description h4, .prompt-params-section h4,
|
||||
.prompt-expected-section h4, .prompt-result-section h4, .prompt-usage h4 {
|
||||
margin-top: 0;
|
||||
color: #2c3e50;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
.prompt-description p {
|
||||
color: #7f8c8d;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.param-note {
|
||||
font-size: 0.9em;
|
||||
color: #95a5a6;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.prompt-result-section {
|
||||
display: none;
|
||||
border-left-color: #4caf50;
|
||||
}
|
||||
|
||||
.prompt-result-section.show {
|
||||
display: block;
|
||||
animation: fadeIn 0.5s;
|
||||
}
|
||||
|
||||
.prompt-usage ul {
|
||||
margin: 0;
|
||||
padding-left: 20px;
|
||||
color: #7f8c8d;
|
||||
}
|
||||
|
||||
.prompt-usage li {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
select {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
border: 2px solid #bbdefb;
|
||||
border-radius: 8px;
|
||||
font-size: 16px;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 15px;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
select:focus {
|
||||
outline: none;
|
||||
border-color: #64b5f6;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.tab button {
|
||||
padding: 10px 12px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.8em;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -341,6 +418,7 @@
|
||||
<button class="tablinks active" onclick="openTab(event, 'company')">企业行业分析</button>
|
||||
<button class="tablinks" onclick="openTab(event, 'excel')">Excel解析</button>
|
||||
<button class="tablinks" onclick="openTab(event, 'llm')">AI分析</button>
|
||||
<button class="tablinks" onclick="openTab(event, 'prompt')">Prompt管理</button>
|
||||
<button class="tablinks" onclick="openTab(event, 'tax')">税务健康</button>
|
||||
</div>
|
||||
|
||||
@@ -371,6 +449,64 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Prompt管理标签页 -->
|
||||
<div id="prompt" class="tabcontent">
|
||||
<div class="section">
|
||||
<h3>📝 getPrompt 方法功能展示</h3>
|
||||
|
||||
<div class="prompt-description">
|
||||
<h4>功能描述</h4>
|
||||
<p>getPrompt 方法用于根据指定的财务报表周期获取对应的提示词模板。系统支持多种周期类型,包括季度(Q1-Q3)和年度报告,每种周期对应专门设计的财务分析提示词,用于指导大模型进行税务健康评估数据转换。</p>
|
||||
</div>
|
||||
|
||||
<div class="prompt-input-section">
|
||||
<label for="promptPeriodSelect">📅 选择财务周期:</label>
|
||||
<select id="promptPeriodSelect">
|
||||
<option value="Q1">Q1 (第一季度)</option>
|
||||
<option value="第一季度">第一季度</option>
|
||||
<option value="Q2">Q2 (第二季度)</option>
|
||||
<option value="第二季度">第二季度</option>
|
||||
<option value="Q3">Q3 (第三季度)</option>
|
||||
<option value="第三季度">第三季度</option>
|
||||
<option value="年度">年度</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="prompt-params-section">
|
||||
<h4>📋 输入参数示例</h4>
|
||||
<div class="json-output" style="background: #fff3e0; border: 1px solid #ff9800; color: #e65100;">
|
||||
{"period": "Q1"}
|
||||
</div>
|
||||
<p class="param-note">参数说明: period 为字符串类型,支持的值包括 Q1、第一季度、Q2、第二季度、Q3、第三季度、年度</p>
|
||||
</div>
|
||||
|
||||
<div class="prompt-expected-section">
|
||||
<h4>🎯 预期输出结果</h4>
|
||||
<div class="json-output" style="background: #e8f5e9; border: 1px solid #4caf50; color: #2e7d32;">
|
||||
{"prompt": "根据选择的周期返回对应的提示词模板", "period": "所选周期"}
|
||||
</div>
|
||||
<p class="param-note">返回格式: JSON对象,包含 prompt(提示词内容) 和 period(所选周期) 字段</p>
|
||||
</div>
|
||||
|
||||
<button id="getPromptBtn" disabled>🚀 获取提示词</button>
|
||||
|
||||
<div class="prompt-result-section" id="promptResultSection">
|
||||
<h4>✅ 实际执行结果</h4>
|
||||
<div id="promptResultContent"></div>
|
||||
</div>
|
||||
|
||||
<div class="prompt-usage">
|
||||
<h4>📖 使用说明</h4>
|
||||
<ul>
|
||||
<li>1. 从下拉菜单中选择一个财务周期</li>
|
||||
<li>2. 点击「获取提示词」按钮执行 getPrompt 方法</li>
|
||||
<li>3. 在下方「实际执行结果」区域查看返回的提示词内容</li>
|
||||
<li>4. 如果选择了不支持的周期,系统会返回错误信息</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 税务健康标签页 -->
|
||||
<div id="tax" class="tabcontent">
|
||||
<div class="section">
|
||||
@@ -389,7 +525,7 @@
|
||||
</select>
|
||||
|
||||
<label for="yearInput">📅 报告期:</label>
|
||||
<input type="number" id="yearInput" placeholder="年份" value="2025" min="1900" max="2100">
|
||||
<input type="number" id="yearInput" placeholder="年份" value="2021" min="1900" max="2022">
|
||||
|
||||
<label for="citInput">💰 企业所得税应纳税额合计 (万元):</label>
|
||||
<input type="number" id="citInput" placeholder="单位:万元" value="100.0" step="0.01">
|
||||
@@ -458,6 +594,7 @@
|
||||
document.getElementById('analyzeCompanyBtn').disabled = false;
|
||||
document.getElementById('parseExcelBtn').disabled = false;
|
||||
document.getElementById('callLLMBtn').disabled = false;
|
||||
document.getElementById('getPromptBtn').disabled = false;
|
||||
document.getElementById('submitTaxBtn').disabled = false;
|
||||
document.getElementById('queryResultBtn').disabled = false;
|
||||
console.log('WASM模块加载完成');
|
||||
@@ -503,7 +640,8 @@
|
||||
displayResults('企业行业分析结果', result);
|
||||
}
|
||||
} catch (error) {
|
||||
showError('分析过程中发生错误: ' + error.message);
|
||||
const errorMsg = error.error || error.message || JSON.stringify(error);
|
||||
showError('分析过程中发生错误: ' + errorMsg);
|
||||
} finally {
|
||||
showLoading(false);
|
||||
}
|
||||
@@ -535,7 +673,8 @@
|
||||
displayResults('Excel解析结果', result);
|
||||
}
|
||||
} catch (error) {
|
||||
showError('解析Excel过程中发生错误: ' + error.message);
|
||||
const errorMsg = error.error || error.message || JSON.stringify(error);
|
||||
showError('解析Excel过程中发生错误: ' + errorMsg);
|
||||
} finally {
|
||||
showLoading(false);
|
||||
}
|
||||
@@ -568,7 +707,8 @@
|
||||
displayResults('大模型调用结果', result);
|
||||
}
|
||||
} catch (error) {
|
||||
showError('AI分析过程中发生错误: ' + error.message);
|
||||
const errorMsg = error.error || error.message || JSON.stringify(error);
|
||||
showError('AI分析过程中发生错误: ' + errorMsg);
|
||||
} finally {
|
||||
showLoading(false);
|
||||
}
|
||||
@@ -624,7 +764,7 @@
|
||||
try {
|
||||
// 构建请求数据
|
||||
let requestData = {
|
||||
req_no: 'REQ' + Date.now().toString(),
|
||||
req_no: Date.now().toString(),
|
||||
company_name: companyName,
|
||||
period: period,
|
||||
year: year.toString(),
|
||||
@@ -761,7 +901,8 @@
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
showError('轮询过程中发生错误: ' + error.message);
|
||||
const errorMsg = error.error || error.message || JSON.stringify(error);
|
||||
showError('轮询过程中发生错误: ' + errorMsg);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -769,7 +910,8 @@
|
||||
setTimeout(pollForResult, 5000);
|
||||
}
|
||||
} catch (error) {
|
||||
showError('税务健康评估过程中发生错误: ' + error.message);
|
||||
const errorMsg = error.error || error.message || JSON.stringify(error);
|
||||
showError('税务健康评估过程中发生错误: ' + errorMsg);
|
||||
} finally {
|
||||
showLoading(false);
|
||||
}
|
||||
@@ -797,7 +939,43 @@
|
||||
displayResults('税务评估查询结果', result);
|
||||
}
|
||||
} catch (error) {
|
||||
showError('查询税务评估结果过程中发生错误: ' + error.message);
|
||||
const errorMsg = error.error || error.message || JSON.stringify(error);
|
||||
showError('查询税务评估结果过程中发生错误: ' + errorMsg);
|
||||
} finally {
|
||||
showLoading(false);
|
||||
}
|
||||
});
|
||||
|
||||
// getPrompt按钮事件
|
||||
const getPromptBtn = document.getElementById('getPromptBtn');
|
||||
const promptPeriodSelect = document.getElementById('promptPeriodSelect');
|
||||
const promptResultSection = document.getElementById('promptResultSection');
|
||||
const promptResultContent = document.getElementById('promptResultContent');
|
||||
|
||||
getPromptBtn.addEventListener('click', async () => {
|
||||
const period = promptPeriodSelect.value;
|
||||
|
||||
showLoading(true);
|
||||
hideError();
|
||||
promptResultSection.classList.remove('show');
|
||||
|
||||
try {
|
||||
const result = await window.getPrompt(period);
|
||||
|
||||
if (result && result.error) {
|
||||
showError(result.error);
|
||||
} else {
|
||||
let html = '<div class="json-output" style="background: #e8f5e9; border: 1px solid #4caf50;">';
|
||||
html += '<strong>周期:</strong> ' + result.period + '<br><br>';
|
||||
html += '<strong>提示词内容:</strong><br>';
|
||||
html += '<pre style="white-space: pre-wrap; word-break: break-word;">' + result.prompt + '</pre>';
|
||||
html += '</div>';
|
||||
promptResultContent.innerHTML = html;
|
||||
promptResultSection.classList.add('show');
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMsg = error.error || error.message || JSON.stringify(error);
|
||||
showError('获取提示词失败: ' + errorMsg);
|
||||
} finally {
|
||||
showLoading(false);
|
||||
}
|
||||
@@ -811,6 +989,7 @@
|
||||
analyzeCompanyBtn.disabled = true;
|
||||
parseExcelBtn.disabled = true;
|
||||
callLLMBtn.disabled = true;
|
||||
getPromptBtn.disabled = true;
|
||||
submitTaxBtn.disabled = true;
|
||||
queryResultBtn.disabled = true;
|
||||
} else {
|
||||
@@ -821,6 +1000,7 @@
|
||||
analyzeCompanyBtn.disabled = false;
|
||||
parseExcelBtn.disabled = false;
|
||||
callLLMBtn.disabled = false;
|
||||
getPromptBtn.disabled = false;
|
||||
submitTaxBtn.disabled = false;
|
||||
queryResultBtn.disabled = false;
|
||||
}, 100);
|
||||
|
||||
Reference in New Issue
Block a user