Spaces:
Sleeping
Sleeping
Update login with accesstoken
Browse files
app.py
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient, login
|
| 3 |
from custom_tools import suggest_best_cities, RecommendCountryTool
|
| 4 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, WikipediaSearchTool, SpeechToTextTool, InferenceClientModel, FinalAnswerTool
|
| 5 |
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
-
def create_agent(
|
| 9 |
-
login(token)
|
| 10 |
tools = [
|
| 11 |
DuckDuckGoSearchTool(),
|
| 12 |
WikipediaSearchTool(),
|
|
@@ -25,10 +26,9 @@ def respond(
|
|
| 25 |
system_message,
|
| 26 |
max_tokens,
|
| 27 |
temperature,
|
| 28 |
-
top_p
|
| 29 |
-
hf_token: gr.OAuthToken,
|
| 30 |
):
|
| 31 |
-
agent = create_agent(
|
| 32 |
|
| 33 |
if isinstance(message, tuple):
|
| 34 |
audio_path = message[0]
|
|
@@ -54,22 +54,11 @@ chatbot = gr.ChatInterface(
|
|
| 54 |
type="messages",
|
| 55 |
multimodal=True,
|
| 56 |
additional_inputs=[
|
| 57 |
-
gr.Textbox(value="You are a friendly Chatbot.", label="
|
| 58 |
-
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 59 |
-
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 60 |
-
gr.Slider(
|
| 61 |
-
minimum=0.1,
|
| 62 |
-
maximum=1.0,
|
| 63 |
-
value=0.95,
|
| 64 |
-
step=0.05,
|
| 65 |
-
label="Top-p (nucleus sampling)",
|
| 66 |
-
),
|
| 67 |
],
|
| 68 |
)
|
| 69 |
|
| 70 |
with gr.Blocks() as demo:
|
| 71 |
-
with gr.Sidebar():
|
| 72 |
-
gr.LoginButton()
|
| 73 |
chatbot.render()
|
| 74 |
|
| 75 |
|
|
|
|
| 1 |
+
import os
|
| 2 |
import gradio as gr
|
| 3 |
from huggingface_hub import InferenceClient, login
|
| 4 |
from custom_tools import suggest_best_cities, RecommendCountryTool
|
| 5 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, WikipediaSearchTool, SpeechToTextTool, InferenceClientModel, FinalAnswerTool
|
| 6 |
|
| 7 |
+
login(os.environ.get("HF_TOKEN"))
|
| 8 |
|
| 9 |
|
| 10 |
+
def create_agent():
|
|
|
|
| 11 |
tools = [
|
| 12 |
DuckDuckGoSearchTool(),
|
| 13 |
WikipediaSearchTool(),
|
|
|
|
| 26 |
system_message,
|
| 27 |
max_tokens,
|
| 28 |
temperature,
|
| 29 |
+
top_p
|
|
|
|
| 30 |
):
|
| 31 |
+
agent = create_agent()
|
| 32 |
|
| 33 |
if isinstance(message, tuple):
|
| 34 |
audio_path = message[0]
|
|
|
|
| 54 |
type="messages",
|
| 55 |
multimodal=True,
|
| 56 |
additional_inputs=[
|
| 57 |
+
gr.Textbox(value="You are a friendly Chatbot.", label="What's up dude?"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
],
|
| 59 |
)
|
| 60 |
|
| 61 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
| 62 |
chatbot.render()
|
| 63 |
|
| 64 |
|