Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -59,70 +59,3 @@ demo = gr.ChatInterface(
|
|
59 |
|
60 |
if __name__ == "__main__":
|
61 |
demo.launch()
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
"""
|
67 |
-
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
|
68 |
-
"""
|
69 |
-
##client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
70 |
-
|
71 |
-
"""
|
72 |
-
def respond(
|
73 |
-
message,
|
74 |
-
history: list[tuple[str, str]],
|
75 |
-
system_message,
|
76 |
-
max_tokens,
|
77 |
-
temperature,
|
78 |
-
top_p,
|
79 |
-
):
|
80 |
-
messages = [{"role": "system", "content": system_message}]
|
81 |
-
|
82 |
-
for val in history:
|
83 |
-
if val[0]:
|
84 |
-
messages.append({"role": "user", "content": val[0]})
|
85 |
-
if val[1]:
|
86 |
-
messages.append({"role": "assistant", "content": val[1]})
|
87 |
-
|
88 |
-
messages.append({"role": "user", "content": message})
|
89 |
-
|
90 |
-
response = ""
|
91 |
-
|
92 |
-
for message in client.chat_completion(
|
93 |
-
messages,
|
94 |
-
max_tokens=max_tokens,
|
95 |
-
stream=True,
|
96 |
-
temperature=temperature,
|
97 |
-
top_p=top_p,
|
98 |
-
):
|
99 |
-
token = message.choices[0].delta.content
|
100 |
-
|
101 |
-
response += token
|
102 |
-
yield response
|
103 |
-
|
104 |
-
"""
|
105 |
-
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
106 |
-
"""
|
107 |
-
demo = gr.ChatInterface(
|
108 |
-
respond,
|
109 |
-
additional_inputs=[
|
110 |
-
gr.Textbox(value="You are a maritime legal assistant with expertise strictly in indian maritime law. Provide detailed legal advice and information based on indian maritime legal principles and regulations.", label="System message"),
|
111 |
-
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
112 |
-
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
113 |
-
gr.Slider(
|
114 |
-
minimum=0.1,
|
115 |
-
maximum=1.0,
|
116 |
-
value=0.95,
|
117 |
-
step=0.05,
|
118 |
-
label="Top-p (nucleus sampling)",
|
119 |
-
),
|
120 |
-
],
|
121 |
-
title="Maritime Legal Compliance",
|
122 |
-
description="This chatbot uses the fine tune Llama 3.1 which has the capabilities of responding and helping in legal advices regarding maritime",
|
123 |
-
)
|
124 |
-
|
125 |
-
|
126 |
-
if __name__ == "__main__":
|
127 |
-
demo.launch()
|
128 |
-
"""
|
|
|
59 |
|
60 |
if __name__ == "__main__":
|
61 |
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|