Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
poc-api
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
poc
poc-api
Commits
03a0ab73
Commit
03a0ab73
authored
Jan 14, 2025
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
3d187137
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
6 deletions
+2
-6
WebSearchFunction.java
...ource/demand/ai/function/web_seach/WebSearchFunction.java
+2
-6
No files found.
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/web_seach/WebSearchFunction.java
View file @
03a0ab73
...
@@ -45,7 +45,7 @@ public class WebSearchFunction extends AbstractLargeModelFunction {
...
@@ -45,7 +45,7 @@ public class WebSearchFunction extends AbstractLargeModelFunction {
private
final
String
KEY
=
Config
.
get
(
"google.custom.search.key"
);
private
final
String
KEY
=
Config
.
get
(
"google.custom.search.key"
);
private
final
String
CX
=
Config
.
get
(
"google.custom.search.cx"
);
private
final
String
CX
=
Config
.
get
(
"google.custom.search.cx"
);
private
final
String
DESC
=
"该方法是
通过Bing所有对用户给出的关键词进行网站、网页搜索检索
获取网页内容"
;
private
final
String
DESC
=
"该方法是
使用Google搜索,对用户给出的关键词进行网页搜索检索并且
获取网页内容"
;
private
final
FunctionLLMConfig
functionLLMConfig
=
new
FunctionLLMConfig
.
FunctionLLMConfigBuilder
()
private
final
FunctionLLMConfig
functionLLMConfig
=
new
FunctionLLMConfig
.
FunctionLLMConfigBuilder
()
.
name
(
"web_search"
)
.
name
(
"web_search"
)
...
@@ -61,6 +61,7 @@ public class WebSearchFunction extends AbstractLargeModelFunction {
...
@@ -61,6 +61,7 @@ public class WebSearchFunction extends AbstractLargeModelFunction {
}
}
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
content
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
content
);
String
query
=
jsonObject
.
getString
(
"query"
);
String
query
=
jsonObject
.
getString
(
"query"
);
query
=
query
.
replaceAll
(
StringUtils
.
SPACE
,
StringUtils
.
EMPTY
);
List
<
WebSearchFunctionResult
>
results
=
new
ArrayList
<>();
List
<
WebSearchFunctionResult
>
results
=
new
ArrayList
<>();
try
{
try
{
CustomSearchAPI
customSearchAPI
=
new
CustomSearchAPI
.
Builder
(
transport
,
jsonFactory
,
GoogleNetHttpTransport
.
newTrustedTransport
().
createRequestFactory
().
getInitializer
())
CustomSearchAPI
customSearchAPI
=
new
CustomSearchAPI
.
Builder
(
transport
,
jsonFactory
,
GoogleNetHttpTransport
.
newTrustedTransport
().
createRequestFactory
().
getInitializer
())
...
@@ -84,12 +85,7 @@ public class WebSearchFunction extends AbstractLargeModelFunction {
...
@@ -84,12 +85,7 @@ public class WebSearchFunction extends AbstractLargeModelFunction {
htmlContent
=
htmlContent
.
substring
(
0
,
10000
);
htmlContent
=
htmlContent
.
substring
(
0
,
10000
);
}
}
}
}
String
title
=
item
.
getTitle
();
String
snippet
=
item
.
getSnippet
();
WebSearchFunctionResult
webSearchResult
=
new
WebSearchFunctionResult
();
WebSearchFunctionResult
webSearchResult
=
new
WebSearchFunctionResult
();
// webSearchResult.setTitle(title);
// webSearchResult.setUrl(link);
// webSearchResult.setSnippet(snippet);
webSearchResult
.
setContent
(
htmlContent
);
webSearchResult
.
setContent
(
htmlContent
);
results
.
add
(
webSearchResult
);
results
.
add
(
webSearchResult
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment