Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
|
|
3 |
from optillm.moa import mixture_of_agents
|
|
|
|
|
4 |
|
5 |
def respond(
|
6 |
model,
|
@@ -12,7 +15,8 @@ def respond(
|
|
12 |
temperature,
|
13 |
top_p,
|
14 |
):
|
15 |
-
client = InferenceClient(model)
|
|
|
16 |
messages = [{"role": "system", "content": system_message}]
|
17 |
|
18 |
for val in history:
|
@@ -23,19 +27,22 @@ def respond(
|
|
23 |
|
24 |
messages.append({"role": "user", "content": message})
|
25 |
|
26 |
-
response = ""
|
|
|
|
|
|
|
27 |
|
28 |
-
for message in client.chat_completion(
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
):
|
35 |
-
|
36 |
|
37 |
-
|
38 |
-
|
39 |
|
40 |
"""
|
41 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
@@ -44,10 +51,11 @@ demo = gr.ChatInterface(
|
|
44 |
respond,
|
45 |
additional_inputs=[
|
46 |
gr.Dropdown(
|
47 |
-
["meta-llama/Meta-Llama-3.1-70B-Instruct", "meta-llama/Meta-Llama-3.1-8B-Instruct", "HuggingFaceH4/zephyr-7b-beta"],
|
|
|
48 |
),
|
49 |
gr.Dropdown(
|
50 |
-
["bon", "mcts", "moa"], label="Approach", info="Choose the approach"
|
51 |
),
|
52 |
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
53 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
+
|
4 |
from optillm.moa import mixture_of_agents
|
5 |
+
from optillm.mcts import chat_with_mcts
|
6 |
+
from optillm.bon import best_of_n_sampling
|
7 |
|
8 |
def respond(
|
9 |
model,
|
|
|
15 |
temperature,
|
16 |
top_p,
|
17 |
):
|
18 |
+
# client = InferenceClient(model)
|
19 |
+
|
20 |
messages = [{"role": "system", "content": system_message}]
|
21 |
|
22 |
for val in history:
|
|
|
27 |
|
28 |
messages.append({"role": "user", "content": message})
|
29 |
|
30 |
+
# response = ""
|
31 |
+
|
32 |
+
final_response = mixture_of_agents(system_message, message, client, model)
|
33 |
+
return final_response
|
34 |
|
35 |
+
# for message in client.chat_completion(
|
36 |
+
# messages,
|
37 |
+
# max_tokens=max_tokens,
|
38 |
+
# stream=True,
|
39 |
+
# temperature=temperature,
|
40 |
+
# top_p=top_p,
|
41 |
+
# ):
|
42 |
+
# token = message.choices[0].delta.content
|
43 |
|
44 |
+
# response += token
|
45 |
+
# yield response
|
46 |
|
47 |
"""
|
48 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
|
|
51 |
respond,
|
52 |
additional_inputs=[
|
53 |
gr.Dropdown(
|
54 |
+
["meta-llama/Meta-Llama-3.1-70B-Instruct", "meta-llama/Meta-Llama-3.1-8B-Instruct", "HuggingFaceH4/zephyr-7b-beta"],
|
55 |
+
value="meta-llama/Meta-Llama-3.1-70B-Instruct", label="Model", info="Choose the base model"
|
56 |
),
|
57 |
gr.Dropdown(
|
58 |
+
["bon", "mcts", "moa"], value="moa", label="Approach", info="Choose the approach"
|
59 |
),
|
60 |
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
61 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|