Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,13 @@ import gradio as gr
|
|
3 |
from openai import OpenAI
|
4 |
from typing import List, Tuple
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
ENDPOINT_URL = "https://api.hyperbolic.xyz/v1"
|
7 |
OAI_API_KEY = os.getenv('HYPERBOLIC_XYZ_KEY')
|
8 |
PASSWORD = os.getenv("PASSWD") # Store the password in an environment variable
|
@@ -13,6 +20,7 @@ def respond(
|
|
13 |
message: str,
|
14 |
history: List[Tuple[str, str]],
|
15 |
system_message: str,
|
|
|
16 |
max_tokens: int,
|
17 |
temperature: float,
|
18 |
top_p: float,
|
@@ -27,7 +35,7 @@ def respond(
|
|
27 |
|
28 |
response = ""
|
29 |
for chunk in client.chat.completions.create(
|
30 |
-
model=
|
31 |
messages=messages,
|
32 |
max_tokens=max_tokens,
|
33 |
temperature=temperature,
|
@@ -59,7 +67,12 @@ with gr.Blocks() as demo:
|
|
59 |
respond,
|
60 |
additional_inputs=[
|
61 |
gr.Textbox(value="You are a helpful assistant.", label="System message"),
|
62 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
63 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
64 |
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
|
65 |
],
|
@@ -68,4 +81,4 @@ with gr.Blocks() as demo:
|
|
68 |
submit_button.click(check_password, inputs=password_input, outputs=[password_input, chat_interface])
|
69 |
|
70 |
if __name__ == "__main__":
|
71 |
-
demo.launch(share=True)
|
|
|
3 |
from openai import OpenAI
|
4 |
from typing import List, Tuple
|
5 |
|
6 |
+
# Define available models
|
7 |
+
AVAILABLE_MODELS = {
|
8 |
+
"DeepSeek V3": "deepseek-ai/DeepSeek-V3",
|
9 |
+
"Llama3.3-70b-Instruct": "meta-llama/Llama-3.3-70B-Instruct",
|
10 |
+
"Llama3.1-8b-Instruct": "meta-llama/Meta-Llama-3.1-8B-Instruct",
|
11 |
+
}
|
12 |
+
|
13 |
ENDPOINT_URL = "https://api.hyperbolic.xyz/v1"
|
14 |
OAI_API_KEY = os.getenv('HYPERBOLIC_XYZ_KEY')
|
15 |
PASSWORD = os.getenv("PASSWD") # Store the password in an environment variable
|
|
|
20 |
message: str,
|
21 |
history: List[Tuple[str, str]],
|
22 |
system_message: str,
|
23 |
+
model_choice: str,
|
24 |
max_tokens: int,
|
25 |
temperature: float,
|
26 |
top_p: float,
|
|
|
35 |
|
36 |
response = ""
|
37 |
for chunk in client.chat.completions.create(
|
38 |
+
model=AVAILABLE_MODELS[model_choice], # Use the selected model
|
39 |
messages=messages,
|
40 |
max_tokens=max_tokens,
|
41 |
temperature=temperature,
|
|
|
67 |
respond,
|
68 |
additional_inputs=[
|
69 |
gr.Textbox(value="You are a helpful assistant.", label="System message"),
|
70 |
+
gr.Dropdown(
|
71 |
+
choices=list(AVAILABLE_MODELS.keys()),
|
72 |
+
value=list(AVAILABLE_MODELS.keys())[0],
|
73 |
+
label="Select Model"
|
74 |
+
),
|
75 |
+
gr.Slider(minimum=1, maximum=30000, value=2048, step=100, label="Max new tokens"),
|
76 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
77 |
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
|
78 |
],
|
|
|
81 |
submit_button.click(check_password, inputs=password_input, outputs=[password_input, chat_interface])
|
82 |
|
83 |
if __name__ == "__main__":
|
84 |
+
demo.launch(share=True)
|