Remostart commited on
Commit
f651fa3
·
verified ·
1 Parent(s): 22ee565

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -39,11 +39,11 @@ TOPICS = [
39
  "Other"
40
  ]
41
 
42
- # Improved prompt template for dyslexia-friendly, standalone response
43
  def create_prompt(personality, level, topic):
44
- return f"Explain {topic} in Plutus for a {level} programmer with {personality} traits. For Beginer levels, Use extremely simple words and everyday examples, like comparing Plutus to a vending machine. Avoid technical jargon like 'decentralized,' 'formal verification,' or 'immutability.' Use short sentences (10 words or less). Break the explanation into 3-4 bullet points. Include one simple analogy. Structure the response with a short introduction (2 sentences), bullet points, and a 1-sentence conclusion. Do not repeat the topic or prompt. Do not simulate a conversation, ask questions, or add follow-up content. Use a direct, instructional tone without personal pronouns like 'I' or 'we.' Conclude with a clear summary sentence."
45
 
46
- # Response function with improved generation parameters
47
  def generate_response(personality, level, topic):
48
  try:
49
  logger.info("Processing selections...")
@@ -58,9 +58,9 @@ def generate_response(personality, level, topic):
58
  "streamer": streamer,
59
  "max_new_tokens": 600, # Increased to avoid cut-offs
60
  "do_sample": True,
61
- "temperature": 0.2,
62
- "top_p": 0.2,
63
- "repetition_penalty": 1.4, # Increased to prevent repetition
64
  "eos_token_id": tokenizer.eos_token_id,
65
  "pad_token_id": tokenizer.pad_token_id
66
  }
@@ -87,7 +87,7 @@ with gr.Blocks(title="Cardano Plutus AI Assistant") as demo:
87
  personality = gr.Dropdown(
88
  choices=PERSONALITY_TYPES,
89
  label="Personality Type",
90
- value="Dyslexic"
91
  )
92
  level = gr.Dropdown(
93
  choices=PROGRAMMING_LEVELS,
@@ -97,7 +97,7 @@ with gr.Blocks(title="Cardano Plutus AI Assistant") as demo:
97
  topic = gr.Dropdown(
98
  choices=TOPICS,
99
  label="Topic",
100
- value="What is Plutus"
101
  )
102
 
103
  generate_btn = gr.Button("Generate")
 
39
  "Other"
40
  ]
41
 
42
+ # Improved prompt template for autism-friendly, focused response
43
  def create_prompt(personality, level, topic):
44
+ return f"Explain {topic} in Plutus for a {level} programmer with {personality} traits. Use only basic words and clear examples. Use a physical object analogy (e.g., a lock or checklist) tied to {topic}. Avoid jargon like 'blockchain,' 'ledger,' 'Haskell,' 'decentralized,' 'cyber,' 'e-commerce,' 'formal verification,' or 'immutability.' Use short sentences (6-8 words). Use exactly 3 numbered points for key ideas. Each point must have 5-10 words. Bold the first word of each point. Structure the response: 2-sentence introduction, 3 numbered points, 1-sentence conclusion. For Autistic traits, use literal language, numbered lists, and **bold key terms**. Repeat key ideas for clarity. Avoid abstract terms or metaphors unless concrete. Do not repeat the topic or prompt. Do not simulate a conversation, ask questions, or discuss unrelated topics like blockchain or cybersecurity. Use a direct, instructional tone without 'I,' 'we,' or conversational phrases. End with a summary sentence on {topic}’s importance. Use double line breaks between introduction, points, and conclusion for readability."
45
 
46
+ # Response function with improved parameters
47
  def generate_response(personality, level, topic):
48
  try:
49
  logger.info("Processing selections...")
 
58
  "streamer": streamer,
59
  "max_new_tokens": 600, # Increased to avoid cut-offs
60
  "do_sample": True,
61
+ "temperature": 0.1, # Lowered for focused output
62
+ "top_p": 0.1, # Lowered for focused output
63
+ "repetition_penalty": 1.7, # Increased to prevent tangents
64
  "eos_token_id": tokenizer.eos_token_id,
65
  "pad_token_id": tokenizer.pad_token_id
66
  }
 
87
  personality = gr.Dropdown(
88
  choices=PERSONALITY_TYPES,
89
  label="Personality Type",
90
+ value="Autistic"
91
  )
92
  level = gr.Dropdown(
93
  choices=PROGRAMMING_LEVELS,
 
97
  topic = gr.Dropdown(
98
  choices=TOPICS,
99
  label="Topic",
100
+ value="Introduction to Validation"
101
  )
102
 
103
  generate_btn = gr.Button("Generate")