Spaces:
Runtime error
Runtime error
ffreemt
commited on
Commit
·
015321b
1
Parent(s):
b836071
- app.py +15 -9
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -7,20 +7,19 @@ from dataclasses import asdict, dataclass
|
|
| 7 |
import gradio as gr
|
| 8 |
from ctransformers import AutoConfig, AutoModelForCausalLM
|
| 9 |
|
| 10 |
-
|
| 11 |
from huggingface_hub import hf_hub_download
|
| 12 |
from loguru import logger
|
| 13 |
|
| 14 |
-
URL = os.
|
| 15 |
-
|
| 16 |
if URL is None:
|
| 17 |
raise ValueError("URL environment variable must be set")
|
| 18 |
-
if
|
| 19 |
raise ValueError("git environment variable must be set")
|
| 20 |
-
# """
|
| 21 |
|
| 22 |
|
| 23 |
-
def predict0(prompt, bot
|
| 24 |
logger.debug(f"{prompt=}, {bot=}, {timeout=}")
|
| 25 |
try:
|
| 26 |
user_prompt = prompt
|
|
@@ -242,11 +241,11 @@ generation_config = GenerationConfig(
|
|
| 242 |
)
|
| 243 |
|
| 244 |
user_prefix = "[user]: "
|
| 245 |
-
assistant_prefix = "[assistant]:"
|
| 246 |
|
| 247 |
with gr.Blocks(
|
| 248 |
theme=gr.themes.Soft(),
|
| 249 |
-
css=".disclaimer {font-variant-caps: all-small-caps;}",
|
| 250 |
) as demo:
|
| 251 |
gr.Markdown(
|
| 252 |
"""<h1><center>MosaicML MPT-30B-Chat</center></h1>
|
|
@@ -258,7 +257,7 @@ with gr.Blocks(
|
|
| 258 |
"""
|
| 259 |
)
|
| 260 |
conversation = Chat()
|
| 261 |
-
chatbot = gr.Chatbot().style(height=500
|
| 262 |
with gr.Row():
|
| 263 |
with gr.Column():
|
| 264 |
msg = gr.Textbox(
|
|
@@ -349,5 +348,12 @@ with gr.Blocks(
|
|
| 349 |
)
|
| 350 |
# """
|
| 351 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 352 |
|
| 353 |
demo.queue(max_size=36, concurrency_count=14).launch(debug=True)
|
|
|
|
| 7 |
import gradio as gr
|
| 8 |
from ctransformers import AutoConfig, AutoModelForCausalLM
|
| 9 |
|
| 10 |
+
from mcli import predict
|
| 11 |
from huggingface_hub import hf_hub_download
|
| 12 |
from loguru import logger
|
| 13 |
|
| 14 |
+
URL = os.getenv("URL", "")
|
| 15 |
+
MOSAICML_API_KEY = os.getenv("MOSAICML_API_KEY", "")
|
| 16 |
if URL is None:
|
| 17 |
raise ValueError("URL environment variable must be set")
|
| 18 |
+
if MOSAICML_API_KEY is None:
|
| 19 |
raise ValueError("git environment variable must be set")
|
|
|
|
| 20 |
|
| 21 |
|
| 22 |
+
def predict0(prompt, bot):
|
| 23 |
logger.debug(f"{prompt=}, {bot=}, {timeout=}")
|
| 24 |
try:
|
| 25 |
user_prompt = prompt
|
|
|
|
| 241 |
)
|
| 242 |
|
| 243 |
user_prefix = "[user]: "
|
| 244 |
+
assistant_prefix = "[assistant]: "
|
| 245 |
|
| 246 |
with gr.Blocks(
|
| 247 |
theme=gr.themes.Soft(),
|
| 248 |
+
css=".disclaimer {font-variant-caps: all-small-caps; font-size: small;}",
|
| 249 |
) as demo:
|
| 250 |
gr.Markdown(
|
| 251 |
"""<h1><center>MosaicML MPT-30B-Chat</center></h1>
|
|
|
|
| 257 |
"""
|
| 258 |
)
|
| 259 |
conversation = Chat()
|
| 260 |
+
chatbot = gr.Chatbot().style(height=200) # 500
|
| 261 |
with gr.Row():
|
| 262 |
with gr.Column():
|
| 263 |
msg = gr.Textbox(
|
|
|
|
| 348 |
)
|
| 349 |
# """
|
| 350 |
|
| 351 |
+
msg.submit(
|
| 352 |
+
# fn=conversation.user_turn,
|
| 353 |
+
fn=predict0,
|
| 354 |
+
inputs=[msg, chatbot],
|
| 355 |
+
outputs=[msg, chatbot],
|
| 356 |
+
queue=False,
|
| 357 |
+
)
|
| 358 |
|
| 359 |
demo.queue(max_size=36, concurrency_count=14).launch(debug=True)
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
ctransformers==0.2.10
|
| 2 |
transformers==4.30.2
|
| 3 |
huggingface_hub
|
|
|
|
| 1 |
+
mosaicml-cli
|
| 2 |
ctransformers==0.2.10
|
| 3 |
transformers==4.30.2
|
| 4 |
huggingface_hub
|