Skip to content

Commit

Permalink
Displaying Agent folders in GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
Clay-Ferguson committed Dec 18, 2024
1 parent 8508cbb commit 29255ad
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 92 deletions.
2 changes: 2 additions & 0 deletions QuantaAI/quanta_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def api_query(req: AIRequest,
codingAgent: {req.codingAgent}
foldersToInclude: {req.foldersToInclude}
foldersToExclude: {req.foldersToExclude}
agentFileExtensions: {req.agentFileExtensions}
maxTokens: {req.maxTokens}
temperature: {req.temperature}
""")
Expand Down Expand Up @@ -110,6 +111,7 @@ def api_query(req: AIRequest,
folders_to_include = req.foldersToInclude.split("\n")
folders_to_include = list(filter(None, folders_to_include))

folders_to_exclude = []
if req.foldersToExclude:
folders_to_exclude = req.foldersToExclude.split("\n")
folders_to_exclude = list(filter(None, folders_to_exclude))
Expand Down
10 changes: 8 additions & 2 deletions common/python/agent/prompt_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,19 @@ def build_folder_content(folder_path: str, source_folder_len: int, ext_set: Set[
if not os.path.exists(folder_path):
raise FileNotFoundError(f"Folder {folder_path} does not exist")

# print("Walking folder_path: {folder_path}")
for dirpath, _, filenames in os.walk(folder_path):
for filename in filenames:
# print(f"Checking file: {filename}")
short_dir: str = dirpath[source_folder_len :]

hasIncludedFileExtension = Utils.has_included_file_extension(ext_set, filename)
# print(f" ext pass: {hasIncludedFileExtension}")
allowFolder = Utils.allow_folder(folders_to_include, folders_to_exclude, short_dir)
# print(f" folder pass: {allowFolder}")

# Check the file extension
if (Utils.has_included_file_extension(ext_set, filename)
and Utils.allow_folder(folders_to_include,folders_to_exclude, short_dir)):
if (hasIncludedFileExtension and allowFolder):
# build the full path
path: str = os.path.join(dirpath, filename)
# get the file name relative to the source folder
Expand Down
7 changes: 5 additions & 2 deletions dc-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ services:
spring.servlet.multipart.max-request-size: "200MB"
adminDataFolder: "/tmp"

qaiProjectsFolder: '${QAI_PROJECTS}'
qaiDataFolder: '${QAI_DATA}'

mail.port: ""
mail.user: "postmaster@quantizr.com"
mail.password: "${emailPassword}"
Expand Down Expand Up @@ -289,8 +292,8 @@ services:
- '${QAI_PORT}:${QAI_PORT}'
volumes:
# todo-2: make these two folders visible in Agent Config panel of app (but read-only)
- /home/clay/ferguson/Quantizr/src:/projects
- /home/clay/ai-agent-temp:/data
- '${QAI_PROJECTS}:/projects'
- '${QAI_DATA}:/data'
- '${QUANTA_BASE}/log:/log'

networks:
Expand Down
7 changes: 5 additions & 2 deletions dc-distro.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ services:
spring.servlet.multipart.max-request-size: "200MB"
adminDataFolder: "/tmp"

qaiProjectsFolder: '${QAI_PROJECTS}'
qaiDataFolder: '${QAI_DATA}'

# mail.port: ""
# mail.user: "your mail user"
# mail.password: "${emailPassword}"
Expand Down Expand Up @@ -227,8 +230,8 @@ services:
- '${QAI_PORT}:${QAI_PORT}'

volumes:
- /home/clay/ferguson/Quantizr/src:/projects
- /home/clay/quanta-localhost-dev/log:/data
- '${QAI_PROJECTS}:/projects'
- '${QAI_DATA}:/data'
- "${DEPLOY_TARGET}/log:/log"
networks:
bridge:
4 changes: 2 additions & 2 deletions scripts/build-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ serviceCheck ${docker_stack}_mongo-dev
# only required to run once to initialize the replica set
# runInitReplica

echo "Waiting 30s for server to initialize..."
sleep 30s
echo "Waiting 20s for server to initialize..."
sleep 20s

printUrlsMessage
2 changes: 2 additions & 0 deletions scripts/setenv-build-distro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export MONGOD_CONF=${DEPLOY_TARGET}/mongod.conf

export QAI_HOST=qai-host-distro
export QAI_PORT=8187
export QAI_PROJECTS=/home/clay/ferguson/Quantizr/src
export QAI_DATA=/home/clay/ai-agent-temp

# we dump this key into the root, and will not use it, but in real environments you'll put this key in some secure location
export MONGO_KEY=/mongo-key-distro
Expand Down
2 changes: 2 additions & 0 deletions scripts/setenv-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export MONGO_PORT=27016

export QAI_HOST=qai-host-dev
export QAI_PORT=8186
export QAI_PROJECTS=/home/clay/ferguson/Quantizr/src
export QAI_DATA=/home/clay/ai-agent-temp

# NOTE: This file gets *generated* by the build.
export MONGOD_CONF=${PRJROOT}/mongod-dev.conf
Expand Down
2 changes: 2 additions & 0 deletions scripts/setenv-run-distro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export MONGO_PORT=27017

export QAI_HOST=qai-host-distro
export QAI_PORT=8187
export QAI_PROJECTS=/home/clay/ferguson/Quantizr/src
export QAI_DATA=/home/clay/ai-agent-temp

export DOCKER_DOWN_DELAY=30s
export DOCKER_UP_DELAY=30s
Expand Down
73 changes: 0 additions & 73 deletions scripts/setenv-run-distro_quanta.sh

This file was deleted.

8 changes: 8 additions & 0 deletions src/main/java/quanta/config/AppProp.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,14 @@ public String getAdminDataFolder() {
return getPathProperty("adminDataFolder");
}

public String getQaiProjectsFolder() {
return getPathProperty("qaiProjectsFolder");
}

public String getQaiDataFolder() {
return getPathProperty("qaiDataFolder");
}

public String getRsaKeyFolder() {
return getPathProperty("rsaKeyFolder");
}
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/quanta/model/client/ClientConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class ClientConfig {
private String login;
private String paymentLink;
private boolean aiAgentEnabled;
private String qaiProjectsFolder;
private String qaiDataFolder;
private String userGuideUrl;

public String getLogin() {
Expand Down Expand Up @@ -159,5 +161,21 @@ public void setUserGuideUrl(String userGuideUrl) {
this.userGuideUrl = userGuideUrl;
}

public String getQaiProjectsFolder() {
return qaiProjectsFolder;
}

public void setQaiProjectsFolder(String qaiProjectsFolder) {
this.qaiProjectsFolder = qaiProjectsFolder;
}

public String getQaiDataFolder() {
return qaiDataFolder;
}

public void setQaiDataFolder(String qaiDataFolder) {
this.qaiDataFolder = qaiDataFolder;
}

public ClientConfig() {}
}
2 changes: 2 additions & 0 deletions src/main/java/quanta/service/NodeRenderService.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ else if (!StringUtils.isEmpty(name)) {
config.setLogin(login);
config.setUrlView(view);
config.setAiAgentEnabled(svc_prop.getAiAgentEnabled());
config.setQaiDataFolder(svc_prop.getQaiDataFolder());
config.setQaiProjectsFolder(svc_prop.getQaiProjectsFolder());
config.setUserGuideUrl(svc_prop.getUserGuideUrl());

attrs.put("g_config", config);
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/public/src/JavaIntf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export interface ClientConfig {
login: string;
paymentLink: string;
aiAgentEnabled: boolean;
qaiProjectsFolder: string;
qaiDataFolder: string;
userGuideUrl: string;
}

Expand Down
23 changes: 12 additions & 11 deletions src/main/resources/public/src/dlg/ConfigureAIDlg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class ConfigureAgentDlg extends DialogBase {
placeholder: "You are a helpful assistant."
}, this.promptState, null, false, 3, this.systemPromptScrollPos),
S.quanta.config.aiAgentEnabled ? new CollapsiblePanel("Coding Agent Props", "Hide Coding Agent Props", null, [
new TextArea("Folders to Include", {
new TextArea("Folders to Include (relative to: " + S.quanta.config.qaiProjectsFolder + ")", {
rows: 4,
placeholder: "List folders to include (optional)"
}, this.foldersToIncludeState, null, false, 3, this.foldersToIncludeScrollPos, "mt-3"),
Expand All @@ -61,6 +61,7 @@ export class ConfigureAgentDlg extends DialogBase {
val: this.fileExtState,
outterClass: "mt-3"
}),
new Div("Data Folder: " + S.quanta.config.qaiDataFolder, { className: "mt-3" }),
], true,
(expanded: boolean) => {
dispatch("setPropsPanelExpanded", s => {
Expand Down Expand Up @@ -97,25 +98,25 @@ export class ConfigureAgentDlg extends DialogBase {
this.fileExtState.setValue(S.props.getPropStr(J.NodeProp.AI_FILE_EXTENSIONS, this.node));
this.maxWordsState.setValue(S.props.getPropStr(J.NodeProp.AI_MAX_WORDS, this.node));
this.temperatureState.setValue(S.props.getPropStr(J.NodeProp.AI_TEMPERATURE, this.node));
this.aiServiceState.setValue(S.props.getPropStr(J.NodeProp.AI_SERVICE, this.node) || "[null]");
this.aiServiceState.setValue(S.props.getPropStr(J.NodeProp.AI_SERVICE, this.node));
}

save = async () => {
// Note: The "|| [null]" makes sure the server deletes the entire property rather than leaving empty string.
S.props.setPropVal(J.NodeProp.AI_PROMPT, this.node, this.promptState.getValue() || "[null]");
S.props.setPropVal(J.NodeProp.AI_FOLDERS_TO_INCLUDE, this.node, this.foldersToIncludeState.getValue() || "[null]");
S.props.setPropVal(J.NodeProp.AI_FOLDERS_TO_EXCLUDE, this.node, this.foldersToExcludeState.getValue() || "[null]");
S.props.setPropVal(J.NodeProp.AI_FILE_EXTENSIONS, this.node, this.fileExtState.getValue() || "[null]");
S.props.setPropVal(J.NodeProp.AI_SERVICE, this.node, this.aiServiceState.getValue() || "[null]");
S.props.setPropVal(J.NodeProp.AI_MAX_WORDS, this.node, this.maxWordsState.getValue() || "[null]");
S.props.setPropVal(J.NodeProp.AI_TEMPERATURE, this.node, this.temperatureState.getValue() || "[null]");
S.props.setPropVal(J.NodeProp.AI_PROMPT, this.node, this.promptState.getValue());
S.props.setPropVal(J.NodeProp.AI_FOLDERS_TO_INCLUDE, this.node, this.foldersToIncludeState.getValue());
S.props.setPropVal(J.NodeProp.AI_FOLDERS_TO_EXCLUDE, this.node, this.foldersToExcludeState.getValue());
S.props.setPropVal(J.NodeProp.AI_FILE_EXTENSIONS, this.node, this.fileExtState.getValue());
S.props.setPropVal(J.NodeProp.AI_SERVICE, this.node, this.aiServiceState.getValue());
S.props.setPropVal(J.NodeProp.AI_MAX_WORDS, this.node, this.maxWordsState.getValue());
S.props.setPropVal(J.NodeProp.AI_TEMPERATURE, this.node, this.temperatureState.getValue());

const aiService: AIService = S.aiUtil.getServiceByName(this.aiServiceState.getValue());
if (aiService && aiService.name !== J.AIModel.NONE) {
S.props.setPropVal(J.NodeProp.AI_CONFIG, this.node, "true");
}
else {
S.props.setPropVal(J.NodeProp.AI_CONFIG, this.node, "[null]");
S.props.setPropVal(J.NodeProp.AI_CONFIG, this.node, "");
}

await S.edit.saveNode(this.node, true);
Expand All @@ -129,7 +130,7 @@ export class ConfigureAgentDlg extends DialogBase {
this.fileExtState.setValue("");
this.maxWordsState.setValue("");
this.temperatureState.setValue("");
this.aiServiceState.setValue("[null]");
this.aiServiceState.setValue("");
}

override async preLoad(): Promise<void> {
Expand Down

0 comments on commit 29255ad

Please sign in to comment.