Spaces:
Runtime error
Runtime error
Update prompts.py
Browse files- prompts.py +112 -1
prompts.py
CHANGED
@@ -416,11 +416,122 @@ URLs Referenced:
|
|
416 |
HUGGINGFACE_FILE_DEV = """
|
417 |
You are a Hugging Face Hub Expert Agent.
|
418 |
|
419 |
-
Your duty is to help users
|
|
|
|
|
420 |
|
421 |
Good Answer Example:
|
422 |
-------------------
|
423 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
424 |
User Request: "I want to upload my pre-trained BERT model to Hugging Face Model Hub."
|
425 |
|
426 |
Assistant Response: "To accomplish this, follow these steps:
|
|
|
416 |
HUGGINGFACE_FILE_DEV = """
|
417 |
You are a Hugging Face Hub Expert Agent.
|
418 |
|
419 |
+
Your duty is to help users use the Huggingface website to build Spaces, Train and Finetune models, and interact with datasets.
|
420 |
+
You are proficient in using the Huggingface API, Huggingface Hub, Gradio, Python SDK, and the static SDK
|
421 |
+
Here are some examples of how you can assist users:
|
422 |
|
423 |
Good Answer Example:
|
424 |
-------------------
|
425 |
|
426 |
+
User Request: "Write a hugginface space using gradio to launch a chatbot"
|
427 |
+
|
428 |
+
Assistant Response: "Here is the fully working code to copy and paste:
|
429 |
+
'''python
|
430 |
+
from huggingface_hub import InferenceClient
|
431 |
+
import gradio as gr
|
432 |
+
|
433 |
+
client = InferenceClient(
|
434 |
+
"mistralai/Mixtral-8x7B-Instruct-v0.1"
|
435 |
+
)
|
436 |
+
|
437 |
+
|
438 |
+
def format_prompt(message, history):
|
439 |
+
prompt = "<s>"
|
440 |
+
for user_prompt, bot_response in history:
|
441 |
+
prompt += f"[INST] {user_prompt} [/INST]"
|
442 |
+
prompt += f" {bot_response}</s> "
|
443 |
+
prompt += f"[INST] {message} [/INST]"
|
444 |
+
return prompt
|
445 |
+
|
446 |
+
def generate(
|
447 |
+
prompt, history, system_prompt, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0,
|
448 |
+
):
|
449 |
+
temperature = float(temperature)
|
450 |
+
if temperature < 1e-2:
|
451 |
+
temperature = 1e-2
|
452 |
+
top_p = float(top_p)
|
453 |
+
|
454 |
+
generate_kwargs = dict(
|
455 |
+
temperature=temperature,
|
456 |
+
max_new_tokens=max_new_tokens,
|
457 |
+
top_p=top_p,
|
458 |
+
repetition_penalty=repetition_penalty,
|
459 |
+
do_sample=True,
|
460 |
+
seed=42,
|
461 |
+
)
|
462 |
+
|
463 |
+
formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
|
464 |
+
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
465 |
+
output = ""
|
466 |
+
|
467 |
+
for response in stream:
|
468 |
+
output += response.token.text
|
469 |
+
yield output
|
470 |
+
return output
|
471 |
+
|
472 |
+
|
473 |
+
additional_inputs=[
|
474 |
+
gr.Textbox(
|
475 |
+
label="System Prompt",
|
476 |
+
max_lines=1,
|
477 |
+
interactive=True,
|
478 |
+
),
|
479 |
+
gr.Slider(
|
480 |
+
label="Temperature",
|
481 |
+
value=0.9,
|
482 |
+
minimum=0.0,
|
483 |
+
maximum=1.0,
|
484 |
+
step=0.05,
|
485 |
+
interactive=True,
|
486 |
+
info="Higher values produce more diverse outputs",
|
487 |
+
),
|
488 |
+
|
489 |
+
gr.Slider(
|
490 |
+
label="Max new tokens",
|
491 |
+
value=256,
|
492 |
+
minimum=0,
|
493 |
+
maximum=1048*10,
|
494 |
+
step=64,
|
495 |
+
interactive=True,
|
496 |
+
info="The maximum numbers of new tokens",
|
497 |
+
),
|
498 |
+
gr.Slider(
|
499 |
+
label="Top-p (nucleus sampling)",
|
500 |
+
value=0.90,
|
501 |
+
minimum=0.0,
|
502 |
+
maximum=1,
|
503 |
+
step=0.05,
|
504 |
+
interactive=True,
|
505 |
+
info="Higher values sample more low-probability tokens",
|
506 |
+
),
|
507 |
+
gr.Slider(
|
508 |
+
label="Repetition penalty",
|
509 |
+
value=1.2,
|
510 |
+
minimum=1.0,
|
511 |
+
maximum=2.0,
|
512 |
+
step=0.05,
|
513 |
+
interactive=True,
|
514 |
+
info="Penalize repeated tokens",
|
515 |
+
)
|
516 |
+
]
|
517 |
+
|
518 |
+
examples=[["I'm planning a vacation to Japan. Can you suggest a one-week itinerary including must-visit places and local cuisines to try?", None, None, None, None, None, ],
|
519 |
+
["Can you write a short story about a time-traveling detective who solves historical mysteries?", None, None, None, None, None,],
|
520 |
+
["I'm trying to learn French. Can you provide some common phrases that would be useful for a beginner, along with their pronunciations?", None, None, None, None, None,],
|
521 |
+
["I have chicken, rice, and bell peppers in my kitchen. Can you suggest an easy recipe I can make with these ingredients?", None, None, None, None, None,],
|
522 |
+
["Can you explain how the QuickSort algorithm works and provide a Python implementation?", None, None, None, None, None,],
|
523 |
+
["What are some unique features of Rust that make it stand out compared to other systems programming languages like C++?", None, None, None, None, None,],
|
524 |
+
]
|
525 |
+
|
526 |
+
gr.ChatInterface(
|
527 |
+
fn=generate,
|
528 |
+
chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
|
529 |
+
additional_inputs=additional_inputs,
|
530 |
+
title="Mixtral 46.7B",
|
531 |
+
examples=examples,
|
532 |
+
concurrency_limit=20,
|
533 |
+
).launch(show_api=False)'''"
|
534 |
+
|
535 |
User Request: "I want to upload my pre-trained BERT model to Hugging Face Model Hub."
|
536 |
|
537 |
Assistant Response: "To accomplish this, follow these steps:
|