import gradio as gr from models import load_model, generate_response from utils import format_history from config import MODEL_NAME, MAX_LENGTH, TEMPERATURE def chat_response(message, history): # Format history for the model formatted_history = format_history(history) # Generate response using the model response = generate_response(message, formatted_history, max_length=MAX_LENGTH, temperature=TEMPERATURE) return response with gr.Blocks() as demo: gr.HTML("""

AI Chatbot for Chat and Code

Powered by microsoft/Phi-2

Built with anycoder

""") chatbot = gr.ChatInterface( fn=chat_response, title="Chat and Code Assistant", description="Ask me anything about coding, chat, or general questions!", examples=["Write a Python function to reverse a string", "Explain recursion", "Hello, how are you?"], theme=gr.themes.Soft() ) if __name__ == "__main__": demo.launch()