Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -53,14 +53,13 @@ terminators = [
|
|
53 |
|
54 |
@spaces.GPU(duration=60)
|
55 |
def chat_llama3_8b(message: str,
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
"""
|
61 |
Generate a streaming response using the llama3-8b model.
|
62 |
"""
|
63 |
-
|
64 |
conversation = []
|
65 |
for user, assistant in history:
|
66 |
conversation.extend([
|
@@ -118,7 +117,7 @@ def chat_llama3_8b(message: str,
|
|
118 |
# Store the full response (including <think>) in history, but only show the user the cleaned response
|
119 |
history.append((message, full_response)) # Full assistant response saved for context
|
120 |
|
121 |
-
# JavaScript snippet
|
122 |
js_code = """
|
123 |
<script>
|
124 |
window.addEventListener("load", function(){
|
@@ -139,7 +138,7 @@ chatbot = gr.Chatbot(height=450, placeholder=PLACEHOLDER, label='Gradio ChatInte
|
|
139 |
with gr.Blocks(fill_height=True, css=css) as demo:
|
140 |
gr.Markdown(DESCRIPTION)
|
141 |
|
142 |
-
# Include the JavaScript
|
143 |
gr.HTML(js_code)
|
144 |
|
145 |
gr.ChatInterface(
|
@@ -159,10 +158,10 @@ with gr.Blocks(fill_height=True, css=css) as demo:
|
|
159 |
gr.Markdown("### Examples")
|
160 |
gr.Examples(
|
161 |
examples=[
|
162 |
-
['What is PrEP, and do I need it?'],
|
163 |
-
['What medications help manage being undetectable with HIV?'],
|
164 |
-
['How do I know if an abortion is the right option?'],
|
165 |
-
['How can I access birth-control in states where it is regulated?']
|
166 |
],
|
167 |
inputs=chatbot,
|
168 |
)
|
|
|
53 |
|
54 |
@spaces.GPU(duration=60)
|
55 |
def chat_llama3_8b(message: str,
|
56 |
+
history: list,
|
57 |
+
temperature: float,
|
58 |
+
max_new_tokens: int
|
59 |
+
) -> str:
|
60 |
"""
|
61 |
Generate a streaming response using the llama3-8b model.
|
62 |
"""
|
|
|
63 |
conversation = []
|
64 |
for user, assistant in history:
|
65 |
conversation.extend([
|
|
|
117 |
# Store the full response (including <think>) in history, but only show the user the cleaned response
|
118 |
history.append((message, full_response)) # Full assistant response saved for context
|
119 |
|
120 |
+
# JavaScript snippet to conditionally show examples if ?examples=true is present in the URL.
|
121 |
js_code = """
|
122 |
<script>
|
123 |
window.addEventListener("load", function(){
|
|
|
138 |
with gr.Blocks(fill_height=True, css=css) as demo:
|
139 |
gr.Markdown(DESCRIPTION)
|
140 |
|
141 |
+
# Include the JavaScript so it runs on the client side.
|
142 |
gr.HTML(js_code)
|
143 |
|
144 |
gr.ChatInterface(
|
|
|
158 |
gr.Markdown("### Examples")
|
159 |
gr.Examples(
|
160 |
examples=[
|
161 |
+
['What is PrEP, and do I need it?', ''],
|
162 |
+
['What medications help manage being undetectable with HIV?', ''],
|
163 |
+
['How do I know if an abortion is the right option?', ''],
|
164 |
+
['How can I access birth-control in states where it is regulated?', '']
|
165 |
],
|
166 |
inputs=chatbot,
|
167 |
)
|