Ниже приведен мой сценарий для javascript получить данные от пользователя
Код: Выделить всё
document.addEventListener("DOMContentLoaded", function () {
const form = document.getElementById("jqlForm");
form.addEventListener("submit", function (event) {
event.preventDefault();
const project = document.getElementById("project").value.trim();
const sprint = document.getElementById("sprint").value.trim();
const story = document.getElementById("story").value.trim();
let jql = `project = ${project} AND sprint = ${sprint}`;
if (story) {
jql += ` AND issuekey ~ "${story}"`;
}
const jqlInput = document.createElement("input");
jqlInput.type = "hidden";
jqlInput.name = "jql";
jqlInput.value = jql;
form.appendChild(jqlInput);
form.submit();
});
});
Код: Выделить всё
from flask import Flask, render_template, request
import openai
from jira import JIRA
app = Flask(__name__)
JIRA_ACCESS_TOKEN = "myToken"
JIRA_URL = "https://JIRAURL.atlassian.net/"
OPENAI_TOKEN = "openAIToken"
openai.api_key = OPENAI_TOKEN
@app.route("/")
def index():
return render_template("index.html")
def generate_summary(prompt, model="gpt-3.5-turbo"):
try:
response = openai.ChatCompletion.create(
model=model,
messages=[{"role": "user", "content": prompt}],
max_tokens=150, # Adjust based on your needs
temperature=0.5, # Adjust for creativity
top_p=0.9 # Adjust for diversity
)
return response.choices[0].message["content"].strip()
except Exception as e:
print(f"An error occurred: {e}")
return "Error: Unable to process request."
def get_sprint_context(sprint_summary, sprint):
prompt = f"You are going to read a list of summary of defect tickets. I want you to analyze the list of defects encountered during {sprint} and provide a summary focusing on which area of the application has more problems, using project management language. Do not use bullet points and in short summary highlight the facts about problematic areas of my application."
return generate_summary(f"List of defects: {sprint_summary}\n\n{prompt}")
def call_gpt(jira_ticket):
prompt = f"This is the response from JIRA getIssue platform API. I want you to give a detailed analysis of this JIRA ticket: {jira_ticket}"
return generate_summary(prompt)
@app.route("/sprint", methods=['POST'])
def sprint_context():
if request.method == 'POST':
jql = request.form.get("jql") # Receive the JQL string from the frontend
sprint = request.form.get("sprint")
if jql and sprint:
jira_client = JIRA(JIRA_URL, basic_auth=("authEmail@gmail.com", JIRA_ACCESS_TOKEN))
issues = jira_client.search_issues(jql)
summary = [issue.fields.summary for issue in issues]
sprint_context = get_sprint_context(summary, sprint)
return render_template('summary.html', my_string=sprint_context)
else:
return "Missing JQL or Sprint data", 400
return "Invalid Request", 400
if __name__ == "__main__":
app.run(debug=True)
Подробнее здесь: https://stackoverflow.com/questions/789 ... ntegration
Мобильная версия