Mayil-AI / bugbug-21dec23

Mozilla Public License 2.0
0 stars 0 forks source link

Deploy similarity model in the http service (hashtag861) #26

Open vikramsubramanian opened 5 months ago

vikramsubramanian commented 5 months ago

We should have an API call in the HTTP service which, given a bug, returns the most similar bugs.

We need to figure out a few things: 1) Where do we store the corpus? How big is it? 2) How do we add new bugs to the pre-existing corpus? We'll need to do it as new bugs are filed every day. )

mayil-ai[bot] commented 5 months ago

To deploy a similarity model in the HTTP service that returns the most similar bugs given a bug, you need to address the following:

1) Where do we store the corpus? How big is it?

2) How do we add new bugs to the pre-existing corpus? We'll need to do it as new bugs are filed every day.

Relevant code snippets for implementing the API call:

Pseudo code for the new API endpoint:

from flask import Flask, request, jsonify
from some_similarity_model import find_similar_bugs

app = Flask(__name__)

@app.route('/find_similar_bugs', methods=['POST'])
def find_similar_bugs_endpoint():
    data = request.get_json()
    bug_id = data.get('bug_id')
    similar_bugs = find_similar_bugs(bug_id)
    return jsonify(similar_bugs)

if __name__ == '__main__':
    app.run()

Pseudo code for updating the corpus with new bugs:

def update_corpus_with_new_bug(bug_data):
    # Transform bug_data to the format required by the similarity model
    transformed_bug = transform_bug_data(bug_data)
    # Update the corpus with the new bug
    corpus.update(transformed_bug)
    # Persist the updated corpus
    save_corpus(corpus)

def daily_corpus_update_job():
    new_bugs = get_new_bugs_since_last_update()
    for bug in new_bugs:
        update_corpus_with_new_bug(bug)

Note: Actual implementation details will depend on the specific technologies and architecture of the existing system.