Sharyar commited on
Commit ·
092b44e
1
Parent(s): e86501a
Remove all project files
Browse files- .gitignore +0 -10
- README.md +0 -49
- app.py +0 -139
- requirements.txt +0 -2
.gitignore
DELETED
|
@@ -1,10 +0,0 @@
|
|
| 1 |
-
__pycache__/
|
| 2 |
-
*.py[cod]
|
| 3 |
-
*$py.class
|
| 4 |
-
.env
|
| 5 |
-
.venv/
|
| 6 |
-
venv/
|
| 7 |
-
.env.local
|
| 8 |
-
.DS_Store
|
| 9 |
-
.idea/
|
| 10 |
-
.vscode/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
DELETED
|
@@ -1,49 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: Technical Description Assistant
|
| 3 |
-
emoji: 📝
|
| 4 |
-
colorFrom: blue
|
| 5 |
-
colorTo: purple
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version: 5.0.0
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: false
|
| 10 |
-
---
|
| 11 |
-
|
| 12 |
-
# Technical Description Assistant
|
| 13 |
-
|
| 14 |
-
A zero-shot Hugging Face Space that helps developers turn rough project descriptions
|
| 15 |
-
into clean, professional technical text.
|
| 16 |
-
|
| 17 |
-
## What it does
|
| 18 |
-
|
| 19 |
-
- Takes an informal project description as input
|
| 20 |
-
- Uses a large language model (zero-shot, no fine-tuning) to rewrite it
|
| 21 |
-
- Produces a clear, concise, and professional technical description
|
| 22 |
-
|
| 23 |
-
## Tech stack
|
| 24 |
-
|
| 25 |
-
- **UI**: Gradio
|
| 26 |
-
- **Model**: `mistralai/Mistral-7B-Instruct-v0.2` via Hugging Face Inference API
|
| 27 |
-
- **Hosting**: Hugging Face Spaces
|
| 28 |
-
|
| 29 |
-
## Running locally
|
| 30 |
-
|
| 31 |
-
```bash
|
| 32 |
-
pip install -r requirements.txt
|
| 33 |
-
python app.py
|
| 34 |
-
```
|
| 35 |
-
|
| 36 |
-
## Usage tips
|
| 37 |
-
|
| 38 |
-
- Mention key technologies (e.g., Docker, Kubernetes, FastAPI, PostgreSQL)
|
| 39 |
-
- Describe the main problem your project solves
|
| 40 |
-
- Include how users or systems interact with it
|
| 41 |
-
|
| 42 |
-
Example rough input:
|
| 43 |
-
|
| 44 |
-
> This project uses docker and cloud stuff to run machines.
|
| 45 |
-
|
| 46 |
-
Example improved output (approximate):
|
| 47 |
-
|
| 48 |
-
> This project provides a containerized infrastructure, using Docker and cloud
|
| 49 |
-
> services to orchestrate and run compute workloads reliably across machines.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
DELETED
|
@@ -1,139 +0,0 @@
|
|
| 1 |
-
import huggingface_hub as _hf
|
| 2 |
-
|
| 3 |
-
# Backwards-compat shim: some Gradio versions still import `HfFolder`
|
| 4 |
-
# from `huggingface_hub`, but newer `huggingface_hub` removed it.
|
| 5 |
-
# We recreate a minimal version so `from huggingface_hub import HfFolder` works.
|
| 6 |
-
if not hasattr(_hf, "HfFolder"):
|
| 7 |
-
class HfFolder: # type: ignore
|
| 8 |
-
"""Minimal stand-in for deprecated huggingface_hub.HfFolder.
|
| 9 |
-
|
| 10 |
-
Only the token-related methods used by Gradio are implemented.
|
| 11 |
-
"""
|
| 12 |
-
|
| 13 |
-
@staticmethod
|
| 14 |
-
def get_token() -> str | None:
|
| 15 |
-
try:
|
| 16 |
-
return _hf.get_token()
|
| 17 |
-
except Exception:
|
| 18 |
-
return None
|
| 19 |
-
|
| 20 |
-
@staticmethod
|
| 21 |
-
def save_token(token: str, *args, **kwargs) -> None:
|
| 22 |
-
try:
|
| 23 |
-
_hf.login(token=token)
|
| 24 |
-
except TypeError:
|
| 25 |
-
# Fallback for older/newer login signatures
|
| 26 |
-
_hf.login(token)
|
| 27 |
-
|
| 28 |
-
@staticmethod
|
| 29 |
-
def delete_token() -> None: # Not strictly needed for Spaces
|
| 30 |
-
return None
|
| 31 |
-
|
| 32 |
-
_hf.HfFolder = HfFolder
|
| 33 |
-
|
| 34 |
-
import gradio as gr
|
| 35 |
-
from huggingface_hub import InferenceClient
|
| 36 |
-
|
| 37 |
-
# Zero-shot model hosted on Hugging Face Inference API
|
| 38 |
-
MODEL_ID = "mistralai/Mistral-7B-Instruct-v0.2"
|
| 39 |
-
client = InferenceClient(MODEL_ID)
|
| 40 |
-
|
| 41 |
-
SYSTEM_PROMPT = """
|
| 42 |
-
You are an AI assistant that rewrites software project descriptions.
|
| 43 |
-
Your goal is to turn short, rough developer text into a clear, concise,
|
| 44 |
-
and professional technical description.
|
| 45 |
-
|
| 46 |
-
Guidelines:
|
| 47 |
-
- Preserve all technical details and technologies mentioned.
|
| 48 |
-
- Use neutral, professional tone (no marketing hype).
|
| 49 |
-
- Improve grammar, clarity, and structure.
|
| 50 |
-
- Prefer 2–5 sentences.
|
| 51 |
-
- Do NOT repeat the original text verbatim.
|
| 52 |
-
""".strip()
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
def improve_description(user_input: str) -> str:
|
| 56 |
-
"""Rewrite a rough project description in a professional, technical style."""
|
| 57 |
-
if not user_input or not user_input.strip():
|
| 58 |
-
return "Please enter a description to improve."
|
| 59 |
-
|
| 60 |
-
user_text = user_input.strip()
|
| 61 |
-
if len(user_text) < 10:
|
| 62 |
-
return "Please provide a bit more detail about your project."
|
| 63 |
-
|
| 64 |
-
messages = [
|
| 65 |
-
{"role": "system", "content": SYSTEM_PROMPT},
|
| 66 |
-
{
|
| 67 |
-
"role": "user",
|
| 68 |
-
"content": (
|
| 69 |
-
"Here is a rough project description written by a developer. "
|
| 70 |
-
"Rewrite it as a clear, concise, and professional technical description, "
|
| 71 |
-
"preserving all the technical meaning and technologies used.\n\n"
|
| 72 |
-
f"Original description:\n{user_text}"
|
| 73 |
-
),
|
| 74 |
-
},
|
| 75 |
-
]
|
| 76 |
-
|
| 77 |
-
try:
|
| 78 |
-
completion = client.chat_completion(
|
| 79 |
-
model=MODEL_ID,
|
| 80 |
-
messages=messages,
|
| 81 |
-
max_tokens=256,
|
| 82 |
-
temperature=0.3,
|
| 83 |
-
top_p=0.9,
|
| 84 |
-
)
|
| 85 |
-
improved = completion.choices[0].message["content"].strip()
|
| 86 |
-
|
| 87 |
-
# Simple safety check: avoid returning the exact same text
|
| 88 |
-
if improved.lower() == user_text.lower():
|
| 89 |
-
return "I couldn't improve this further. Please add more detail or context."
|
| 90 |
-
|
| 91 |
-
return improved
|
| 92 |
-
except Exception as e:
|
| 93 |
-
# Fallback message if the remote API fails for any reason
|
| 94 |
-
return (
|
| 95 |
-
"There was an issue contacting the language model service. "
|
| 96 |
-
"Please try again in a moment or simplify your description."
|
| 97 |
-
)
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
with gr.Blocks(title="Technical Description Assistant") as demo:
|
| 101 |
-
gr.Markdown(
|
| 102 |
-
"""
|
| 103 |
-
# 📝 Technical Description Assistant
|
| 104 |
-
|
| 105 |
-
Paste a rough project description, and this assistant will rewrite it
|
| 106 |
-
into a clear, professional technical description using a zero-shot
|
| 107 |
-
large language model hosted on Hugging Face.
|
| 108 |
-
"""
|
| 109 |
-
)
|
| 110 |
-
|
| 111 |
-
with gr.Row():
|
| 112 |
-
with gr.Column():
|
| 113 |
-
input_text = gr.Textbox(
|
| 114 |
-
label="Your Description",
|
| 115 |
-
placeholder="Describe your project in your own words...",
|
| 116 |
-
lines=8,
|
| 117 |
-
)
|
| 118 |
-
submit_btn = gr.Button("✨ Improve Description", variant="primary")
|
| 119 |
-
|
| 120 |
-
with gr.Column():
|
| 121 |
-
output_text = gr.Textbox(
|
| 122 |
-
label="Professional Version",
|
| 123 |
-
lines=8,
|
| 124 |
-
)
|
| 125 |
-
|
| 126 |
-
gr.Markdown(
|
| 127 |
-
"""
|
| 128 |
-
### Example inputs
|
| 129 |
-
- "This is a web app that lets users upload pics and it uses AI to make them look better. Built with Python and some ML stuff."
|
| 130 |
-
- "Made a tool that checks code for bugs. It's really fast and works with multiple languages. Uses AST parsing."
|
| 131 |
-
- "API for weather data. Gets info from multiple sources and combines them. Has caching so it's faster."
|
| 132 |
-
"""
|
| 133 |
-
)
|
| 134 |
-
|
| 135 |
-
submit_btn.click(improve_description, inputs=input_text, outputs=output_text)
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
if __name__ == "__main__":
|
| 139 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
gradio==4.44.0
|
| 2 |
-
huggingface_hub==0.20.3
|
|
|
|
|
|
|
|
|