Spaces:
Sleeping
Sleeping
Upshivam commited on
Commit ·
78e641c
1
Parent(s): 7f28ec8
Fix: switch to chat_completion for Mistral conversational task
Browse files
app.py
CHANGED
|
@@ -8,7 +8,14 @@ client = InferenceClient(
|
|
| 8 |
)
|
| 9 |
|
| 10 |
def generate_dockerfile(description, base_os, app_type):
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
Description: {description}
|
| 13 |
Base OS: {base_os}
|
| 14 |
App Type: {app_type}
|
|
@@ -17,16 +24,16 @@ Include:
|
|
| 17 |
- Multi-stage build if applicable
|
| 18 |
- Non-root user for security
|
| 19 |
- Health check
|
| 20 |
-
- Clear comments
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
prompt,
|
| 26 |
-
max_new_tokens=800,
|
| 27 |
temperature=0.3
|
| 28 |
)
|
| 29 |
-
return response
|
| 30 |
|
| 31 |
demo = gr.Interface(
|
| 32 |
fn=generate_dockerfile,
|
|
|
|
| 8 |
)
|
| 9 |
|
| 10 |
def generate_dockerfile(description, base_os, app_type):
|
| 11 |
+
messages = [
|
| 12 |
+
{
|
| 13 |
+
"role": "system",
|
| 14 |
+
"content": "You are a DevOps expert. Return ONLY Dockerfile content, no explanation."
|
| 15 |
+
},
|
| 16 |
+
{
|
| 17 |
+
"role": "user",
|
| 18 |
+
"content": f"""Generate a production-ready Dockerfile for:
|
| 19 |
Description: {description}
|
| 20 |
Base OS: {base_os}
|
| 21 |
App Type: {app_type}
|
|
|
|
| 24 |
- Multi-stage build if applicable
|
| 25 |
- Non-root user for security
|
| 26 |
- Health check
|
| 27 |
+
- Clear comments"""
|
| 28 |
+
}
|
| 29 |
+
]
|
| 30 |
|
| 31 |
+
response = client.chat_completion(
|
| 32 |
+
messages=messages,
|
| 33 |
+
max_tokens=800,
|
|
|
|
|
|
|
| 34 |
temperature=0.3
|
| 35 |
)
|
| 36 |
+
return response.choices[0].message.content
|
| 37 |
|
| 38 |
demo = gr.Interface(
|
| 39 |
fn=generate_dockerfile,
|