Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation tools #213

Open
wants to merge 27 commits into
base: dev
Choose a base branch
from
Open

Documentation tools #213

wants to merge 27 commits into from

Conversation

MarcoMeijer
Copy link

Being able to add documentation sources via chat, and letting the chat assistent use that as a source.

For example you can ask:
"Add "https://cplusplus.com/reference/stl/" to the documentation"

And if that was succesfull you can ask:
"What are the methods of std::string?"

"list" => doc_sources_list(ccx, tool_call_id).await,
"add" => doc_sources_add(ccx, tool_call_id, args).await,
"remove" => doc_sources_remove(ccx, tool_call_id, args).await,
_ => Err(format!("Unknown action `{}`", action))
Copy link
Member

Choose a reason for hiding this comment

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

Unknown argument action {}. Action must be one of add, remove, list


if source.starts_with("http://") || source.starts_with("https://") {
if let Some((dir, _)) = get_directory_and_file_from_url(&source) {
let dir = format!("./.refact/docs/{dir}");
Copy link
Member

Choose a reason for hiding this comment

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

why writing into ./.refact. We already have .refact directory at ~/.refact


// if the source is an url, download the page and convert it to markdown
if source.starts_with("http://") || source.starts_with("https://") {
task::spawn(add_url_to_documentation(ccx.global_context.clone(), source, 2, 40));
Copy link
Member

Choose a reason for hiding this comment

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

2, 40 be better constants defined on top of the file

let Some((dir_name, file_name)) = get_directory_and_file_from_url(&url) else {
continue; // skip this url
};
let file_path = format!("./.refact/docs/{dir_name}/{file_name}");
Copy link
Member

Choose a reason for hiding this comment

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

guessing it wouldn't work in Windows

use crate::files_in_workspace::Document;

pub async fn enqueue_all_documentation_files(gcx: Arc<ARwLock<GlobalContext>>) {
let Ok(paths) = fs::read_dir("./.refact/docs") else {
Copy link
Member

Choose a reason for hiding this comment

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

bad path

.documentation_sources
.lock()
.await
.join(",");
Copy link
Member

Choose a reason for hiding this comment

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

Personally, I'm not a fan of this writing style and we don't write in a project like this, why does it take 8 lines when it could be one single line?

@@ -98,6 +99,18 @@ tools:
description: "The exact name of a function, method, class, type alias. No spaces allowed."
parameters_required:
- "symbol"

- name: "doc_sources"
Copy link
Member

Choose a reason for hiding this comment

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

I would describe all that with a little bit more details so model would have more clue how to use it properly

};

if let Ok(origin_json) = serde_json::to_string(&origin) {
let file_path = format!("./.refact/docs/{directory}/origin.json");
Copy link
Member

Choose a reason for hiding this comment

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

don't like this path

Copy link
Member

@valaises valaises left a comment

Choose a reason for hiding this comment

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

At first glance:
Paths aren't treated well. Do not write to ./.refact, don't assume all filesystems use "/" to join paths.

To think about:

  1. Using the same "vecdb" for both documentation and code can cause problems
  2. Is filesystem a proper way to store documentation? Mb prefer a database

I'm not sure if I tooluse is a proper way to manage documentation for a user. Tooluse is rather a thing to retrieve a context for the current chat session, not to manipulate things... I'd do it as a part of Refact's WebGUI. Why would someone list documentation or delete using a chat interface?

What I see it could be used as: when user sends a message with a link in it, it would read it as a .md file and:
if file is too big: use a local vecdb search on it
if size is ok: paste to messages as is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants