Spaces:
Runtime error
Runtime error
| from transformers import pipeline | |
| import gradio as gr | |
| from fastapi import FastAPI | |
| from gradio_client import Client | |
| from typing import Union | |
| import uvicorn | |
| app = FastAPI() | |
| chatbot = pipeline(model="facebook/blenderbot-400M-distill") | |
| def DS_chatbot(message,history): | |
| conversation = chatbot(message) | |
| return conversation[0]['generated_text'] | |
| io = gr.ChatInterface(DS_chatbot, title=" DS Chatbot", description="Enter text to start chatting.") | |
| async def read_main(): | |
| return {"Instruction1": "Append /gradio to the url to see gradio the interface" | |
| ,"Instruction2": "Append /hello/{any_name} to get a greeting"} | |
| async def read_name(name: Union[str, None] = None): | |
| return { "Hey!": name} | |
| # Mount the Gradio app onto the FastAPI app | |
| app = gr.mount_gradio_app(app, io, path='/gradio') | |
| if __name__ == "__main__": | |
| uvicorn.run(app, host="0.0.0.0", port=7860) |