from groq import Groq
from dotenv import load_dotenv
import os

load_dotenv()
client = Groq(
    api_key="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",
)

def make_readme(tree):
    chat_completion = client.chat.completions.create(
        messages=[
            {
                "role": "user",
                "content": f'''You are an expert technical writer and developer advocate. When given details about a software project, you produce a complete, polished README in Markdown that includes:
                1. Project Title and Badges  
                2. Short Description  
                3. Table of Contents  
                4. Features  
                5. Prerequisites  
                6. Installation  
                7. Configuration  
                8. Usage Examples  
                9. Running Tests  
                10. Deployment  
                11. Contributing Guidelines  
                12. License  
                13. Contact / Authors

                Your README should use clear headings (`##`,`###`), bullet lists, code blocks, and links where appropriate. Be concise but thorough, and assume the reader has basic command​‑line knowledge.
                Here is the project description:
                {tree}'''
            }
        ],
        model="llama-3.3-70b-versatile",
        stream=False,
    )
    return chat_completion.choices[0].message.content

def make_license():
    return (
        '''Copyright 2025 [Your Name or Organization]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.''')

def make_report(tree):
    chat_completion = client.chat.completions.create(
        messages=[
            {
                "role": "user",
                "content": f'''You are an expert technical writer and software documenter. Write a detailed **project report** in Markdown based on the following project description:

```
{tree}
```

The report must be structured and equivalent to **6 to 10 MS Word pages**, and include:

1. **Introduction**
   - Describe what the project is and what it aims to do.

2. **Problem Statement**
   - Explain the real-world problem this project solves, and why it's important.

3. **Project Features**
   - List all major features.
   - For each feature, describe how it works under the hood (libraries, logic, modules).

4. **Flow of Execution**
   - Step-by-step breakdown of how the system works.
   - Use diagrams, bullet points, or pseudocode where useful.

5. **Implementation Details**
   - Discuss technologies used, architecture, key files, external APIs, etc.

6. **Future Scope**
   - What improvements or extensions are possible in future versions?

7. **Conclusion**
   - Wrap up the report with a summary of learnings or impact.

8. **Screenshots / Output Section**
   - Leave Markdown image placeholders like: `![Output Screenshot](path/to/screenshot.png)`

Use professional formatting with headers (##, ###), lists, and code snippets. Do **not** use raw HTML. Assume the reader is a technical audience such as a reviewer or mentor.
'''
            }
        ],
        model="llama-3.3-70b-versatile",
        stream=False,
    )
    return chat_completion.choices[0].message.content