Skip to content

Commit

Permalink
plugin run state & fix
Browse files Browse the repository at this point in the history
  • Loading branch information
onlyGuo committed Apr 20, 2024
1 parent 189c23e commit eaa26ca
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ You can download the latest version of GPTCraft from the [release page](https://
- [x] Model switching support
- [ ] Image upload support
- [x] Support for DALL-E image outputs
- [ ] Support for plugins and the multimodal approach of official ChatGPT-Plus.
- [x] Support for plugins and the multimodal approach of official ChatGPT-Plus.
- [ ] Session cleanup support
- [x] Session editing support
- [ ] Voice output support
Expand Down
72 changes: 48 additions & 24 deletions lib/components/chat/message/CodeHightLightView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,30 +71,54 @@ class CodeElementBuilder extends MarkdownElementBuilder {
);
}
if(language == 'call-function'){
GPTPluginInterface plugin = GPTPluginController.getByFunctionName(element.textContent.replaceAll("\n", ""));
return Row(
children: [
Container(
padding: const EdgeInsets.only(left: 5, right: 5, top: 3, bottom: 3),
margin: const EdgeInsets.only(top: 2, bottom: 2),
decoration: BoxDecoration(
color: const Color.fromRGBO(220, 220, 220, 0.5),
borderRadius: BorderRadius.circular(5),
),
child: Row(
children: [
SizedBox(
width: 20,
height: 20,
child: plugin.icon,
),
const SizedBox(width: 5,),
Text(plugin.name),
],
)
),
Expanded(child: Container(),),
],
String name = element.textContent.contains("!end") ?
element.textContent.substring(0, element.textContent.indexOf("!end")) : element.textContent;
GPTPluginInterface plugin = GPTPluginController.getByFunctionName(name.replaceAll("\n", ""));
return Container(
color: Colors.white,
child: Row(
children: [
Container(
padding: const EdgeInsets.only(left: 5, right: 5, top: 3, bottom: 3),
margin: const EdgeInsets.only(top: 2, bottom: 2),
decoration: BoxDecoration(
color: const Color.fromRGBO(220, 220, 220, 0.5),
borderRadius: BorderRadius.circular(5),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
SizedBox(
width: 20,
height: 20,
child: plugin.icon,
),
const SizedBox(width: 5,),
Text(plugin.name),
],
),
if(element.textContent.contains("!end"))
const Row(
children: [
Icon(Icons.check, color: Colors.green, size: 12,),
Text('Completed!', style: TextStyle(fontSize: 12, color: Colors.grey),),
],
)
else
const Row(
children: [
Icon(Icons.timer, color: Colors.blue, size: 12,),
Text('Running...', style: TextStyle(fontSize: 12, color: Colors.grey),),
],
)
],
),
),
Expanded(child: Container())
],
),
);

}
Expand Down
3 changes: 3 additions & 0 deletions lib/gpt/plugins/impl/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class DrawPlugin extends GPTPluginInterface {
String basicUrl, String accessKey) {
if(method == 'dall_e_draw'){
basicUrl = basicUrl.endsWith('/') ? basicUrl : '$basicUrl/';
if(params['size'] != null && !['1024x1024', '1792x1024', '1024x1792'].contains(params['size'])){
params['size'] = '1024x1024';
}
try{
return Util.post('${basicUrl}v1/images/generations', {
"Authorization": "Bearer $accessKey",
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/Util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class Util{
if(tool["function"]["name"] != null){
callFunction = tool["function"]["name"];
callFunctionId = tool["id"];
showContent += "\n\n```call-function\n$callFunction\n```\n";
showContent += "\n\n```call-function\n$callFunction";
}
callFunctionParams += tool["function"]["arguments"];
}
Expand Down Expand Up @@ -246,6 +246,7 @@ class Util{
Map<String, dynamic> functionParam = jsonDecode(callFunctionParams);
p.execute(method.name, functionParam, basicUrl, accessKey).then((value) {
message.add(ChatMessage(content: value, role: 'tool', time: '', toolsCallId: callFunctionId));
showContent += '!end\n```\n';
askGPT(basicUrl, model, temperature, accessKey, plugin, message, callback, err,
bufferContent: showContent);
});
Expand Down

0 comments on commit eaa26ca

Please sign in to comment.