Spaces:
Runtime error
Runtime error
Update app.py
Browse files9 unmodified lines101112131415161762 unmodified lines80818283848524 unmodified lines11011111211311411519 unmodified lines13513613713813914018 unmodified lines1591601611621631641651661672 unmodified lines17017117217317417517617717817918018118218318437 unmodified lines2222232242252262272282292302312322332349 unmodified linesfrom share_btn import community_icon_html, loading_icon_html, share_js, share_btn_cssHF_TOKEN = os.environ.get("HF_TOKEN", None)API_URL = "https://api-inference.huggingface.co/models/bigcode/starcoder"API_URL_BASE ="https://api-inference.huggingface.co/models/bigcode/starcoderbase"FIM_PREFIX = "<fim_prefix>"FIM_MIDDLE = "<fim_middle>"62 unmodified linesclient_base = Client(API_URL_BASE, headers={"Authorization": f"Bearer {HF_TOKEN}"},)def generate(prompt, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0, version="StarCoder",24 unmodified linesif version == "StarCoder":stream = client.generate_stream(prompt, **generate_kwargs)else:stream = client_base.generate_stream(prompt, **generate_kwargs)19 unmodified linesexamples = ["X_train, y_train, X_test, y_test = train_test_split(X, y, test_size=0.1)\n\n# Train a logistic regression model, predict the labels on the test set and compute the accuracy score","// Returns every other value in the array as a new array.\nfunction everyOther(arr) {","def alternating(list1, list2):\n results = []\n for i in range(min(len(list1), len(list2))):\n results.append(list1[i])\n results.append(list2[i])\n if len(list1) > len(list2):\n <FILL_HERE>\n else:\n results.extend(list2[i+1:])\n return results",]18 unmodified linesdescription = """<div style="text-align: center;"><h1> 💫 StarCoder<span style='color: #e6b800;'> - </span>Code Completion Playground 🪐</h1><p>This is a demo to generate code with <a href="https://huggingface.co/bigcode/starcoder" style='color: #e6b800;'>StarCoder</a>, a 15B parameter model for code generation in 86 programming languages.<b>This is not an instruction model</b>. For instruction and chatting you can chat with a fine-tuned version of the model at <a href="https://huggingface.co/spaces/HuggingFaceH4/starchat-playground">StarChat Playground</a></p></div>"""disclaimer = """⚠️<b>Any use or sharing of this demo constitues your acceptance of the BigCode [OpenRAIL-M](https://huggingface.co/spaces/bigcode/bigcode-model-license-agreement) License Agreement and the use restrictions included within.</b>\2 unmodified lineswith gr.Blocks(theme=theme, analytics_enabled=False, css=css) as demo:with gr.Column():gr.Markdown(description)with gr.Row():with gr.Column():instruction = gr.Textbox(placeholder="Enter your code here",label="Code",elem_id="q-input",)submit = gr.Button("Generate", variant="primary")output = gr.Code(elem_id="q-output", lines=30)with gr.Row():with gr.Column():with gr.Accordion("Advanced settings", open=False):37 unmodified linesinteractive=True,info="Penalize repeated tokens",)with gr.Column():version = gr.Dropdown(["StarCoderBase", "StarCoder"],value="StarCoder",label="Version",info="",)gr.Markdown(disclaimer)with gr.Group(elem_id="share-btn-container"):community_icon = gr.HTML(community_icon_html, visible=True)9 unmodified lines1011121314151617181962 unmodified lines82838485868788899024 unmodified lines11511611711811912012112219 unmodified lines14214314414514614714818 unmodified lines1671681691701711721731741751761771781791801811822 unmodified lines18518618718818919019119219319419519619719819920020120220320420520620737 unmodified lines2452462472482492502519 unmodified linesfrom share_btn import community_icon_html, loading_icon_html, share_js, share_btn_cssHF_TOKEN = os.environ.get("HF_TOKEN", None)API_URL = "https://api-inference.huggingface.co/models/bigcode/starcoder"API_URL_BASE ="https://api-inference.huggingface.co/models/bigcode/starcoderbase"API_URL_PLUS = "https://api-inference.huggingface.co/models/bigcode/starcoderplus"FIM_PREFIX = "<fim_prefix>"FIM_MIDDLE = "<fim_middle>"62 unmodified linesclient_base = Client(API_URL_BASE, headers={"Authorization": f"Bearer {HF_TOKEN}"},)client_plus = Client(API_URL_PLUS, headers={"Authorization": f"Bearer {HF_TOKEN}"},)def generate(prompt, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0, version="StarCoder",24 unmodified linesif version == "StarCoder":stream = client.generate_stream(prompt, **generate_kwargs)elif version == "StarCoderPlus":stream = client_plus.generate_stream(prompt, **generate_kwargs)else:stream = client_base.generate_stream(prompt, **generate_kwargs)19 unmodified linesexamples = ["X_train, y_train, X_test, y_test = train_test_split(X, y, test_size=0.1)\n\n# Train a logistic regression model, predict the labels on the test set and compute the accuracy score","// Returns every other value in the array as a new array.\nfunction everyOther(arr) {","Poor English: She no went to the market. Corrected English:","def alternating(list1, list2):\n results = []\n for i in range(min(len(list1), len(list2))):\n results.append(list1[i])\n results.append(list2[i])\n if len(list1) > len(list2):\n <FILL_HERE>\n else:\n results.extend(list2[i+1:])\n return results",]18 unmodified linesdescription = """<div style="text-align: center;"><h1> ⭐ StarCoder <span style='color: #e6b800;'>Models</span> Playground</h1><p>This is a demo to generate text and code with the following StarCoder models:</p></div><div style="text-align: left;"><ul><li><a href="https://huggingface.co/bigcode/starcoderplus" style='color: #e6b800;'>StarCoderPlus</a>: A finetuned version of StarCoderBase on English web data, making it strong in both English text and code generation.</li><li><a href="https://huggingface.co/bigcode/starcoderbase" style='color: #e6b800;'>StarCoderBase</a>: A code generation model trained on 80+ programming languages, providing broad language coverage for code generation tasks.</li><li><a href="https://huggingface.co/bigcode/starcoder" style='color: #e6b800;'>StarCoder</a>: A finetuned version of StarCoderBase specifically focused on Python, while also maintaining strong performance on other programming languages.</li></ul><p><b>Please note:</b> These models are not designed for instruction purposes. If you're looking for instruction or want to chat with a fine-tuned model, you can visit the <a href="https://huggingface.co/spaces/HuggingFaceH4/starchat-playground">StarChat Playground</a>.</p></div>"""disclaimer = """⚠️<b>Any use or sharing of this demo constitues your acceptance of the BigCode [OpenRAIL-M](https://huggingface.co/spaces/bigcode/bigcode-model-license-agreement) License Agreement and the use restrictions included within.</b>\2 unmodified lineswith gr.Blocks(theme=theme, analytics_enabled=False, css=css) as demo:with gr.Column():gr.Markdown(description)with gr.Row():version = gr.Dropdown(["StarCoderPlus", "StarCoderBase", "StarCoder"],value="StarCoderPlus",label="Model",info="Choose a model from the list",)with gr.Row():with gr.Column():instruction = gr.Textbox(placeholder="Enter your code here",lines=5,label="Input",elem_id="q-input",)submit = gr.Button("Generate", variant="primary")output = gr.Code(elem_id="q-output", lines=30, label="Output")with gr.Row():with gr.Column():with gr.Accordion("Advanced settings", open=False):37 unmodified linesinteractive=True,info="Penalize repeated tokens",)gr.Markdown(disclaimer)with gr.Group(elem_id="share-btn-container"):community_icon = gr.HTML(community_icon_html, visible=True)
app.py+29-12