alapl063 commited on
Commit
6248ad1
·
verified ·
1 Parent(s): 0de1f31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -40
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
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
 
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
- with gr.Blocks(css="""
75
- body { background-color: #A9B5DF; }
76
- .gradio-container { background-color: #A9B5DF; }
77
- .gradio-markdown { background-color: #2D336B; color: white; padding: 10px; border-radius: 10px; }
78
- .gradio-button { background-color: #7886C7; color: white; border-radius: 10px; }
79
- .gradio-chatbot-message { background-color: #FFF2F2; color: #2D336B; padding: 10px; border-radius: 10px; }
80
- """) as demo:
81
- gr.Markdown("# 🌍 ***FlightAI - Your Travel Assistant - Votre Assistant de Voyage*** ✈️\n")
82
-
83
- chatbot = gr.Chatbot(type="messages")
84
- chatbot.value = [
85
- {"role": "assistant", "content": "Hey! I'm FlightAI. Tell me your travel plans or pick a button below!\n\nSalut! Je suis FlightAI. Dis-moi ton projet de voyage ou choisis un bouton ci-dessous!"}
86
- ]
87
-
88
- with gr.Row():
89
- btn1 = gr.Button("Trip recommendations / Recommendations de Voyage", elem_classes=["gradio-button"])
90
- btn2 = gr.Button("Send me somewhere! / Envoyez-moi quelques part!", elem_classes=["gradio-button"])
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)