Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,32 +1,11 @@
|
|
| 1 |
-
"""
|
| 2 |
# Inference
|
| 3 |
|
| 4 |
-
import gradio as gr
|
| 5 |
-
|
| 6 |
-
app = gr.load(
|
| 7 |
-
"google/gemma-2-2b-it",
|
| 8 |
-
src = "models",
|
| 9 |
-
inputs = [gr.Textbox(label = "Input")],
|
| 10 |
-
outputs = [gr.Textbox(label = "Output")],
|
| 11 |
-
title = "Google Gemma",
|
| 12 |
-
description = "Inference",
|
| 13 |
-
examples = [
|
| 14 |
-
["Hello, World."]
|
| 15 |
-
]
|
| 16 |
-
).launch()
|
| 17 |
-
"""
|
| 18 |
-
|
| 19 |
-
# Inference Client
|
| 20 |
-
|
| 21 |
import gradio as gr
|
| 22 |
from huggingface_hub import InferenceClient
|
| 23 |
-
#import os
|
| 24 |
-
|
| 25 |
-
#hf_token = os.getenv("HF_TOKEN")
|
| 26 |
|
| 27 |
client = InferenceClient("google/gemma-2-2b-it")
|
| 28 |
|
| 29 |
-
def
|
| 30 |
message,
|
| 31 |
history: list[tuple[str, str]],
|
| 32 |
#system_message,
|
|
@@ -41,7 +20,8 @@ def fn_chat(
|
|
| 41 |
if val[0]:
|
| 42 |
messages.append({"role": "user", "content": val[0]})
|
| 43 |
if val[1]:
|
| 44 |
-
messages.append({"role": "assistant", "content": val[1]})
|
|
|
|
| 45 |
|
| 46 |
messages.append({"role": "user", "content": message})
|
| 47 |
|
|
@@ -60,7 +40,7 @@ def fn_chat(
|
|
| 60 |
yield response
|
| 61 |
|
| 62 |
app = gr.ChatInterface(
|
| 63 |
-
fn =
|
| 64 |
additional_inputs = [
|
| 65 |
#gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
| 66 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
|
@@ -68,7 +48,7 @@ app = gr.ChatInterface(
|
|
| 68 |
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
|
| 69 |
],
|
| 70 |
title = "Google Gemma",
|
| 71 |
-
description = "
|
| 72 |
examples = [
|
| 73 |
["Hello, World."]
|
| 74 |
]
|
|
|
|
|
|
|
| 1 |
# Inference
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
from huggingface_hub import InferenceClient
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
client = InferenceClient("google/gemma-2-2b-it")
|
| 7 |
|
| 8 |
+
def fn(
|
| 9 |
message,
|
| 10 |
history: list[tuple[str, str]],
|
| 11 |
#system_message,
|
|
|
|
| 20 |
if val[0]:
|
| 21 |
messages.append({"role": "user", "content": val[0]})
|
| 22 |
if val[1]:
|
| 23 |
+
#messages.append({"role": "assistant", "content": val[1]})
|
| 24 |
+
messages.append({"role": "bot", "content": val[1]})
|
| 25 |
|
| 26 |
messages.append({"role": "user", "content": message})
|
| 27 |
|
|
|
|
| 40 |
yield response
|
| 41 |
|
| 42 |
app = gr.ChatInterface(
|
| 43 |
+
fn = fn,
|
| 44 |
additional_inputs = [
|
| 45 |
#gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
| 46 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
|
|
|
| 48 |
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
|
| 49 |
],
|
| 50 |
title = "Google Gemma",
|
| 51 |
+
description = "Inference",
|
| 52 |
examples = [
|
| 53 |
["Hello, World."]
|
| 54 |
]
|