Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
-
from huggingface_hub import InferenceClient
|
| 4 |
import langdetect
|
| 5 |
import requests
|
| 6 |
import random
|
|
@@ -8,9 +7,19 @@ from groq import Groq
|
|
| 8 |
|
| 9 |
|
| 10 |
GROQ_API_KEY = os.getenv("GROQ_API_KEY", "")
|
| 11 |
-
|
|
|
|
| 12 |
|
| 13 |
model="llama-3.3-70b-versatile"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
def detect_language(text):
|
| 16 |
"""Detects whether the input text is in French or English."""
|
|
@@ -71,41 +80,20 @@ def respond(
|
|
| 71 |
response += token
|
| 72 |
yield response
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
btn3 = gr.Button("1 week planned vacations / Voyage d'une semaine planifié", elem_classes=["gradio-button"])
|
| 92 |
-
|
| 93 |
-
user_input = gr.Textbox(placeholder="Type your travel question here...")
|
| 94 |
-
|
| 95 |
-
demo = gr.ChatInterface(
|
| 96 |
-
respond,
|
| 97 |
-
additional_inputs=[
|
| 98 |
-
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
| 99 |
-
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 100 |
-
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 101 |
-
gr.Slider(
|
| 102 |
-
minimum=0.1,
|
| 103 |
-
maximum=1.0,
|
| 104 |
-
value=0.95,
|
| 105 |
-
step=0.05,
|
| 106 |
-
label="Top-p (nucleus sampling)",
|
| 107 |
-
),
|
| 108 |
-
],
|
| 109 |
-
)
|
| 110 |
-
|
| 111 |
-
demo.launch()
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
import langdetect
|
| 4 |
import requests
|
| 5 |
import random
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
GROQ_API_KEY = os.getenv("GROQ_API_KEY", "")
|
| 10 |
+
|
| 11 |
+
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
|
| 12 |
|
| 13 |
model="llama-3.3-70b-versatile"
|
| 14 |
+
import os
|
| 15 |
+
import gradio as gr
|
| 16 |
+
from huggingface_hub import InferenceClient
|
| 17 |
+
import langdetect
|
| 18 |
+
import requests
|
| 19 |
+
import random
|
| 20 |
+
|
| 21 |
+
GROQ_API_KEY = os.getenv("GROQ_API_KEY", "")
|
| 22 |
+
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 23 |
|
| 24 |
def detect_language(text):
|
| 25 |
"""Detects whether the input text is in French or English."""
|
|
|
|
| 80 |
response += token
|
| 81 |
yield response
|
| 82 |
|
| 83 |
+
demo = gr.ChatInterface(
|
| 84 |
+
respond,
|
| 85 |
+
additional_inputs=[
|
| 86 |
+
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
| 87 |
+
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 88 |
+
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 89 |
+
gr.Slider(
|
| 90 |
+
minimum=0.1,
|
| 91 |
+
maximum=1.0,
|
| 92 |
+
value=0.95,
|
| 93 |
+
step=0.05,
|
| 94 |
+
label="Top-p (nucleus sampling)",
|
| 95 |
+
),
|
| 96 |
+
],
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|