Skip to content

Commit

Permalink
Merge pull request #162 from devopshobbies/dev
Browse files Browse the repository at this point in the history
Update REAME.md and re-structure of openai input token
  • Loading branch information
mohammadll authored Dec 26, 2024
2 parents c922dd9 + e2518f0 commit da1e5e0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 73 deletions.
54 changes: 14 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,27 @@
[![devopsgpt demo](devopsgpt.jpg)](https://youtu.be/IPXmjUcDZJU?si=4S5U_y8Jr1u5gOrh)

# DevOps-GPT
# 🚀 DevOpsGPT: Automate Your DevOps Workflow

This project helps you to balance your daily work as a DevOps engineer, from simple bug fixes to project template generation. you don't need to search on Google for some routine jobs and it helps you with a robust prompt to simplify your career.
DevOpsGPT is a revolutionary tool designed to streamline your workflow and empower you to build systems and automate tasks with ease.

## Run DevOpsGPT
**Tired of spending hours on repetitive DevOps tasks?**

Builds and starts the Docker Compose stack:

make

Stops and removes the Docker Compose stack:
DevOpsGPT is here to help! Whether you're setting up infrastructure, speeding up deployments, or tackling any other DevOps challenge, our app can make your life easier and more productive.

make down
**Here's what you can expect with DevOpsGPT:**

Installs the Helm chart for the devopsgpt app on a Kubernetes cluster:
* **Faster task completion:** Automate repetitive tasks and free up your time to focus on more strategic initiatives.
* **Simplified workflows:** Our intuitive interface makes it easy to get started and use DevOpsGPT to its full potential.
* **Increased efficiency:** Streamline your DevOps processes and achieve more with less effort.

make helm-install

Uninstalls the Helm chart for the devopsgpt app:

make helm-uninstall

You can override the release name and namespace for Helm commands by running:

make [helm-install|helm-uninstall] namespace=NAMESPACE releaseName=RELEASENAME

The default namespace is `default` and the default release name is `devopsgpt`.



## Running Tests

To run tests, run the following command

```
cd app && pytest tests/
```




## Environment Variables

To run this project, you will need to add the following environment variables to your .env file

`KEY` (OpenAI API Key)
**Ready to experience the DevOpsGPT difference?**

1. Visit our website: https://hobs.ai
2. Sign in or create an account.
3. Start exploring the many features of DevOpsGPT and see how it can transform your workflow.
4. We value your feedback! Share your thoughts and suggestions with us to help us continuously improve DevOpsGPT.

**We're confident that DevOpsGPT will become an essential tool in your DevOps toolkit. Let's work together to make it even better!**


## API Reference
Expand Down
4 changes: 2 additions & 2 deletions app/gpt_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from openai import OpenAI
from fastapi import HTTPException

def gpt_service(prompt):
def gpt_service(prompt,token):

try:
client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
client = OpenAI(api_key=token)
chat_completion = client.chat.completions.create(
messages=[
{
Expand Down
25 changes: 4 additions & 21 deletions app/models/terraform_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,27 @@

class IaCBasicInput(BasicInput):
input:str
service:Optional[str] = 'terraform'
token:str

@validator("input")
def validate_input(cls, value):
if not value:
raise ValueError("Input cannot be empty.")
return value

@validator("service")
def validate_service(cls, value):
allowed_services = ['terraform']
if value not in allowed_services:
raise ValueError(f"Service must be one of {allowed_services}.")
return value


class IaCBugfixInput(BasicInput):
bug_description:str
version:str = 'latest'
service:Optional[str] = 'terraform'
token:str

@validator("bug_description")
def validate_bug_description(cls, value):
if not value:
raise ValueError("Bug description cannot be empty.")
return value

@validator("version")
def validate_version(cls, value):
if not value:
raise ValueError("Version cannot be empty.")
return value

@validator("service")
def validate_service(cls, value):
allowed_services = ['terraform']
if value not in allowed_services:
raise ValueError(f"Service must be one of {allowed_services}.")
return value


class IaCInstallationInput(BaseModel):
os:str = "Ubuntu"
Expand Down
10 changes: 2 additions & 8 deletions app/prompt_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,15 @@
def IaC_basics_generator(input : IaCBasicInput) -> str:

prompt = f"""
Write a robust answer about {input.service},
focusing on the latest update of {input.service} and based on this question:{input.input},
minimun length of answer is {input.min_tokens} and maximum length is {input.max_tokens}
{input.input}
"""
return prompt


def IaC_bugfix_generator(input : IaCBugfixInput) -> str:

prompt = f"""
Write a clear answer to debug {input.service}
focusing on the version {input.version} of {input.service} and based on this bug:{input.bug_description},
generate a correct code that help us to solve this bug.
minimum length of answer is {input.min_tokens} and maximum length is {input.max_tokens}
{input.bug_description}
"""
return prompt
Expand Down
4 changes: 2 additions & 2 deletions app/routes/terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ async def IaC_basic_generation(request:IaCBasicInput) -> Output:
if os.environ.get("TEST"):
return Output(output='Terraform developed by hashicorp and it is very usefull')
generated_prompt = IaC_basics_generator(request)
output = gpt_service(generated_prompt)
output = gpt_service(generated_prompt,request.token)
return Output(output=output)

@app.post("/api/IaC-bugfix/")
async def IaC_bugfix_generation(request:IaCBugfixInput) -> Output:
if os.environ.get("TEST"):
return Output(output='fix this bug by adding x to the y')
generated_prompt = IaC_bugfix_generator(request)
output = gpt_service(generated_prompt)
output = gpt_service(generated_prompt,request.token)
return Output(output=output)


Expand Down

0 comments on commit da1e5e0

Please sign in to comment.