Skip to content

Commit

Permalink
feat: [codegeex] add command_type arguments of inlinechat api
Browse files Browse the repository at this point in the history
Log: as title
  • Loading branch information
LiHua000 authored and deepin-mozart committed Oct 25, 2024
1 parent 596566f commit e2acd78
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/plugins/codegeex/codegeex/copilotapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,14 @@ QByteArray CopilotApi::assembleInlineChatBody(const QString &prompt, const Inlin
json.insert("code", info.selectedCode);
json.insert("command", "inline_chat");
json.insert("locale", locale);
json.insert("talkId", CodeGeeXManager::instance()->getTalkId());
json.insert("model", chatModel);
json.insert("prompt", prompt);
QString promptWithType = prompt;
if (info.commandType == InlineChatInfo::Chat)
promptWithType.append(".use Chat type to answer me");
else if (info.commandType == InlineChatInfo::Programing)
promptWithType.append(".use Programing type to answer me");
json.insert("prompt", promptWithType);

QJsonObject inline_chat_obj;
inline_chat_obj.insert("is_ast", info.is_ast);
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/codegeex/codegeex/copilotapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,16 @@ static const QStringList ALL_AST_LANGS = {
};

struct InlineChatInfo {
enum CommandType{
Programing,
Chat
};
QString fileName { "" };
QString package_code { "" }; // eg: "10 import path \n11 import os \n15 import pygame"
QString class_function { "" }; // if is_ast is false, class_function do not be set. or set it to "all class and function definition in current file"
QString selectedCode { "" }; // need to contains [cursor]
QString contextCode { "" }; // linenumber before code
CommandType commandType { Programing };
bool is_ast { false }; // true when above langs contains this file type and file content > 100 lines
};

Expand Down

0 comments on commit e2acd78

Please sign in to comment.