aliabd HF Staff commited on
Commit
86f77c2
·
1 Parent(s): 7343824

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +6 -7
  2. requirements.txt +2 -0
  3. run.ipynb +1 -0
  4. run.py +18 -0
README.md CHANGED
@@ -1,12 +1,11 @@
 
1
  ---
2
- title: Chatinterface System Prompt Main
3
- emoji: 🦀
4
- colorFrom: purple
5
- colorTo: green
6
  sdk: gradio
7
  sdk_version: 3.40.1
8
- app_file: app.py
9
  pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+
2
  ---
3
+ title: chatinterface_system_prompt_main
4
+ emoji: 🔥
5
+ colorFrom: indigo
6
+ colorTo: indigo
7
  sdk: gradio
8
  sdk_version: 3.40.1
9
+ app_file: run.py
10
  pinned: false
11
  ---
 
 
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+
2
+ s3://gradio-main-build//gradio-3.40.1-py3-none-any.whl
run.ipynb ADDED
@@ -0,0 +1 @@
 
 
1
+ {"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: chatinterface_system_prompt"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import time\n", "\n", "def echo(message, history, system_prompt, tokens):\n", " response = f\"System prompt: {system_prompt}\\n Message: {message}.\"\n", " for i in range(min(len(response), int(tokens))):\n", " time.sleep(0.05)\n", " yield response[: i+1]\n", "\n", "demo = gr.ChatInterface(echo, \n", " additional_inputs=[\n", " gr.Textbox(\"You are helpful AI.\", label=\"System Prompt\"), \n", " gr.Slider(10, 100)\n", " ]\n", " )\n", "\n", "if __name__ == \"__main__\":\n", " demo.queue().launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import time
3
+
4
+ def echo(message, history, system_prompt, tokens):
5
+ response = f"System prompt: {system_prompt}\n Message: {message}."
6
+ for i in range(min(len(response), int(tokens))):
7
+ time.sleep(0.05)
8
+ yield response[: i+1]
9
+
10
+ demo = gr.ChatInterface(echo,
11
+ additional_inputs=[
12
+ gr.Textbox("You are helpful AI.", label="System Prompt"),
13
+ gr.Slider(10, 100)
14
+ ]
15
+ )
16
+
17
+ if __name__ == "__main__":
18
+ demo.queue().launch()