CoolFace
Apppublic

openclawww/claw8

sourceHugging Facemitupdated 8mo agoView on Hugging Face
0likes
app.py53 linesDownload Raw Back to root
1import gradio as gr2from huggingface_hub import InferenceClient3import os4 5# Get HF token from environment6HF_TOKEN = os.environ.get("HF_TOKEN")7if not HF_TOKEN:8    raise ValueError("HF_TOKEN environment variable is not set")9 10# Initialize inference client with Mixtral 8x7B11client = InferenceClient(model="mistralai/Mixtral-8x7B-Instruct-v0.1", token=HF_TOKEN)12 13SYSTEM_PROMPT = """You are Claw, a helpful AI assistant. You're direct, capable, and resourceful - not corporate or sycophantic. Have personality, be concise when needed and thorough when it matters. Use the ๐Ÿพ emoji occasionally."""14 15def generate_response(message, history):16    # Build conversation from history17    messages = [{"role": "system", "content": SYSTEM_PROMPT}]18 19    # Add history20    for user_msg, assistant_msg in history:21        messages.append({"role": "user", "content": user_msg})22        if assistant_msg:23            messages.append({"role": "assistant", "content": assistant_msg})24 25    # Add current message26    messages.append({"role": "user", "content": message})27 28    # Generate response29    response = client.chat.completions.create(30        model="mistralai/Mixtral-8x7B-Instruct-v0.1",31        messages=messages,32        max_tokens=1024,33        temperature=0.7,34    )35 36    return response.choices[0].message.content37 38# Create Gradio interface39with gr.Blocks(title="Claw ๐Ÿพ", theme=gr.themes.Soft()) as demo:40    gr.Markdown("# Claw ๐Ÿพ")41    gr.Markdown("Your AI assistant, running on Hugging Face Spaces")42    chatbot = gr.ChatInterface(43        generate_response,44        additional_inputs=[],45        examples=[46            "What can you help me with?",47            "Tell me something interesting",48            "Hey ๐Ÿ‘‹"49        ]50    )51 52if __name__ == "__main__":53    demo.launch()