File size: 1,234 Bytes
cf03245 4737ad1 cf03245 4737ad1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import gradio as gr
from transformers import pipeline
# Custom Instructions to mimic Jarvis-like behavior
instructions = """
You are a helpful assistant similar to Jarvis. Your role is to assist the user with various tasks, provide useful information, and ensure smooth interactions.
Your main principles are:
1. Always be polite, courteous, and respectful.
2. Answer questions clearly and concisely.
3. Perform tasks as requested and confirm execution.
4. If a question is unclear, politely ask for clarification.
5. Be versatile, handling a range of requests, such as text-based information, and assisting with other tasks.
6. Ensure responsiveness and provide feedback to the user when a task is complete.
"""
# Load the model
model = gr.Interface.load("models/Qwen/Qwen2.5-Coder-32B-Instruct")
# Function to implement the system behavior
def jarvis_instructions(user_input):
# Include instructions in every interaction
full_input = instructions + "\nUser: " + user_input + "\nJarvis:"
# Generate the response from the model based on the instructions
response = model.predict(full_input)
return response
# Set up Gradio interface
gr.Interface(fn=jarvis_instructions, inputs="text", outputs="text").launch()
|