Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,6 +16,7 @@ from pydantic import BaseModel
|
|
| 16 |
from typing import List, Optional, AsyncGenerator
|
| 17 |
import asyncio
|
| 18 |
import gradio as gr
|
|
|
|
| 19 |
|
| 20 |
# ==============================================================================
|
| 21 |
# Model Architecture (Same as before)
|
|
@@ -446,7 +447,7 @@ async def chat_completions(request: ChatCompletionRequest):
|
|
| 446 |
"finish_reason": None
|
| 447 |
}]
|
| 448 |
}
|
| 449 |
-
yield f"
|
| 450 |
yield " [DONE]\n\n"
|
| 451 |
|
| 452 |
if request.stream:
|
|
@@ -471,7 +472,7 @@ async def list_models():
|
|
| 471 |
|
| 472 |
|
| 473 |
# ==============================================================================
|
| 474 |
-
#
|
| 475 |
# ==============================================================================
|
| 476 |
|
| 477 |
def get_api_info():
|
|
@@ -501,10 +502,13 @@ Set `"stream": true` in your request to receive real-time token-by-token respons
|
|
| 501 |
"stream": true,
|
| 502 |
"temperature": 0.7
|
| 503 |
}}
|
| 504 |
-
|
|
|
|
|
|
|
|
|
|
| 505 |
with gr.Blocks(title="SAM-X-1 API") as demo:
|
| 506 |
gr.Markdown(get_api_info())
|
| 507 |
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
|
|
|
| 16 |
from typing import List, Optional, AsyncGenerator
|
| 17 |
import asyncio
|
| 18 |
import gradio as gr
|
| 19 |
+
from gradio import HTML
|
| 20 |
|
| 21 |
# ==============================================================================
|
| 22 |
# Model Architecture (Same as before)
|
|
|
|
| 447 |
"finish_reason": None
|
| 448 |
}]
|
| 449 |
}
|
| 450 |
+
yield f" {json.dumps(chunk)}\n\n"
|
| 451 |
yield " [DONE]\n\n"
|
| 452 |
|
| 453 |
if request.stream:
|
|
|
|
| 472 |
|
| 473 |
|
| 474 |
# ==============================================================================
|
| 475 |
+
# Gradio App (API Info Page)
|
| 476 |
# ==============================================================================
|
| 477 |
|
| 478 |
def get_api_info():
|
|
|
|
| 502 |
"stream": true,
|
| 503 |
"temperature": 0.7
|
| 504 |
}}
|
| 505 |
+
```
|
| 506 |
+
"""
|
| 507 |
+
|
| 508 |
+
# Create the Gradio app
|
| 509 |
with gr.Blocks(title="SAM-X-1 API") as demo:
|
| 510 |
gr.Markdown(get_api_info())
|
| 511 |
|
| 512 |
+
# Launch Gradio app with FastAPI mounted
|
| 513 |
+
if __name__ == "__main__":
|
| 514 |
+
demo.launch(server_name="0.0.0.0", server_port=7860, show_error=True)
|