Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions lua/vectorcode/integrations/codecompanion/func_calling_tool.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ return check_cli_wrap(function(opts)
auto_submit = { ls = false, query = false },
ls_on_start = false,
no_duplicate = true,
only_chunks = false,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the chunk and document options can never co-exist, maybe rename this to chunk_mode?

}, opts or {})
logger.info("Creating CodeCompanion tool with the following args:\n", opts)
local capping_message = ""
Expand Down Expand Up @@ -58,7 +59,6 @@ return check_cli_wrap(function(opts)
end

if action.command == "query" then
local args = { "query", "--pipe", "-n", tostring(action.options.count) }
if action.options.query == nil then
return {
status = "error",
Expand All @@ -68,7 +68,10 @@ return check_cli_wrap(function(opts)
if type(action.options.query) == "string" then
action.options.query = { action.options.query }
end
local args = { "query" }
vim.list_extend(args, action.options.query)
vim.list_extend(args, { "--pipe", "-n", tostring(action.options.count) })
vim.list_extend(args, { "--include", "path", "chunk", "document" })
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The chunk and document options in the --include flag are exclusive. You can have only one of them. path can stay there.

if action.options.project_root == "" then
action.options.project_root = nil
end
Expand Down Expand Up @@ -289,18 +292,34 @@ return check_cli_wrap(function(opts)
else
user_message = ""
end
local llm_message = string.format(
[[Here is a file the VectorCode tool retrieved:
local llm_message
if opts.only_chunks then
llm_message = string.format(
[[Here is a file chunk the VectorCode tool retrieved:
<path>
%s
</path>
<chunk>
%s
</chunk>
]],
file.path,
file.chunk
)
else
llm_message = string.format(
[[Here is a file the VectorCode tool retrieved:
<path>
%s
</path>
<content>
%s
</content>
]],
file.path,
file.document
)
file.path,
file.document
)
end
agent.chat:add_tool_output(self, llm_message, user_message)
agent.chat.references:add({
source = cc_common.tool_result_source,
Expand Down