PraneshJs commited on
Commit
b087e5d
·
verified ·
1 Parent(s): e511984

upgraded prompts

Browse files
Files changed (1) hide show
  1. azure_ai.py +114 -14
azure_ai.py CHANGED
@@ -10,32 +10,132 @@ client = AzureOpenAI(
10
  api_key=os.getenv("AZURE_OPENAI_KEY").strip()
11
  )
12
 
 
13
  def enhance_with_ai(repo_info):
14
  file_summaries = "\n".join([
15
- f"### {name}\n```{content[:300]}```"
16
  for name, content in list(repo_info['files'].items())[:10]
17
  ])
18
 
19
- prompt = f"""
20
- Create a professional README.md for a GitHub project named "{repo_info['name']}".
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- Description: {repo_info['description']}
23
- Topics: {', '.join(repo_info['topics'])}
24
 
25
- The project includes the following files:
26
- {file_summaries}
27
 
28
- README must include: Introduction, Workflow/Architecture Diagram, Features, Installation, Usage, Contributing, and License.
29
- """
30
 
31
  response = client.chat.completions.create(
32
  model=os.getenv("AZURE_DEPLOYMENT_NAME").strip(),
33
  messages=[
34
- {"role": "system", "content": "You are a helpful assistant that creates GitHub READMEs. You must follow the provided structure and include all necessary sections. Use necessary emojies and markdown formatting."},
35
- {"role": "user", "content": prompt}
36
  ],
37
- temperature=0.7,
38
- max_tokens=1000
39
  )
40
 
41
- return response.choices[0].message.content
 
10
  api_key=os.getenv("AZURE_OPENAI_KEY").strip()
11
  )
12
 
13
+
14
  def enhance_with_ai(repo_info):
15
  file_summaries = "\n".join([
16
+ f"### {name}\n```{content[:500]}```"
17
  for name, content in list(repo_info['files'].items())[:10]
18
  ])
19
 
20
+ system_prompt = """You are a senior open-source developer and technical writer who has authored
21
+ documentation for projects with 50,000+ GitHub stars (e.g., FastAPI, LangChain, Streamlit).
22
+
23
+ Your README output must:
24
+ - Feel like a polished, production-grade open-source project
25
+ - Use Mermaid diagrams: sequenceDiagram for API/data flow, flowchart LR for architecture
26
+ - Include shields.io badges, tables, and collapsible sections where appropriate
27
+ - Be scannable: a developer should understand the project in under 60 seconds
28
+ - Never truncate — every section must be fully written
29
+ - Use emojis only in section headers, not inline text"""
30
+
31
+ user_prompt = f"""
32
+ Generate a world-class GitHub README.md for this project.
33
+
34
+ PROJECT CONTEXT
35
+ ---------------
36
+ Name : {repo_info['name']}
37
+ Description : {repo_info['description']}
38
+ Topics : {', '.join(repo_info['topics'])}
39
+
40
+ FILES (sampled for context):
41
+ {file_summaries}
42
+ ---------------
43
+
44
+ Follow this EXACT structure and do not skip any section:
45
+
46
+ 1. Hero Section
47
+ - H1 title with a one-line tagline below it
48
+ - Shields.io badges row:
49
+ ![Python](https://img.shields.io/badge/python-3.10+-blue)
50
+ ![License](https://img.shields.io/badge/license-MIT-green)
51
+ ![Stars](https://img.shields.io/github/stars/user/{repo_info['name']})
52
+ ![Issues](https://img.shields.io/github/issues/user/{repo_info['name']})
53
+ - A short 2-line summary of what the project does
54
+
55
+ 2. Table of Contents
56
+ - Linked TOC to every section
57
+
58
+ 3. Introduction
59
+ - The problem this project solves (2-3 sentences)
60
+ - Who benefits from it
61
+ - A "Why {repo_info['name']}?" comparison table vs alternatives:
62
+ | Feature | {repo_info['name']} | Alternative A | Alternative B |
63
+
64
+ 4. Features
65
+ - 6-8 bullet points, each starting with a relevant emoji
66
+ - Group under: Core Features, Developer Experience, Deployment
67
+
68
+ 5. Architecture
69
+ - A Mermaid flowchart LR showing system components:
70
+ ```mermaid
71
+ flowchart LR
72
+ A[Input Layer] --> B[Processing Layer]
73
+ B --> C[Output Layer]
74
+ ```
75
+ - A component breakdown table after the diagram:
76
+ | Component | Role | Technology |
77
+
78
+ 6. Workflow
79
+ - A Mermaid sequenceDiagram showing the request/response or data flow:
80
+ ```mermaid
81
+ sequenceDiagram
82
+ actor User
83
+ participant App
84
+ participant Backend
85
+ User->>App: action
86
+ App->>Backend: request
87
+ Backend-->>App: response
88
+ App-->>User: result
89
+ ```
90
+ - Numbered step-by-step explanation below the diagram
91
+
92
+ 7. Tech Stack
93
+ | Layer | Technology | Purpose |
94
+
95
+ 8. Installation
96
+ - Prerequisites block
97
+ - Quick Start in 3 steps max:
98
+ ```bash
99
+ git clone https://github.com/user/{repo_info['name']}.git
100
+ cd {repo_info['name']}
101
+ pip install -r requirements.txt
102
+ ```
103
+ - Environment setup:
104
+ ```bash
105
+ cp .env.example .env
106
+ # Fill in your values
107
+ ```
108
+
109
+ 9. Usage
110
+ - Basic example with code block
111
+ - Advanced example with code block
112
+
113
+ 10. Project Structure
114
+ ```
115
+ {repo_info['name']}/
116
+ |- src/ # core logic
117
+ |- tests/ # unit tests
118
+ |- docs/ # documentation
119
+ |- README.md
120
+ ```
121
 
122
+ 11. Contributing
123
+ - 4-step git contribution guide in a bash code block
124
 
125
+ 12. License
126
+ - MIT License — 2025 {repo_info['name']} Contributors
127
 
128
+ Write the complete README now. Do not summarize, skip, or truncate any section.
129
+ """
130
 
131
  response = client.chat.completions.create(
132
  model=os.getenv("AZURE_DEPLOYMENT_NAME").strip(),
133
  messages=[
134
+ {"role": "system", "content": system_prompt},
135
+ {"role": "user", "content": user_prompt}
136
  ],
137
+ temperature=0.3,
138
+ max_tokens=4000
139
  )
140
 
141
+ return response.choices[0].message.content