Spaces:
Runtime error
Runtime error
aresnow
commited on
Commit
•
a9bd2fc
1
Parent(s):
da0667c
Arena as fisrt tab
Browse files- app.py +25 -18
- requirements.txt +1 -1
app.py
CHANGED
@@ -403,21 +403,21 @@ class GradioApp:
|
|
403 |
return chat, model_text
|
404 |
|
405 |
def _build_arena_with_launched(self, models: List[Tuple[str, ModelSpec]]):
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
]
|
412 |
-
chats = [c[0] for c in chat_and_text]
|
413 |
-
texts = [c[1] for c in chat_and_text]
|
414 |
|
415 |
-
|
|
|
416 |
|
417 |
-
|
418 |
-
return "", text_in, text_in
|
419 |
|
420 |
-
|
|
|
|
|
|
|
421 |
|
422 |
gr.ClearButton(components=[msg] + chats + texts)
|
423 |
|
@@ -425,6 +425,9 @@ class GradioApp:
|
|
425 |
if self._use_launched_model:
|
426 |
models = self._api.list_models()
|
427 |
with gr.Blocks() as blocks:
|
|
|
|
|
|
|
428 |
with gr.Tab(self._locale("Chat")):
|
429 |
chat, model_text = self._build_single_with_launched(models, 0)
|
430 |
msg = gr.Textbox(label=self._locale("Input"))
|
@@ -434,9 +437,6 @@ class GradioApp:
|
|
434 |
|
435 |
msg.submit(update_message, inputs=[msg], outputs=[msg, model_text])
|
436 |
gr.ClearButton(components=[chat, msg, model_text])
|
437 |
-
if len(models) > 2:
|
438 |
-
with gr.Tab(self._locale("Arena")):
|
439 |
-
self._build_arena_with_launched(models)
|
440 |
else:
|
441 |
with gr.Blocks() as blocks:
|
442 |
with gr.Tab(self._locale("Chat")):
|
@@ -450,16 +450,23 @@ class GradioApp:
|
|
450 |
async def launch_xinference():
|
451 |
import xoscar as xo
|
452 |
from xinference.core.service import SupervisorActor
|
|
|
453 |
from xinference.deploy.worker import start_worker_components
|
454 |
|
455 |
pool = await xo.create_actor_pool(address="0.0.0.0", n_process=0)
|
|
|
456 |
await xo.create_actor(
|
457 |
-
SupervisorActor, address=
|
458 |
)
|
459 |
await start_worker_components(
|
460 |
-
address=
|
461 |
)
|
462 |
-
|
|
|
|
|
|
|
|
|
|
|
463 |
gradio_block.launch()
|
464 |
|
465 |
|
|
|
403 |
return chat, model_text
|
404 |
|
405 |
def _build_arena_with_launched(self, models: List[Tuple[str, ModelSpec]]):
|
406 |
+
chat_and_text = []
|
407 |
+
with gr.Row():
|
408 |
+
for i in range(self._gladiator_num):
|
409 |
+
with gr.Column():
|
410 |
+
chat_and_text.append(self._build_single_with_launched(models, i))
|
|
|
|
|
|
|
411 |
|
412 |
+
chats = [c[0] for c in chat_and_text]
|
413 |
+
texts = [c[1] for c in chat_and_text]
|
414 |
|
415 |
+
msg = gr.Textbox(label=self._locale("Input"))
|
|
|
416 |
|
417 |
+
def update_message(text_in: str):
|
418 |
+
return "", text_in, text_in
|
419 |
+
|
420 |
+
msg.submit(update_message, inputs=[msg], outputs=[msg] + texts)
|
421 |
|
422 |
gr.ClearButton(components=[msg] + chats + texts)
|
423 |
|
|
|
425 |
if self._use_launched_model:
|
426 |
models = self._api.list_models()
|
427 |
with gr.Blocks() as blocks:
|
428 |
+
if len(models) >= 2:
|
429 |
+
with gr.Tab(self._locale("Arena")):
|
430 |
+
self._build_arena_with_launched(models)
|
431 |
with gr.Tab(self._locale("Chat")):
|
432 |
chat, model_text = self._build_single_with_launched(models, 0)
|
433 |
msg = gr.Textbox(label=self._locale("Input"))
|
|
|
437 |
|
438 |
msg.submit(update_message, inputs=[msg], outputs=[msg, model_text])
|
439 |
gr.ClearButton(components=[chat, msg, model_text])
|
|
|
|
|
|
|
440 |
else:
|
441 |
with gr.Blocks() as blocks:
|
442 |
with gr.Tab(self._locale("Chat")):
|
|
|
450 |
async def launch_xinference():
|
451 |
import xoscar as xo
|
452 |
from xinference.core.service import SupervisorActor
|
453 |
+
from xinference.core.api import AsyncSupervisorAPI
|
454 |
from xinference.deploy.worker import start_worker_components
|
455 |
|
456 |
pool = await xo.create_actor_pool(address="0.0.0.0", n_process=0)
|
457 |
+
supervisor_address = pool.external_address
|
458 |
await xo.create_actor(
|
459 |
+
SupervisorActor, address=supervisor_address, uid=SupervisorActor.uid()
|
460 |
)
|
461 |
await start_worker_components(
|
462 |
+
address=supervisor_address, supervisor_address=supervisor_address
|
463 |
)
|
464 |
+
api = AsyncSupervisorAPI(supervisor_address)
|
465 |
+
supported_models = ["orca", "chatglm2", "chatglm", "vicuna-v1.3"]
|
466 |
+
for model in supported_models:
|
467 |
+
await api.launch_model(str(uuid.uuid4()), model)
|
468 |
+
|
469 |
+
gradio_block = GradioApp(supervisor_address, use_launched_model=True).build()
|
470 |
gradio_block.launch()
|
471 |
|
472 |
|
requirements.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
xinference
|
2 |
xoscar
|
3 |
chatglm-cpp
|
4 |
llama-cpp-python
|
|
|
1 |
+
xinference @ git+https://github.com/aresnow1/inference.git@bugfix/model-lock
|
2 |
xoscar
|
3 |
chatglm-cpp
|
4 |
llama-cpp-python
|