Skip to content

Commit

Permalink
AI Feature (#687)
Browse files Browse the repository at this point in the history
* first basic functionality of the ai feature works

* Google Java Format

* add poetry dependency file

* add test property for python container, test classes

* Google Java Format

* improve design of markdown, userstories & add markdown to member

* add title functionality + style, improve Codebase

* styling of the description improved, removed overflow for ai buttons

* logic for description, styling of description, modal, title

* add AiControllerTest Logic

* Google Java Format

* add grammar check logic + JUnitTests Backend, add spinner to fe,

* Google Java Format

* add PyTest to Python Container

* change prettier to warn

* add confidental masking for grammar check

* Google Java Format

* add confidental masking for description, add jira2md converter, us.id is now a string

* Google Java Format

* privacy modal added, 3 categories of confidential data, tried few-shot prompting

* Google Java Format

* added language selector to privacy modal for better prompting results

* Google Java Format

* added user story estimation feature, translation

* Google Java Format

* add cancel button translation

* prompts are now in extra files, add docker env variable

* remove docker env, and logic for python service

* improve modal design, functionality

* fix deletion bug

* splitting a user story now works

* Google Java Format

* improve optic of split feature

* improve german prompt & design of splitting modal

* fix title bug, remove unnecessary variable

* fix deletion bug for splitted User Stories

* improve title prompt_title.txt

* fix prompt_grammar_check.txt

* adjust styling of modal

* add function to check if api key exists

* Google Java Format

* increase max_tokens for prompts

* fix two prompting mistakes

* marking important content now works

* Google Java Format

* remove unnecessary prints

* add ai container to pipeline

* fix: merge conflicts & remove cat gif

* add ai container to docker

---------

Co-authored-by: github-actions <>
Co-authored-by: Till Wanner <[email protected]>
  • Loading branch information
SponsoredByPuma and Till Wanner authored Aug 7, 2024
1 parent a4b00ae commit 7bdd9c4
Show file tree
Hide file tree
Showing 60 changed files with 3,032 additions and 235 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/diveni-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- 'backend/**'
- 'frontend/**'
- 'proxy/**'
- 'ai/**'
- '.github/workflows/diveni-deploy.yaml'
workflow_dispatch:

Expand All @@ -18,7 +19,7 @@ jobs:
strategy:
fail-fast: false
matrix:
service: [backend, frontend, proxy]
service: [ai, backend, frontend, proxy]
permissions:
contents: read
packages: write
Expand Down
14 changes: 14 additions & 0 deletions ai/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM python:3.11.2

WORKDIR /ai

RUN pip install poetry

COPY . .

RUN poetry install
RUN poetry self add poetry-dotenv-plugin

EXPOSE 8000

CMD ["poetry","run", "uvicorn", "controller.gpt_controller:app", "--host", "0.0.0.0", "--port", "8000"]
2 changes: 2 additions & 0 deletions ai/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This is our python container, used for the communication between our Java Spring Boot Backend
and the openAI API.
63 changes: 63 additions & 0 deletions ai/controller/gpt_controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from fastapi import FastAPI
import service.gpt_service as service
from dto.user_story import UserStory
from dto.title import Title
from dto.estimation_data import Estimation_data

app = FastAPI()


@app.post("/improve-title")
async def improve_title(title: Title):
print("gpt_controller: --> improve_title(), title={", title.name, "}")
response = await service.improve_title(title.name, title.confidential_data)
print("gpt_controller: <-- improve_title()")
return {"improvedTitle": response}


@app.post("/improve-description")
async def improve_description(data: UserStory):
print("gpt_controller: --> improve_description(), description={", data, "}")
response = await service.improve_description(data)
print("gpt_controller: <-- improve_description()")
return {"improved_description": response.description, "improved_acceptance_criteria": response.acceptance_criteria}


@app.post("/grammar-check")
async def grammar_check(data: UserStory):
print("gpt_controller: --> grammar_check(), description={", data, "}")
response = await service.grammar_check(data)
print("gpt_controller: <-- grammar_check()")
return {"improved_description": response}


@app.post("/estimate-user-story")
async def estimate_user_story(data: Estimation_data):
print("gpt_controller: --> estimate_user_story(), data={", data, "}")
response = await service.estimate_user_story(data)
print("gpt_controller: <-- estimate_user_story()")
return {"estimation": response}


@app.post("/split-user-story")
async def split_user_story(data: UserStory):
print("gpt_controller: --> split_user_story(), data={", data, "}")
response = await service.split_user_story(data)
print("gpt_controller: <-- split_user_story()")
return {"new_user_stories": response}


@app.post("/mark-description")
async def mark_description(data: UserStory):
print("gpt_controller: --> mark_description(), data={", data, "}")
response = await service.mark_description(data)
print("gpt_controller: <-- mark_description()")
return {"description": response}


@app.get("/check-api-key")
def check_api_key():
print("gpt_controller: --> check_api_key()")
response = service.check_api_key()
print("gpt_controller: <-- check_api_key()")
return {"has_api_key": response}
7 changes: 7 additions & 0 deletions ai/dto/description_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Description_Response:
description: str
acceptance_criteria: list

def __init__(self, description, acceptance_criteria):
self.description = description
self.acceptance_criteria = acceptance_criteria
8 changes: 8 additions & 0 deletions ai/dto/estimation_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from pydantic import BaseModel


class Estimation_data(BaseModel):
title: str
description: str
voteSet: list
confidential_data: dict
6 changes: 6 additions & 0 deletions ai/dto/title.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from pydantic import BaseModel


class Title(BaseModel):
name: str
confidential_data: dict
8 changes: 8 additions & 0 deletions ai/dto/user_story.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from pydantic import BaseModel


class UserStory(BaseModel):
title: str
description: str
language: str
confidential_data: dict
24 changes: 24 additions & 0 deletions ai/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[tool.poetry]
name = "ai"
version = "0.1.0"
description = ""
authors = ["SponsoredByPuma"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"
fastapi = "^0.110.0"
uvicorn = "^0.28.0"
openai = "^1.13.3"
pytest = "^8.1.1"
mock = "^5.1.0"


[tool.poetry.group.dev.dependencies]
pytest = "^8.1.1"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

100 changes: 100 additions & 0 deletions ai/resource/names.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
Alice Johnson
Benjamin Lee
Catherine Adams
David Martinez
Ella Thompson
Franklin White
Grace Robinson
Henry Harris
Isabella Turner
James Edwards
Katherine Scott
Liam Walker
Mia Lewis
Noah Hall
Olivia Green
Patrick Carter
Quinn Foster
Rachel King
Samuel Miller
Taylor Allen
Victoria Young
William Brown
Zoe Adams
Alexander Clark
Brooklyn Hill
Christopher Turner
Daisy Martinez
Ethan Johnson
Faith Robinson
Gabriel Lee
Hannah White
Isaac Harris
Jasmine Thompson
Kevin Edwards
Lily Scott
Mason Walker
Nora Lewis
Owen Hall
Penelope Green
Quentin Foster
Ruby King
Sebastian Miller
Tessa Allen
Ulysses Young
Violet Brown
Wyatt Adams
Xander Clark
Yara Hill
Zachary Turner
Ava Carter
Bryce Foster
Chloe Robinson
Daniel Lee
Emily Harris
Finn Thompson
Grace Turner
Henry Walker
Isabella Green
Jacob Hall
Kylie Scott
Liam Young
Mila Adams
Nathan Clark
Olivia Hill
Parker Foster
Quinn Lewis
Ryan Martinez
Sophia Turner
Thomas Edwards
Uma Robinson
Vincent Lee
Willow Harris
Xavier Thompson
Yasmine Turner
Zara Walker
Adam Green
Bella Hall
Caleb Scott
Diana Young
Eli Adams
Fiona Clark
George Hill
Hazel Foster
Ian Lewis
Jade Martinez
Kai Turner
Luna Edwards
Max Robinson
Nina Lee
Oscar Harris
Paige Thompson
Quincy Walker
Riley Green
Sofia Hall
Theo Scott
Una Young
Vera Adams
Wyatt Clark
Xena Hill
Yuki Foster
13 changes: 13 additions & 0 deletions ai/resource/prompts/prompt_estimation_fibo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Task: Send a JSON with "estimation" and estimate the effort for this user story: Title: filter numbers out of the input field
Description: The existing Backend Service should filter numbers out of the input, since the system crashes with numbers.
Valid Options are: ['1','2','3','5','8','13','21']
Answer: {"estimation": "2"}
Task: Send a JSON with "estimation" and estimate the effort for this user story: Title: Create a webapp like amazon
Description: Our Company should have a web application like amazon, but better
## Acceptance Criteria:
* robust and fast backend with java
* good looking design
* nosql database should be implemented
Valid Options are: ['1','2','3','5','8','13','21']
Answer: {"estimation": "21"}
Task: Send a JSON with "estimation" and estimate the effort for this user story: Title:
13 changes: 13 additions & 0 deletions ai/resource/prompts/prompt_estimation_hour.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Task: Send a JSON with "estimation" and estimate the effort for this user story: Title: filter numbers out of the input field
Description: The existing Backend Service should filter numbers out of the input, since the system crashes with numbers.
Valid Options are: ['1','2','3','4','5','6','8','10','12','16']
Answer: {"estimation": "2"}
Task: Send a JSON with "estimation" and estimate the effort for this user story: Title: Create a webapp like amazon
Description: Our Company should have a web application like amazon, but better
## Acceptance Criteria:
* robust and fast backend with java
* good looking design
* nosql database should be implemented
Valid Options are: ['1','2','3','4','5','6','8','10','12','16']
Answer: {"estimation": "16"}
Task: Send a JSON with "estimation" and estimate the effort for this user story: Title:
13 changes: 13 additions & 0 deletions ai/resource/prompts/prompt_estimation_number.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Task: Send a JSON with "estimation" and estimate the effort for this user story: Title: filter numbers out of the input field
Description: The existing Backend Service should filter numbers out of the input, since the system crashes with numbers.
Valid Options are: ['1','2','3','4','5','6','7','8','9','10']
Answer: {"estimation": "2"}
Task: Send a JSON with "estimation" and estimate the effort for this user story: Title: Create a webapp like amazon
Description: Our Company should have a web application like amazon, but better
## Acceptance Criteria:
* robust and fast backend with java
* good looking design
* nosql database should be implemented
Valid Options are: ['1','2','3','4','5','6','7','8','9','10']
Answer: {"estimation": "10"}
Task: Send a JSON with "estimation" and estimate the effort for this user story: Title:
13 changes: 13 additions & 0 deletions ai/resource/prompts/prompt_estimation_shirt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Task: Send a JSON with "estimation" and estimate the effort for this user story: Title: filter numbers out of the input field
Description: The existing Backend Service should filter numbers out of the input, since the system crashes with numbers.
Valid Options are: ['XS','S','M','L','XL']
Answer: {"estimation": "S"}
Task: Send a JSON with "estimation" and estimate the effort for this user story: Title: Create a webapp like amazon
Description: Our Company should have a web application like amazon, but better
## Acceptance Criteria:
* robust and fast backend with java
* good looking design
* nosql database should be implemented
Valid Options are: ['XS','S','M','L','XL']
Answer: {"estimation": "XL"}
Task: Send a JSON with "estimation" and estimate the effort for this user story: Title:
11 changes: 11 additions & 0 deletions ai/resource/prompts/prompt_grammar_check.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Task: Send a JSON with "description" & "acceptance_criteria" and fix grammar & syntax mistakes, but do not add new elements, for this markdown-text: As a user i want 2 be able to accessed a homepage so that I can easily navigate to different sections of the website.
##### Acceptance Criteria:
* The homepage should have a visualy appealing design.
* The homepage should have an clear and concise navigation menü
Solution: {"description" : "As a user, I want to be able to access a homepage so that I can easily navigate to different sections of the website.
##### Acceptance Criteria:\n ",
"acceptance_criteria" : ["* The homepage should have a visually appealing design.","* The homepage should have a clear and concise navigation menu."]}
Task: Send a JSON with "description" & "acceptance_criteria" and fix grammar & syntax mistakes, but do not add new elements, for this markdown-text: As a devloper, i want to crete a backend servize with a REST API so dhat i can easily manage and manipulate dayta from the database
Solution: {"description" : "As a developer, I want to create a backend service with a REST API so that I can easily manage and manipulate data from the database.",
"acceptance_criteria" : []}
Task: Send a JSON with "description" & "acceptance_criteria" and fix grammar & syntax mistakes, but do not add new elements, for this markdown-text:
18 changes: 18 additions & 0 deletions ai/resource/prompts/prompt_improve_description.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Task: Send JSON with "description" & "acceptance_criteria" for this User Story: create rest service for backend
Solution: {"description" : "As a developer, I want to create a REST service for the backend so that I can easily access and manipulate data from the database.",
"acceptance_criteria" : ["
"The REST service should have endpoints for GET, POST, PUT & DELETE requests",
"Unit Tests should be written"]}
Task: Send JSON with "description" & "acceptance_criteria" for this User Story: create Homepage
Solution: {"description" : "As a user, I want to be able to access a homepage so that I can easily navigate to different sections of the website.",
"acceptance_criteria" : ["The homepage should have a visually appealing design.", "The homepage should have a clear and concise navigation menu.", "It should have a search bar for easy navigation.","The homepage should be accessible on different devices."]}
Task: Send JSON with "description" & "acceptance_criteria" for this User Story: create a homepage for placerholder-company-1 with a java backend. It should not cost more than 100 thousand euros
### Acceptance Criteria:
* good looking design
* logo of placerholder-company-1 should be on the navbar
Solution: {"description" : "As a developer, I want to create a visually appealing homepage for placerholder-company-1. The website should have a modern design and incorporate a Java backend.",
"acceptance_criteria" : [
"The homepage should have an aesthetically pleasing layout.",
"Use responsive design principles to ensure it looks great on various devices",
"The placerholder-company-1 logo must be prominently displayed on the navigation bar"]}
Task: Send JSON with "description" & "acceptance_criteria" for this User Story (at least 6 acceptance criteria):
10 changes: 10 additions & 0 deletions ai/resource/prompts/prompt_improve_description_german.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Aufgabe: Sende ein JSON mit "description" & "acceptance_criteria" für diese User Story: Erstelle einen REST Service für das Backend
Antwort: {"description": "Als Entwickler im Backend-Team möchte ich einen RESTful Service erstellen, um die Kommunikation zwischen dem Frontend und dem Backend zu ermöglichen.",
"acceptance_criteria": ["Die Anfragen können GET, POST, PUT oder DELETE sein.","Der Service muss sicherstellen, dass nur autorisierte Benutzer auf die Endpunkte zugreifen können.","Der Service sollte die eingehenden Anfragen validieren, um sicherzustellen, dass sie den erwarteten Parametern und Formaten entsprechen."]}
Aufgabe: Sende ein JSON mit "description" & "acceptance_criteria" für diese User Story: Erstelle eine Homepage für placeholder-company-1 mit einem java Backend. Es sollte nicht mehr als 100 tausend Euro kosten
## Akzeptanz Kriterien
* gut aussehende Webseite
* Das Logo von placeholder-company-1 sollte auf der Navigationsleiste zu sehen sein
Antwort: {"description" : "Als Entwickler möchte ich eine professionelle Homepage, mit einem Java-Backend für placeholder-company-1 erstellen, um eine benutzerfreundliche Plattform zu schaffen, die das Unternehmen online repräsentiert.",
"acceptance_criteria" : ["Die Kosten für die Erstellung der Homepage dürfen 100.000 Euro nicht überschreiten","Das Java-Backend muss robust und sicher sein, um die Funktionalität der Website zu unterstützen.", "Die Website sollte eine klare Navigation haben, um Benutzern das Auffinden von Informationen zu erleichtern"]}
Aufgabe: Sende ein JSON mit "description" & "acceptance_criteria" für diese User Story (mindestens 6 Akzeptanz Kriterien):
23 changes: 23 additions & 0 deletions ai/resource/prompts/prompt_mark_description.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Task: Send JSON with "description" for this User Story and mark all important content: As a backend developer, I want to create a reliable and scalable RESTful API service, so that our application can efficiently handle client requests and data processing.
##### Acceptance Criteria:
* The API service should support common HTTP methods (GET, POST, PUT, DELETE) for CRUD operations.
* The service should implement proper error handling and return appropriate HTTP status codes.
* Authentication and authorization mechanisms should be implemented to secure the API endpoints
Solution: {"description" : "As a *backend developer*, I want to create a **reliable and scalable RESTful API service**, so that our application can efficiently handle client requests and data processing.
##### Acceptance Criteria:
* The API service should **support** common HTTP methods (GET, POST, PUT, DELETE) for **CRUD operations**.
* The service should **implement proper error handling** and return **appropriate HTTP status codes**.
* **Authentication and authorization mechanisms** should be implemented to secure the API endpoints" }
Task: Send JSON with "description" for this User Story and mark all important content: As a web developer, I want to create an engaging and informative homepage for our website, so that visitors can easily understand our product or service offerings.
Solution: {"description" : "As a *web developer*, I want to create an **engaging and informative homepage** for our website, so that visitors can easily understand our product or service offerings."}
Task: Send JSON with "description" for this User Story and mark all important content: As a web developer, I want to create a homepage for Placeholder Company 1 with a Java backend, while ensuring that the total cost does not exceed 100,000 euros.
##### Acceptance Criteria:
* The homepage should be built using Java for the backend and a modern frontend framework (e.g., React, Angular, Vue.js).
* The homepage should accurately represent Placeholder Company 1's brand, products, and services.
* The total cost of development, including labor, hosting, and any third-party tools or services, must not exceed 100,000 euros
Solution: {"description" : "As a *web developer*, I want to create a **homepage for Placeholder Company 1 with a Java backend**, while ensuring that the total cost does not exceed **100,000 euros**.
##### Acceptance Criteria:
* The homepage should be **built using Java** for the backend and a modern frontend framework (e.g., React, Angular, Vue.js).
* The homepage should **accurately represent** Placeholder Company 1's brand, products, and services.
* The total cost of development, including **labor, hosting, and any third-party tools or services**, must not exceed **100,000 euros**"}
Task: Send JSON with "description" for this User Story and mark all important content:
Loading

0 comments on commit 7bdd9c4

Please sign in to comment.