Files
wasm-go/cmd/test/main.go
lychang 7f5350db62 update
2026-05-20 03:25:35 +08:00

56 lines
1.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"fmt"
"log"
"wasm-go/internal/api"
)
func main() {
fmt.Println("=== 企业行业分类示例 ===")
// 创建LLM客户端 - 这里使用Ollama作为示例
// 如果Ollama不可用,也可以使用OpenAI
var llmClient *api.LLMClient
// 尝试连接到Ollama
fmt.Println("尝试连接到Ollama服务...")
llmClient = api.NewOllamaClient("http://localhost:11434", "qwen3.5:9b")
// 如果需要使用OpenAI,取消下面的注释并替换API KEY
/*
llmClient = api.NewOpenAIClient("your-openai-api-key", "gpt-3.5-turbo")
*/
// 创建企业行业分类器
classifier := api.NewCompanyIndustryClassifier(llmClient)
// 示例公司名称 - 可以从命令行参数获取
companyName := "深圳市致远速联信息技术有限公司"
fmt.Printf("正在分析公司: %s\n", companyName)
// 分析企业行业
result, err := classifier.ClassifyCompany(companyName)
if err != nil {
log.Printf("分析失败: %v", err)
return
}
// 输出结果
fmt.Printf("\n✅ 企业行业分析完成!\n")
fmt.Printf("公司名称: %s\n", result.CompanyName)
fmt.Printf("主要行业: %s - %s\n", result.Primary.Code, result.Primary.Name)
fmt.Printf("判断依据: %s\n", result.Primary.Reason)
if len(result.Secondary) > 0 {
fmt.Printf("次要行业:\n")
for _, sec := range result.Secondary {
fmt.Printf(" %s - %s\n", sec.Code, sec.Name)
fmt.Printf(" 判断依据: %s\n", sec.Reason)
}
} else {
fmt.Printf("次要行业: 无\n")
}
}