Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
chat-query
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
jaden
chat-query
Commits
484b7b14
Commit
484b7b14
authored
Jul 13, 2023
by
jaden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: functions upodate
parent
ebd75809
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
39 deletions
+34
-39
client/api/openAI.ts
client/api/openAI.ts
+4
-2
components/AITool/index.tsx
components/AITool/index.tsx
+3
-0
data/prompt/functions.ts
data/prompt/functions.ts
+4
-2
pages/actions/index.tsx
pages/actions/index.tsx
+6
-28
utils/export-sql.js
utils/export-sql.js
+6
-4
utils/getXMLContent.ts
utils/getXMLContent.ts
+11
-3
No files found.
client/api/openAI.ts
View file @
484b7b14
...
...
@@ -37,8 +37,9 @@ export default class OpenAI {
onFinish
:
(
responseText
:
string
)
=>
any
,
onUpdate
:
(
responseText
:
string
,
delta
:
string
)
=>
any
,
onError
:
(
e
:
Error
)
=>
any
,
functions
:
any
[]
=
[]
,
functions
:
any
[],
closeFn
?:
MutableRefObject
<
any
>
,
function_call
?:
any
,
stream
:
boolean
=
true
)
{
const
requestPayload
=
{
...
...
@@ -48,7 +49,8 @@ export default class OpenAI {
frequency_penalty
:
model
.
frequency_penalty
,
presence_penalty
:
model
.
presence_penalty
,
stream
,
functions
:
functions
,
functions
,
function_call
,
};
const
controller
=
new
AbortController
();
const
chatPayload
=
{
...
...
components/AITool/index.tsx
View file @
484b7b14
...
...
@@ -52,6 +52,7 @@ type AIProps = {
noHistory
?:
boolean
;
functions
:
any
[];
stream
?:
boolean
;
function_call
:
any
;
};
export
function
AIWrapper
({
...
...
@@ -71,6 +72,7 @@ export function AIWrapper({
SendButton
,
noHistory
,
functions
,
function_call
,
stream
,
}:
AIProps
)
{
const
input
=
useRef
<
any
>
();
...
...
@@ -170,6 +172,7 @@ export function AIWrapper({
},
functions
,
closeRef
,
function_call
,
stream
||
!
functions
);
},
...
...
data/prompt/functions.ts
View file @
484b7b14
export
const
QUERY_FUNCTION
=
[
{
name
:
'
saveExecuteSqlInfo
'
,
description
:
'
存储执行该需求所需要的关键信息
'
,
description
:
'
Unique and mandatory execution (no other functions can be executed), storing the key information required to execute this requirement
'
,
parameters
:
{
type
:
'
object
'
,
properties
:
{
sql
:
{
type
:
'
string
'
,
description
:
'
The SQL statement to execute
'
,
description
:
'
The SQL statement to execute must be standard and cannot contain any other code.
'
,
},
variablesArr
:
{
type
:
'
array
'
,
...
...
pages/actions/index.tsx
View file @
484b7b14
...
...
@@ -635,38 +635,14 @@ export default function Actions() {
role
:
'
assistant
'
,
content
:
`好的,请问这个示例对吗?
根据您提供的数据库模型,生成的查询如下:
\`\`\`sql
SELECT $field$ FROM users where id=$id$;
INSERT INTO users (email, name) VALUES ($email$, $name$);
\`\`\`
执行所需变量:
<var> $field$ </var>: <varDescription> users 表中的某个字段。</varDescription>
查询命名和描述:
查询名称:查询所有表中的数据
查询描述:该查询用于检索所有表中的数据。
{"name":"python","arguments":"import pandas as pd\n\n# 模拟查询数据库中的表\ntables = ['departments', 'doctors', 'patients', 'appointments']\n\n# 将查询结果转换为DataFrame格式\ndf = pd.DataFrame(tables, columns=['Table Name'])\n\n# 将DataFrame转换为HTML格式\nhtml_result = df.to_html(index=False)\n\nhtml_result"}
`
,
},
{
role
:
'
user
'
,
content
:
`不对!
你不应该使用markdown语法
,(输出结果标签(<sql>、<var>等)必须保留。变量的命名必须请放在$和$之间,例如:$tab$、$name$...),下面是一个示例:
content
:
`不对!
必须且仅能调用functions中saveExecuteSqlInfo
,(输出结果标签(<sql>、<var>等)必须保留。变量的命名必须请放在$和$之间,例如:$tab$、$name$...),下面是一个示例:
根据您提供的数据库模型,已为您生成查询:
<sql>
SELECT $field$ FROM users where id=$id$;
INSERT INTO users (email, name) VALUES ($email$, $name$);
</sql>
执行所需变量:
<var> $field$ </var>: <varDescription> users 表中的某个字段。</varDescription>
查询命名和描述:
<queryName> 查用户和插入用户 </queryName>
<queryDescription> 先根据用户id查出用户,然后插入一个用户。 </queryDescription>
{"name":"saveExecuteSqlInfo","arguments":"{\n \"sql\": \"SELECT * FROM departments; SELECT * FROM doctors; SELECT * FROM patients; SELECT * FROM appointments;\",\n \"variablesArr\": [],\n \"queryName\": \"查询所有表中的数据\",\n \"queryDescription\": \"该查询用于检索所有表中的数据。\"\n}"}
`
,
},
{
...
...
@@ -803,8 +779,10 @@ INSERT INTO users (email, name) VALUES ($email$, $name$);
<
Content
>
<
AI
functions=
{
QUERY_FUNCTION
}
function_call=
{
{
name
:
'
saveExecuteSqlInfo
'
,
}
}
stream=
{
false
}
noHistory
quickTip=
{
queryTip
}
welcome=
{
<>
...
...
utils/export-sql.js
View file @
484b7b14
...
...
@@ -47,10 +47,12 @@ const exportSQL = (tableDict, linkDict, databaseType = 'postgres') => {
}),
};
const
database
=
Parser
.
parse
(
combined
,
'
json
'
);
const
sql
=
ModelExporter
.
export
(
database
,
databaseType
,
false
);
return
sql
;
try
{
const
database
=
Parser
.
parse
(
combined
,
'
json
'
);
return
ModelExporter
.
export
(
database
,
databaseType
,
false
);
}
catch
(
e
)
{
console
.
log
(
e
);
}
};
export
default
exportSQL
;
utils/getXMLContent.ts
View file @
484b7b14
...
...
@@ -15,13 +15,21 @@ export class XML {
}
export
class
FunctionsJson
{
private
root
:
HTMLDivElement
;
private
root
:
Record
<
string
,
any
>
;
constructor
(
code
:
string
)
{
this
.
root
=
JSON
.
parse
(
code
);
try
{
this
.
root
=
JSON
.
parse
(
code
);
}
catch
{
this
.
root
=
{};
}
}
get
(
code
:
string
):
string
{
return
JSON
.
parse
(
get
(
this
.
root
,
'
arguments
'
,
'
{}
'
))[
code
];
try
{
return
JSON
.
parse
(
get
(
this
.
root
,
'
arguments
'
,
'
{}
'
))[
code
]
||
''
;
}
catch
(
e
)
{
return
''
;
}
}
}
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