Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
@@ -1,80 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from huggingface_hub import InferenceClient
|
3 |
-
from huggingface_hub import login
|
4 |
-
import os
|
5 |
-
import time
|
6 |
-
|
7 |
-
L_ogin = os.getenv('token')
|
8 |
-
KHEOPS_E3_V14 = os.getenv('KHEOPS_E3_V14')
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
"""
|
13 |
-
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
14 |
-
"""
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
import time
|
20 |
-
|
21 |
-
def respond(
|
22 |
-
message,
|
23 |
-
history: list[tuple[str, str]],
|
24 |
-
model_id,
|
25 |
-
system_message,
|
26 |
-
max_tokens,
|
27 |
-
temperature,
|
28 |
-
top_p,
|
29 |
-
):
|
30 |
-
client = InferenceClient(token=L_ogin,timeout = 30, model=KHEOPS_E3_V14)
|
31 |
-
messages = [{"role": "system", "content": system_message}]
|
32 |
-
|
33 |
-
for val in history:
|
34 |
-
if val[0]:
|
35 |
-
messages.append({"role": "user", "content": val[0]})
|
36 |
-
if val[1]:
|
37 |
-
messages.append({"role": "assistant", "content": val[1]})
|
38 |
-
|
39 |
-
messages.append({"role": "user", "content": message})
|
40 |
-
|
41 |
-
response = ""
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
for message in client.chat_completion(
|
46 |
-
messages,
|
47 |
-
max_tokens=max_tokens,
|
48 |
-
stream=True,
|
49 |
-
temperature=temperature,
|
50 |
-
top_p=top_p,
|
51 |
-
):
|
52 |
-
token = message.choices[0].delta.content
|
53 |
-
if token is None:
|
54 |
-
token = ""
|
55 |
-
response += token
|
56 |
-
yield response
|
57 |
-
|
58 |
-
|
59 |
-
"""
|
60 |
-
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
61 |
-
"""
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
system_promp = 'You are Kheops developped by Kheops AI, an advanced AI assistant designed to engage with users by providing clear, accurate, and helpful information across various topics. Your primary objectives are to deliver responses that are concise and factually correct, avoiding unnecessary jargon unless requested by the user. Maintain a friendly, professional, and positive tone, adapting your communication style to match the users language, tone, and knowledge level, whether formal or casual. Focus on offering practical and concrete solutions to the users queries, and if you do not have an answer, be honest and suggest alternative ways for the user to find the information. Always protect the privacy of the user by avoiding the request or storage of sensitive personal information and ensuring confidentiality in all conversations. Your goal is to assist, inform, and engage in a manner that is both helpful and respectful, ensuring every interaction is as positive and productive as possible.'
|
67 |
-
demo = gr.ChatInterface(
|
68 |
-
respond,
|
69 |
-
additional_inputs=[
|
70 |
-
#gr.Dropdown(label="Choose a KHEOPS Model", KHEOPS E3 V14, value = "KHEOPS E3 V14"),
|
71 |
-
gr.Textbox(visible=True,value=system_promp, label="System message"),
|
72 |
-
gr.Slider(visible=False,minimum=1, maximum=4232, value=2000, step=1, label="Max new tokens"),
|
73 |
-
gr.Slider(minimum=0.1, maximum=1.0, value=0.4, step=0.05, label="Temperature"),
|
74 |
-
gr.Slider(visible=False,minimum=0.1,maximum=1.0,value=0.95,step=0.05,label="Top-p (nucleus sampling)"),
|
75 |
-
],
|
76 |
-
)
|
77 |
-
|
78 |
-
|
79 |
-
if __name__ == "__main__":
|
80 |
-
demo.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|