|
from transformers import pipeline |
|
import gradio as gr |
|
|
|
|
|
chatbot = pipeline(model="morph-labs/morph-prover-v0-7b", |
|
max_length=512, |
|
) |
|
|
|
def vanilla_chatbot(message): |
|
try: |
|
|
|
formatted_message = f"[INST] <<SYS>>\nYou are a helpful assistant.\n<</SYS>>\n\n{message}[/INST]" |
|
|
|
|
|
output = chatbot(formatted_message, max_new_tokens=500) |
|
|
|
|
|
response = output[0] if output else "No response generated." |
|
|
|
|
|
return response |
|
except Exception as e: |
|
|
|
print(f"An unexpected error occurred: {e}") |
|
|
|
return "An unexpected error occurred." |
|
|
|
|
|
demo_chatbot = gr.Interface( |
|
fn=vanilla_chatbot, |
|
inputs="text", |
|
outputs="text", |
|
title="Vanilla Chatbot", |
|
description="Enter text to start chatting." |
|
) |
|
|
|
|
|
demo_chatbot.launch() |
|
|