Spaces:
Running
Running
acecalisto3
commited on
Commit
•
c43dc09
1
Parent(s):
eeb235a
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,33 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
-
|
|
|
|
|
7 |
|
8 |
-
def
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
|
|
11 |
iface = gr.Interface(
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
16 |
)
|
17 |
|
|
|
18 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Load the text generation pipeline
|
5 |
+
pipe = pipeline(
|
6 |
+
"text-generation",
|
7 |
+
model="MaziyarPanahi/BASH-Coder-Mistral-7B-Mistral-7B-Instruct-v0.2-slerp-GGUF"
|
8 |
+
)
|
9 |
|
10 |
+
def generate_bash_code(prompt):
|
11 |
+
"""Generates BASH code using the Mistral-7B pipeline."""
|
12 |
+
sequences = pipe(
|
13 |
+
prompt,
|
14 |
+
max_length=200,
|
15 |
+
num_return_sequences=1,
|
16 |
+
do_sample=True, # Enable sampling for more creative output
|
17 |
+
top_k=50, # Explore a wider range of vocabulary
|
18 |
+
top_p=0.95, # Control the probability distribution of tokens
|
19 |
+
temperature=0.8 # Adjust temperature for creativity
|
20 |
+
)
|
21 |
+
return sequences[0]['generated_text']
|
22 |
|
23 |
+
# Create the Gradio interface
|
24 |
iface = gr.Interface(
|
25 |
+
fn=generate_bash_code,
|
26 |
+
inputs=gr.Textbox(lines=5, label="Describe what you want your BASH script to do"),
|
27 |
+
outputs=gr.Code(language="bash", label="Generated BASH Code"),
|
28 |
+
title="BASH Coder",
|
29 |
+
description="Generate BASH scripts using a Mistral-7B model.",
|
30 |
)
|
31 |
|
32 |
+
# Launch the interface
|
33 |
iface.launch()
|