GeoService.php
3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
/**
* @remark :
* @name :GeoService.php
* @author :lyh
* @method :post
* @time :2025/7/3 14:21
*/
namespace App\Services\Geo;
use Illuminate\Support\Facades\Http;
class GeoService
{
public $api_key = 'UkzZljFv83Z2qBi5YR1o3f2otAVWtug6';
public $api_url = 'https://api.cmer.com/';
/**
* 获取AI平台数据
* @param $content
* @param $platform
* @return mixed|string
*/
public function getAiPlatformResult($content,$platform)
{
$url = $this->api_url . 'v1/websearch_chat';
$header = [
'accept: application/json',
'X-CmerApi-Host: llm-chat.p.cmer.com',
'apikey: '.$this->api_key,
'Content-Type: application/json'
];
$message = [
'messages'=>[
[
'content'=>$content,
'role'=>'user'
],
],
'platform' => $platform,
'security_check' => true
];
$data = http_post($url,json_encode($message,true),$header,true,180);
return $data;
}
/**
* 获取Google数据
* @param $search
* @param int $lum_json 默认1 不只是什么参数
* @return mixed|string
*/
public function getGooglePlatformResult($search)
{
$url = 'https://api.cmer.com/ai-overviews';
$header = [
'accept: application/json',
'apikey: UkzZljFv83Z2qBi5YR1o3f2otAVWtug6',
'Content-Type: application/json',
'X-CmerApi-Host:ai-overviews.p.cmer.com'
];
$param = [
'q' => $search,
'location' => 'New York, United States',
'gl' => 'us',
'hl'=>'en'
];
$url = $url . '?' . http_build_query($param);
return http_get($url, $header);
}
/**
* 请求chat会话, 自定义模型
* @param $content
* @param string $model
* @return mixed|string
*/
public function getChatResult($content, $model = 'deepseek-r1'){
$url = $this->api_url . 'v1/chat';
switch ($model){
case 'deepseek-r1':
$supplier = 'bailian';
break;
case 'gpt-4o-mini':
$supplier = 'azure';
break;
default:
$supplier = '';
break;
}
$header = [
'accept: application/json',
'X-CmerApi-Host: llm-chat.p.cmer.com',
'apikey: '.$this->api_key,
'Content-Type: application/json'
];
$message = [
'messages'=>[
[
'content'=>$content,
'role'=>'user'
],
],
'model' => $model,
"supplier"=> $supplier,
'security_check' => true
];
$data = http_post($url,json_encode($message,true),$header);
return $data;
}
/**
* 获取语句余弦相似度
* $text 会被拆解语句, 分析预警传$text
* @param string $standard 标准答案
* @param string $text 需要分析的语句
* @param string $embedding_model
* @param string $similarity_method
* @return \Illuminate\Http\Client\Response
*/
public function cosineSimilarity($standard, $text, $embedding_model = 'text-embedding-3-small', $similarity_method = 'cosine')
{
$url = 'http://knowledge_base.zabbix.waimaoq.com/v1/crud/split_similarity';
$header = [
'accept: application/json',
'Content-Type: application/json'
];
$param = [
'text1' => $standard,
'text2' => $text,
'embedding_model' => $embedding_model,
'similarity_method' => $similarity_method
];
$result = Http::post($url, $param);
return $result->json();
}
}