Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,8 +10,6 @@ title = """# Welcome to 🌟Tonic's✨StarCoder
|
|
| 10 |
Join us : 🌟TeamTonic🌟 is always making cool demos! Join our active builder's 🛠️community 👻 [](https://discord.gg/GWpVpekp) On 🤗Huggingface:[MultiTransformer](https://huggingface.co/MultiTransformer) Math 🔍 [introspector](https://huggingface.co/introspector) On 🌐Github: [Tonic-AI](https://github.com/tonic-ai) & contribute to🌟 [SciTonic](https://github.com/Tonic-AI/scitonic)🤗Big thanks to Yuvi Sharma and all the folks at huggingface for the community grant 🤗
|
| 11 |
"""
|
| 12 |
|
| 13 |
-
default_system_prompt = """SYSTEM: You are an AI that code. Answer with code."""
|
| 14 |
-
|
| 15 |
model_path = "bigcode/starcoder2-15b"
|
| 16 |
|
| 17 |
hf_token = os.getenv("HF_TOKEN")
|
|
@@ -25,18 +23,18 @@ model = AutoModelForCausalLM.from_pretrained( model_path, quantization_config=qu
|
|
| 25 |
@spaces.GPU
|
| 26 |
def generate_text(prompt, temperature, max_length):
|
| 27 |
inputs = tokenizer.encode(prompt, return_tensors="pt").to("cuda")
|
| 28 |
-
outputs = model.generate(inputs, max_length=max_length, top_p=0.9, temperature=temperature)
|
| 29 |
return tokenizer.decode(outputs[0])
|
| 30 |
|
| 31 |
def gradio_app():
|
| 32 |
with gr.Blocks() as demo:
|
| 33 |
gr.Markdown(title)
|
| 34 |
-
prompt = gr.
|
| 35 |
with gr.Row():
|
| 36 |
temperature = gr.Slider(minimum=0.1, maximum=1.0, step=0.1, value=0.5, label="Temperature")
|
| 37 |
max_length = gr.Slider(minimum=100, maximum=1024, step=10, value=100, label="Generate Length")
|
| 38 |
generate_btn = gr.Button("Try✨StarCoder")
|
| 39 |
-
output = gr.Code(label="
|
| 40 |
|
| 41 |
generate_btn.click(
|
| 42 |
fn=generate_text,
|
|
|
|
| 10 |
Join us : 🌟TeamTonic🌟 is always making cool demos! Join our active builder's 🛠️community 👻 [](https://discord.gg/GWpVpekp) On 🤗Huggingface:[MultiTransformer](https://huggingface.co/MultiTransformer) Math 🔍 [introspector](https://huggingface.co/introspector) On 🌐Github: [Tonic-AI](https://github.com/tonic-ai) & contribute to🌟 [SciTonic](https://github.com/Tonic-AI/scitonic)🤗Big thanks to Yuvi Sharma and all the folks at huggingface for the community grant 🤗
|
| 11 |
"""
|
| 12 |
|
|
|
|
|
|
|
| 13 |
model_path = "bigcode/starcoder2-15b"
|
| 14 |
|
| 15 |
hf_token = os.getenv("HF_TOKEN")
|
|
|
|
| 23 |
@spaces.GPU
|
| 24 |
def generate_text(prompt, temperature, max_length):
|
| 25 |
inputs = tokenizer.encode(prompt, return_tensors="pt").to("cuda")
|
| 26 |
+
outputs = model.generate(inputs, max_length=max_length, top_p=0.9, temperature=temperature, do_sample=True)
|
| 27 |
return tokenizer.decode(outputs[0])
|
| 28 |
|
| 29 |
def gradio_app():
|
| 30 |
with gr.Blocks() as demo:
|
| 31 |
gr.Markdown(title)
|
| 32 |
+
prompt = gr.Code(label="Enter your code prompt", placeholder="def print_hello_world():")
|
| 33 |
with gr.Row():
|
| 34 |
temperature = gr.Slider(minimum=0.1, maximum=1.0, step=0.1, value=0.5, label="Temperature")
|
| 35 |
max_length = gr.Slider(minimum=100, maximum=1024, step=10, value=100, label="Generate Length")
|
| 36 |
generate_btn = gr.Button("Try✨StarCoder")
|
| 37 |
+
output = gr.Code(label="✨StarCoder:", lines=40)
|
| 38 |
|
| 39 |
generate_btn.click(
|
| 40 |
fn=generate_text,
|