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
3f3b2975
Commit
3f3b2975
authored
May 12, 2025
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:合同信息提取插件
parent
dfec90e9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
7 deletions
+37
-7
ContractExtractionFunction.java
...nd/ai/function/extraction/ContractExtractionFunction.java
+37
-7
No files found.
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/extraction/ContractExtractionFunction.java
View file @
3f3b2975
...
...
@@ -10,6 +10,7 @@ import cn.com.poc.thirdparty.resource.demand.ai.function.entity.Properties;
import
cn.com.poc.thirdparty.resource.demand.ai.function.extraction.entity.KeyInfo
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.text_in_pdf2md.api.TextInClient
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.json.JSONException
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.stereotype.Component
;
...
...
@@ -41,12 +42,14 @@ public class ContractExtractionFunction extends AbstractLargeModelFunction {
@Override
public
AbstractFunctionResult
<
String
>
doFunction
(
String
content
,
String
identifier
)
{
AbstractFunctionResult
<
String
>
result
=
new
AbstractFunctionResult
<>();
String
fileUrl
;
List
<
KeyInfo
>
keyInfos
=
new
ArrayList
<>();
if
(
isJsonArray
(
content
))
{
JSONArray
jsonArray
=
JSONArray
.
parseArray
(
content
);
if
(
jsonArray
.
isEmpty
())
{
return
result
;
}
String
fileUrl
=
jsonArray
.
getJSONObject
(
0
).
getString
(
"file_url"
);
List
<
KeyInfo
>
keyInfos
=
new
ArrayList
<>();
fileUrl
=
jsonArray
.
getJSONObject
(
0
).
getString
(
"file_url"
);
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
JSONObject
jsonObject
=
jsonArray
.
getJSONObject
(
i
);
KeyInfo
keyInfo
=
new
KeyInfo
();
...
...
@@ -64,6 +67,24 @@ public class ContractExtractionFunction extends AbstractLargeModelFunction {
}
keyInfos
.
add
(
keyInfo
);
}
}
else
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
content
);
fileUrl
=
jsonObject
.
getString
(
"file_url"
);
KeyInfo
keyInfo
=
new
KeyInfo
();
if
(
jsonObject
.
containsKey
(
"field_type"
))
{
keyInfo
.
setField_type
(
jsonObject
.
getString
(
"file_type"
));
}
if
(
jsonObject
.
containsKey
(
"key_info"
))
{
keyInfo
.
setKey_info
(
jsonObject
.
getString
(
"key_info"
));
}
if
(
jsonObject
.
containsKey
(
"paraphrase_names"
))
{
keyInfo
.
setParaphrase_names
(
jsonObject
.
getJSONArray
(
"paraphrase_names"
).
toArray
(
new
String
[
0
]));
}
if
(
jsonObject
.
containsKey
(
"keywords"
))
{
keyInfo
.
setKeywords
(
jsonObject
.
getJSONArray
(
"keywords"
).
toArray
(
new
String
[
0
]));
}
keyInfos
.
add
(
keyInfo
);
}
TextInClient
textInClient
=
new
TextInClient
();
String
extraction
=
textInClient
.
extraction
(
fileUrl
,
keyInfos
);
...
...
@@ -86,4 +107,13 @@ public class ContractExtractionFunction extends AbstractLargeModelFunction {
public
List
<
String
>
getLLMConfig
(
List
<
Variable
>
variableStructure
)
{
return
this
.
getLLMConfig
();
}
private
boolean
isJsonArray
(
String
json
)
{
try
{
new
cn
.
hutool
.
json
.
JSONArray
(
json
);
return
true
;
}
catch
(
JSONException
e
)
{
return
false
;
}
}
}
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