File size: 1,800 Bytes
b30ed6a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from jira.client import JIRA
import pandas as pd

def get_details(project_id):
        # Specify a server key. It should be your
    # domain name link. yourdomainname.atlassian.net
    jiraOptions = {'server': "https://srikanthnm.atlassian.net"}
    
    # Get a JIRA client instance, pass,
    # Authentication parameters
    # and the Server name.
    # emailID = your emailID
    # token = token you receive after registration
    jira = JIRA(options=jiraOptions, basic_auth=(
        "[email protected]", "ATATT3xFfGF09rugcjiT06v8xMayt5ggayMNiwz4b6w07PWQxPvpi4fMDzwwHxKt-v8dGx49uiulIMKHUUYroeS8cXvMKYfi7sQnFsYNfGslPVqSq1BQrzPhTio-xmYOHcit5ijzU9cSGGa7eLXUMxQTsSQjLhtZ-EQPI8h6aki690_-evLFZmU=3910FFD4"))
    
    # Search all issues mentioned against a project name.
    lstKeys = []
    lstSummary = []
    lstReporter = []
    for singleIssue in jira.search_issues(jql_str=f'project = {project_id}'):
        lstKeys.append(singleIssue.key)
        lstSummary.append(singleIssue.fields.summary)
        lstReporter.append(singleIssue.fields.assignee.displayName)

    df_output = pd.DataFrame()
    df_output['Key'] = lstKeys
    df_output['Summary'] = lstSummary
    df_output['Assignee'] = lstReporter

    df_output.to_csv('jira.csv', index=False)

    return df_output

def ask_question(strQuery):
    from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
    import pandas as pd

    tokenizer = AutoTokenizer.from_pretrained("Yale-LILY/reastap-large")
    model = AutoModelForSeq2SeqLM.from_pretrained("Yale-LILY/reastap-large")

    table = pd.read_csv("jira.csv")

    query = strQuery
    encoding = tokenizer(table=table, query=query, return_tensors="pt")

    outputs = model.generate(**encoding)

    return (tokenizer.batch_decode(outputs, skip_special_tokens=True)[0])