Skip to content

[WIP] New Link Creation Agent processors #310

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

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

eddiebrissow
Copy link
Collaborator

@eddiebrissow eddiebrissow commented Mar 20, 2025

Missing processor's implementation;

@eddiebrissow eddiebrissow self-assigned this Mar 20, 2025
Copy link
Contributor

@andre-senna andre-senna left a comment

Choose a reason for hiding this comment

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

See comments in the dev channel

@andre-senna andre-senna self-requested a review March 25, 2025 10:48
Copy link
Contributor

@andre-senna andre-senna left a comment

Choose a reason for hiding this comment

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

There are two things in this new design that I think new to be changed.

(1) Processor are designed to deal with 1 single QueryAnswer. This is bad because we'd need to instantiate one processor for each QueryAnswer and this is a totally unnecessary overhead. And a pointless one, in my opinion, since it doesn't make the design simpler. Processors don't keep any data (or they shouldn't) so the best design here is to instantiate them only once in agent's constructor and use them to process QueryAnswers of multiple requests.

(2) Creation and returning of the created links are split into three methods making the whole process asynchronous. This introduce unnecessary overhead and complexity. I believe the need to tho this is because of the point (1) above. So I think that solving (1) will make it easier to solve (2).

NOTE: to address (1) and (2) we'd need to change the method signature to something like:

    virtual virtual std::vector<std::vector<std::string>> process(QueryAnswer* query_answer);

Which kind of merge the functionality of current constructor, process() and get_links().

Comment on lines 27 to 37
vector<vector<string>> link_tokens;
if (LinkCreationProcessor::get_processor_type(link_template.front()) ==
ProcessorType::PROOF_OF_IMPLICATION) {
link_tokens = implication_processor.process(query_answer, link_template);
}else if (LinkCreationProcessor::get_processor_type(link_template.front()) ==
ProcessorType::PROOF_OF_EQUIVALENCE) {
link_tokens = equivalence_processor.process(query_answer, link_template);
}else {
link_tokens = link_template_processor.process(query_answer, link_template);
}
this->create_link(link_tokens, *das_client);
Copy link
Collaborator

Choose a reason for hiding this comment

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

                vector<vector<string>> link_tokens;
                auto processor_type = \
                    LinkCreationProcessor::get_processor_type(link_template.front());
                if (processor_type == ProcessorType::PROOF_OF_IMPLICATION) {
                    link_tokens = \
                        implication_processor.process(query_answer, link_template);
                } else if (processor_type == ProcessorType::PROOF_OF_EQUIVALENCE) {
                    link_tokens = \
                        equivalence_processor.process(query_answer, link_template);
                } else {
                    link_tokens = \
                        link_template_processor.process(query_answer, link_template);
                }
                this->create_link(link_tokens, *das_client);

std::vector<std::vector<std::string>> LinkTemplateProcessor::process(
QueryAnswer* query_answer, std::optional<std::vector<std::string>> config) {
std::vector<shared_ptr<Link>> links;
if(config != std::nullopt){
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's an optional but cannot be nullopt?

Comment on lines 12 to 26
if(config != std::nullopt){
if (config.value().front() == "LIST") {
LinkCreateTemplateList link_create_template_list(config.value());
for (auto link_template : link_create_template_list.get_templates()) {
shared_ptr<Link> link = process_template_request(query_answer, link_template);
links.push_back(link);
}
} else {
LinkCreateTemplate link_template(config.value());
shared_ptr<Link> link = process_template_request(query_answer, link_template);
links.push_back(link);
}
} else{
throw runtime_error("Invalid link template");
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

        if (config == std::nullopt) {
            throw runtime_error("Invalid link template");
        }
        if (config.value().front() == "LIST") {
            LinkCreateTemplateList link_create_template_list(config.value());
            for (auto link_template : link_create_template_list.get_templates()) {
                auto link = \
                    process_template_request(query_answer, link_template);
                links.push_back(link);
            }
        } else {
            LinkCreateTemplate link_template(config.value());
            auto link = \
                process_template_request(query_answer, link_template);
            links.push_back(link);
        }

@angeloprobst
Copy link
Collaborator

Please, check the functions params for const-ness and referencing.

Also, if possible, add using namespace std; to the top of the file and remove std:: from the middle of the code to make it cleaner.

@eddiebrissow eddiebrissow changed the title [#232] Added support for new processors [WP] New Link Creation Agent processors Apr 1, 2025
@eddiebrissow eddiebrissow changed the title [WP] New Link Creation Agent processors [WIP] New Link Creation Agent processors Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants