Get Intent
Get Intent
"intent": "issuelist",
"question": "issue list",
"score": 0.9,
"nodes": [
{
"id": "1",
"label": "Node 1",
"x": -4.625,
"y": 62.296875,
"config": {
"responseType": "api",
"text": "",
"value": {
"apiUrl": "http://127.0.0.1:8000/jira/projects",
"apiMethod": "GET",
"apiHeaders": "",
"apiBody": ""
}
}
},
{
"id": "2",
"label": "Node 2",
"x": 91.375,
"y": 201.296875,
"config": {
"responseType": "report",
"text": "",
"value": {
"title": "Projects",
"datafield": "{{issuelist#1}}",
"summary": "List of Projects",
"columns": [
{
"key": "value[0].name",
"label": "name"
}
]
}
}
}
],
"links": [
{
"from": "1",
"to": "2"
}
]
},
{
"intent": "projects",
"question": "show projects",
"score": 1.5,
"nodes": [
{
"id": "1",
"label": "Node 1",
"x": 89.75,
"y": 98.203125,
"config": {
"responseType": "api",
"text": "",
"value": {
"apiUrl": "http://127.0.0.1:8000/jira/projects",
"apiMethod": "GET",
"apiHeaders": "",
"apiBody": ""
}
}
},
{
"id": "2",
"label": "Node 2",
"x": 94.75,
"y": 205.203125,
"config": {
"responseType": "form",
"text": "",
"value": [
{
"label": "Project",
"type": "dropdown",
"required": false,
"options": "",
"optionsType": "dynamic",
"datafield": "{{projects#1}}.value",
"datakey": "key",
"datalabel": "name"
}
]
}
},
{
"id": "3",
"label": "Node 3",
"x": 95.75,
"y": 299.203125,
"config": {
"responseType": "api",
"text": "",
"value": {
"apiUrl": "http://127.0.0.1:8000/jira/search_issues?
jql=project='{{projects#2}}.Project'",
"apiMethod": "GET",
"apiHeaders": "",
"apiBody": ""
}
}
},
{
"id": "4",
"label": "Node 4",
"x": 93.75,
"y": 408.203125,
"config": {
"responseType": "report",
"text": "",
"value": {
"title": "Issues",
"datafield": "{{projects#3}}.value.issues",
"summary": "Issuelist",
"columns": [
{
"key": "key",
"label": "Task ID"
},
{
"key": "fields.summary",
"label": "Task Summary"
},
{
"key": "fields.description",
"label": "Description"
},
{
"key": "fields.assignee.displayName",
"label": "Assignee"
},
{
"key": "fields.status.name",
"label": "Status"
},
{
"key": "fields.priority.name",
"label": "Priority"
},
{
"key": "fields.duedate",
"label": "Due Date"
},
{
"key": "fields.created",
"label": "Created Date"
},
{
"key": "fields.resolutiondate",
"label": "Resolved Date"
},
{
"key": "fields.timespent",
"label": "Time Spent"
},
{
"key": "fields.issuetype.name",
"label": "Issue Type"
}
]
}
}
}
],
"links": [
{
"from": "1",
"to": "2"
},
{
"from": "2",
"to": "3"
},
{
"from": "3",
"to": "4"
}
]
},
import nltk
from sentence_transformers import SentenceTransformer, util
import numpy as np
nltk.download('stopwords')
from nltk.corpus import stopwords
similarities = util.pytorch_cos_sim(input_embedding,
intent_embeddings).squeeze(0)
best_idx = torch.argmax(similarities).item()
best_intent = intents[best_idx]
#print(intent["score"])
intent_embedding = model.encode(intent["question"], convert_to_tensor=True)
similarity = util.pytorch_cos_sim(input_embedding, intent_embedding).item()
#print(similarity)
if similarity >= intent["score"] and similarity > best_score:
best_score = similarity
best_intent = intent["intent"]
return intent