switching to phi3.5, adding example queries
Browse files
app.py
CHANGED
@@ -38,7 +38,8 @@ class chat_engine_hf_api:
|
|
38 |
|
39 |
def __init__(self):
|
40 |
self.client = InferenceClient(
|
41 |
-
"
|
|
|
42 |
token=os.environ['HF_TOKEN_API']
|
43 |
)
|
44 |
|
@@ -78,6 +79,9 @@ max_history_length = 3
|
|
78 |
# keep a hidden model "native" language chat history
|
79 |
native_chat_history = []
|
80 |
|
|
|
|
|
|
|
81 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
82 |
|
83 |
gr.Markdown("# BreizhBot\n## Breton Chatbot (Translation based)\nPart of the [GweLLM](https://github.com/blackccpie/GweLLM) project")
|
@@ -85,6 +89,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
85 |
chatbot = gr.Chatbot(
|
86 |
label="Chat",
|
87 |
placeholder="Degemer mat, petra a c'hellan ober evidoc'h ?",
|
|
|
88 |
type="messages")
|
89 |
msg = gr.Textbox(label='User Input')
|
90 |
|
@@ -97,6 +102,12 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
97 |
|
98 |
chatbot.clear(clear, inputs=[chatbot])
|
99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
def user_input(message, chat_history):
|
101 |
"""
|
102 |
Handles instant display of the user query (without waiting for model answer)
|
@@ -131,6 +142,8 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
131 |
|
132 |
return "", chat_history
|
133 |
|
|
|
|
|
134 |
msg.submit(user_input, [msg, chatbot], chatbot).then(respond, [msg, chatbot], [msg, chatbot])
|
135 |
|
136 |
if __name__ == "__main__":
|
|
|
38 |
|
39 |
def __init__(self):
|
40 |
self.client = InferenceClient(
|
41 |
+
"microsoft/Phi-3.5-mini-instruct",
|
42 |
+
#"meta-llama/Llama-3.2-3B-Instruct",
|
43 |
token=os.environ['HF_TOKEN_API']
|
44 |
)
|
45 |
|
|
|
79 |
# keep a hidden model "native" language chat history
|
80 |
native_chat_history = []
|
81 |
|
82 |
+
# example queries
|
83 |
+
example_queries = [{"text" : "Piv eo Albert Einstein ?"}, {"text" : "Petra eo kêr vrasañ Breizh ?"}, {"text" : "Kont din ur farsadenn bugel ?"}]
|
84 |
+
|
85 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
86 |
|
87 |
gr.Markdown("# BreizhBot\n## Breton Chatbot (Translation based)\nPart of the [GweLLM](https://github.com/blackccpie/GweLLM) project")
|
|
|
89 |
chatbot = gr.Chatbot(
|
90 |
label="Chat",
|
91 |
placeholder="Degemer mat, petra a c'hellan ober evidoc'h ?",
|
92 |
+
examples=example_queries,
|
93 |
type="messages")
|
94 |
msg = gr.Textbox(label='User Input')
|
95 |
|
|
|
102 |
|
103 |
chatbot.clear(clear, inputs=[chatbot])
|
104 |
|
105 |
+
def example_input(evt: gr.SelectData):
|
106 |
+
"""
|
107 |
+
Handles example input selection
|
108 |
+
"""
|
109 |
+
return evt.value["text"]
|
110 |
+
|
111 |
def user_input(message, chat_history):
|
112 |
"""
|
113 |
Handles instant display of the user query (without waiting for model answer)
|
|
|
142 |
|
143 |
return "", chat_history
|
144 |
|
145 |
+
chatbot.example_select(example_input, None, msg).then(user_input, [msg, chatbot], chatbot).then(respond, [msg, chatbot], [msg, chatbot])
|
146 |
+
|
147 |
msg.submit(user_input, [msg, chatbot], chatbot).then(respond, [msg, chatbot], [msg, chatbot])
|
148 |
|
149 |
if __name__ == "__main__":
|