Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve #23

Open
wants to merge 54 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
6e0917b
Added Dev Container Folder
vaseramin777 Jan 27, 2024
7903ee9
how to install
vaseramin777 Feb 19, 2024
90fa1f3
how to install
vaseramin777 Feb 19, 2024
796a4d3
how to install
vaseramin777 Feb 19, 2024
5bda6d8
how to install
vaseramin777 Feb 19, 2024
1558cbe
how to install
vaseramin777 Feb 19, 2024
945abf0
how to install
vaseramin777 Feb 19, 2024
7ab3ff3
how to install
vaseramin777 Feb 19, 2024
0741ab8
how to install
vaseramin777 Feb 19, 2024
b1f5931
how to install
vaseramin777 Feb 19, 2024
ccd9390
how to install
vaseramin777 Feb 19, 2024
7eda6b1
how to install
vaseramin777 Feb 19, 2024
430ded0
how to install
vaseramin777 Feb 19, 2024
c903ba0
how to install
vaseramin777 Feb 19, 2024
91d4d04
how to install
vaseramin777 Feb 19, 2024
392b845
how to install
vaseramin777 Feb 19, 2024
e36b7b9
how to install
vaseramin777 Feb 19, 2024
ff09355
how to install
vaseramin777 Feb 19, 2024
c64baa0
how to install
vaseramin777 Feb 19, 2024
54b1d6d
how to install
vaseramin777 Feb 19, 2024
cb94ca7
how to install
vaseramin777 Feb 19, 2024
9831b7a
how to install
vaseramin777 Feb 19, 2024
677aedf
how to install
vaseramin777 Feb 19, 2024
9d0d482
how to install
vaseramin777 Feb 19, 2024
3c0ffc8
how to install
vaseramin777 Feb 19, 2024
81c1c1a
how to install
vaseramin777 Feb 19, 2024
7a25aba
how to install
vaseramin777 Feb 19, 2024
d907b2a
how to install
vaseramin777 Feb 19, 2024
75a2b49
how to install
vaseramin777 Feb 19, 2024
9b58811
start
vaseramin777 Feb 19, 2024
b5cb52d
how to install
vaseramin777 Feb 19, 2024
4bb83b1
start
vaseramin777 Feb 19, 2024
f2923e9
start
vaseramin777 Feb 19, 2024
f0eb8a6
improve
vaseramin777 Mar 21, 2024
5b20ea8
improve
vaseramin777 Mar 21, 2024
7fd8d1b
improve
vaseramin777 Mar 21, 2024
1f8f24b
improve
vaseramin777 Mar 21, 2024
80461c5
improve
vaseramin777 Mar 21, 2024
afaea3d
improve
vaseramin777 Mar 21, 2024
081134d
improve
vaseramin777 Mar 21, 2024
8f8abfa
improve
vaseramin777 Mar 21, 2024
2e748f7
improve
vaseramin777 Mar 21, 2024
fefa6b1
improve
vaseramin777 Mar 21, 2024
e73ba9a
improve
vaseramin777 Mar 21, 2024
2808496
improve
vaseramin777 Mar 21, 2024
4f92bc5
improve
vaseramin777 Mar 21, 2024
f52f756
improve
vaseramin777 Mar 21, 2024
25811ce
improve
vaseramin777 Mar 21, 2024
eb0947c
improve
vaseramin777 Mar 21, 2024
62fed97
improve
vaseramin777 Mar 21, 2024
1ed696d
improve
vaseramin777 Mar 21, 2024
a4088b6
improve
vaseramin777 Mar 21, 2024
c18917f
improve
vaseramin777 Mar 21, 2024
fd9664d
ss
vaseramin777 Mar 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .codesandbox/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// These tasks will run in order when initializing your CodeSandbox project.
"setupTasks": [],

// These tasks can be run from CodeSandbox. Running one will open a log in the app.
"tasks": {}
}
33 changes: 33 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye",
"customizations": {
"codespaces": {
"openFiles": [
"README.md",
"hackGPT.py"
]
},
"vscode": {
"settings": {},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance"
]
}
},
"updateContentCommand": "[ -f packages.txt ] && sudo apt update && sudo apt upgrade -y && sudo xargs apt install -y <packages.txt; [ -f requirements.txt ] && pip3 install --user -r requirements.txt; pip3 install --user streamlit; echo '✅ Packages installed and Requirements met'",
"postAttachCommand": {
"server": "streamlit run hackGPT.py --server.enableCORS false --server.enableXsrfProtection false"
},
"portsAttributes": {
"8501": {
"label": "Application",
"onAutoForward": "openPreview"
}
},
"forwardPorts": [
8501
]
}
15 changes: 10 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
def fibonacci(n):
sequence = []
a, b = 0, 1
while a < n:
sequence.append(a)
a, b = b, a + b
return sequence

.DS_Store

.vscode/settings.json

.env
n = int(input("Enter a number: "))
print(f"The Fibonacci sequence up to {n} is:")
print(fibonacci(n))
173 changes: 47 additions & 126 deletions JIRA_hackGPT.py
Original file line number Diff line number Diff line change
@@ -1,134 +1,52 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from dotenv import load_dotenv
import sys
import fade
from pathlib import Path
import openai
from time import sleep
# -*- coding: utf-8 -*,- Encoding declaration for non-ASCII characters

import os
import fade
from pathlib import Path
import openai
import fade # Unknown import, possibly custom or unnecessary
import requests
import urllib.parse
import urllib.request
import openai
from dotenv import load_dotenv
import gradio as gr
import pandas as pd
import matplotlib.pyplot as plt
import json
import csv
import datetime
import argparse
from prettytable.colortable import ColorTable, Themes
from prettytable import from_csv
from jira import JIRA
# Load API key from an environment variable or secret management service

import urllib.parse as urlparse # Parse URLs
import urllib.request as urlrequest # Make HTTP requests
import openai # Interact with OpenAI API
import pandas as pd # Data manipulation and analysis
import matplotlib.pyplot as plt # Data visualization
import json # Work with JSON data
import csv # Work with CSV files
import datetime as dt # Date and time manipulation
import argparse # Command line argument parsing

from prettytable import from_csv, ColorTable, Themes # Data display
from jira import JIRA # Interact with JIRA

# Load API key from environment variable or secret management service
load_dotenv(".env")
apiToken = os.environ.get('OPENAI_TOKEN')
jira_token = os.environ.get('JIRA_TOKEN')
openai.api_key = apiToken


if 'OPENAI_TOKEN' in os.environ:
openai_token = os.environ['OPENAI_TOKEN']

elif 'JIRA_USER' in os.environ:

jira_pass = os.environ['JIRA_TOKEN']
else:
error='''
* ) ) (
`( ( /(( ( ( )\
)\( )\())\ ( )\))( ((((_)
((_)\ (_))((_) )\ ) (( ))\ )\)
8"""" 8"""8 8"""8 8"""88 8"""8
8 8 8 8 8 8 8 8 8
8eeee 8eee8e 8eee8e 8 8 8eee8e
88 88 8 88 8 8 8 88 8
88 88 8 88 8 8 8 88 8
88eee 88 8 88 8 8eeee8 88 8

\033[1;33mAttempting to Set OpenAI and JIRA system variable with API key.'''
fadederror = fade.fire(error)
print(fadederror)
Path(".env").touch()
setting_token = open(".env", "a")
userkey = input('Enter OpenAI API Key: ').replace(" ","")
setting_token.write("OPENAI_TOKEN="+'"'+userkey+'"\n')
#https://id.atlassian.com/manage-profile/security/api-tokens
jiratoken = input('Enter JIRA Token: ').replace(" ","")
setting_token.write("JIRA_TOKEN="+'"'+jiratoken+'"\n')


date_string = datetime.datetime.now()

load_dotenv()
apiToken = os.environ.get("OPENAI_TOKEN")
headers = {
"Accept": "application/json; charset=utf-8",
"Authorization": "Token" + str(apiToken)
}



if 'OPENAI_TOKEN' in os.environ:
pass
else:
os.environ['OPENAI_TOKEN'] = input('Enter API Key: ').replace(" ","")
token = os.environ.get("OPENAI_TOKEN")
hack= "\n"*7 + r"""



|¯¯¯¯| |¯¯¯¯| '/¯¯¯/.\¯¯¯\‚ '/¯¯¯¯/\¯¯¯¯\ |¯¯¯¯| |¯¯¯¯|
|:·.·|_|:·.·| |:·.·|_|:·.·| |:·.·| |____| |:·.·|./____/
|:·.·|¯|:·.·| |:·.·|¯|:·.·| |:·.·|__|¯¯¯¯| |:·.·|.\¯¯¯¯\
|____| |____| |____|:|____| \__ _\/____/ |____| |_____|


""" + "\n"*12

gpt = "\n"*4 +r"""

______ _______ ________
/ \| \| \
| ▓▓▓▓▓▓\ ▓▓▓▓▓▓▓\\▓▓▓▓▓▓▓▓
| ▓▓ __\▓▓ ▓▓__/ ▓▓ | ▓▓
| ▓▓| \ ▓▓ ▓▓ | ▓▓
| ▓▓ \▓▓▓▓ ▓▓▓▓▓▓▓ | ▓▓
| ▓▓__| ▓▓ ▓▓ | ▓▓
\▓▓ ▓▓ ▓▓ | ▓▓
\▓▓▓▓▓▓ \▓▓ \▓▓
"""

fadedhack = fade.water(hack)
fadedgpt = fade.random(gpt)


for pair in zip(*map(str.splitlines, (fadedhack, fadedgpt))):
print(*pair)
api_token = os.getenv("OPENAI_TOKEN")
jira_token = os.getenv("JIRA_TOKEN")
openai.api_key = api_token

# Authenticate with JIRA
#jira_url = input("Enter JIRA URL: ")
jira_options = {'server': 'YOUR_JIRA_URL'}
jira = JIRA(options=jira_options, basic_auth=('YOUR_JIRA_EMAIL', 'YOUR_JIRA_TOKEN'))
jira_options = {'server': 'YOUR_JIRA_URL'}
jira = JIRA(options=jira_options, basic_auth=('YOUR_JIRA_EMAIL', jira_token))

# Fetch all open bugs from JIRA
issues = jira.search_issues('type = bug')

issues = jira.search_issues('type = bug ')
# Iterate through each issue
for issue in issues:
ticket = fade.brazil("JIRA Ticket Summary: ")
summary = fade.water(issue.fields.summary)
# Print JIRA ticket summary
ticket = f"JIRA Ticket Summary: {issue.fields.summary}"
print(fade.water(ticket))

# Print issue description
description = fade.water(issue.fields.description)
des_summary = fade.brazil("Issue description: ")
print(ticket.rstrip('\n') + summary)
print(des_summary.rstrip('\n'))
print(description)
print(fade.water(description))

# Generate a prompt for the issue
prompt = f"Fix the following issue: {issue.fields.description}"

# Set the OpenAI model engine
model_engine = "davinci"

# Generate a solution using OpenAI
completions = openai.Completion.create(
engine=model_engine,
prompt=prompt,
Expand All @@ -137,14 +55,17 @@
stop=None,
temperature=0.7,
)
solution = fade.brazil("Genrating solution and adding to : ")
print (solution)

# Print the generated solution
solution = fade.brazil("Generating solution and adding to JIRA: ")
print(fade.brazil(solution))
print("Sample: " + completions.choices[0].text[:40])

# Add the solution as a comment to the JIRA issue
response = completions.choices[0].text
jira.add_comment(issue.key, response)

#with open('output/JIRA_hackGPT_log.csv', 'a+', encoding='UTF8', newline='') as f:
# w = csv.writer(f, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
# w.writerow([date_string, {issue.fields.description}, str(response).lstrip('\n')])
# f.close()

# Log the issue and solution to a CSV file
# with open('output/JIRA_hackGPT_log.csv', 'a+', encoding='UTF8', newline='') as f:
# w = csv.writer(f, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
# w.writerow([dt.datetime.now(), issue.fields.description, response])
Loading