This tutorial shows you how ping the microservice that allows you to retrieve an embedding given an issue title and body. This notebook is available on GitHub.
In [1]:
import requests
import json
import numpy as np
from passlib.apps import custom_app_context as pwd_context
API_ENDPOINT = 'https://embeddings.gh-issue-labeler.com/text'
API_KEY = 'YOUR_API_KEY' # Contact maintainers for your api key
https://embeddings.gh-issue-labeler.com/textAllows you to get embeddings for the raw text corresponding to a single GitHub issue. The motivation for this endpoint is to use this at inference time, for example, when you need to perform computation on a new issue.
This endpoint listens to POST requests, with the payload illustrated below:
In [2]:
data = {'title': 'Fix the issue',
'body': 'I am encountering an error\n when trying to push the button.'}
# sending post request and saving response as response object
r = requests.post(url=API_ENDPOINT,
headers={'Token':pwd_context.hash(API_KEY)},
json=data)
Convert byte stream sent over REST back to a numpy array. The numpy array is a 2,400 dimensional embedding which are latent features of the GitHub Issue.
In [5]:
embeddings = np.frombuffer(r.content, dtype='<f4')
embeddings.shape
Out[5]: