ari7cr commited on
Commit
8b369df
·
verified ·
1 Parent(s): 2cf432b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -6,7 +6,7 @@ import torch
6
  physician = pipeline("text-generation", model="HuggingFaceTB/SmolLM2-1.7B-Instruct")
7
  patient = pipeline("text-generation", model="HuggingFaceTB/SmolLM2-1.7B-Instruct")
8
 
9
- # System prompts to define roles
10
  patient_system_prompt = "You are a patient describing your symptoms to a physician."
11
  physician_system_prompt = "You are a physician responding to a patient's symptoms."
12
 
@@ -17,10 +17,10 @@ def generate_conversation(topic, turns):
17
  patient_tokens = 0
18
 
19
  # Initial prompt for the patient
20
- patient_prompt = f"I'm here to talk about {topic}."
21
- print(f"Patient Initial Prompt: {patient_prompt}") # Debugging
22
  patient_response = patient(
23
- f"{patient_system_prompt} {patient_prompt}",
24
  max_length=50, # Reduce max_length for faster responses
25
  num_return_sequences=1,
26
  truncation=True, # Explicitly enable truncation
@@ -35,7 +35,7 @@ def generate_conversation(topic, turns):
35
  # Physician's turn
36
  print(f"Physician Turn {turn} Prompt: {patient_response}") # Debugging
37
  physician_response = physician(
38
- f"{physician_system_prompt} Patient says: {patient_response}",
39
  max_length=50, # Reduce max_length for faster responses
40
  num_return_sequences=1,
41
  truncation=True, # Explicitly enable truncation
@@ -49,7 +49,7 @@ def generate_conversation(topic, turns):
49
  # Patient's turn
50
  print(f"Patient Turn {turn} Prompt: {physician_response}") # Debugging
51
  patient_response = patient(
52
- f"{patient_system_prompt} Physician says: {physician_response}",
53
  max_length=50, # Reduce max_length for faster responses
54
  num_return_sequences=1,
55
  truncation=True, # Explicitly enable truncation
 
6
  physician = pipeline("text-generation", model="HuggingFaceTB/SmolLM2-1.7B-Instruct")
7
  patient = pipeline("text-generation", model="HuggingFaceTB/SmolLM2-1.7B-Instruct")
8
 
9
+ # System prompts to define roles (not included in the input prompt)
10
  patient_system_prompt = "You are a patient describing your symptoms to a physician."
11
  physician_system_prompt = "You are a physician responding to a patient's symptoms."
12
 
 
17
  patient_tokens = 0
18
 
19
  # Initial prompt for the patient
20
+ patient_input = f"Patient: I'm here to talk about {topic}."
21
+ print(f"Patient Initial Input: {patient_input}") # Debugging
22
  patient_response = patient(
23
+ patient_input, # Only the patient's message, without the system prompt
24
  max_length=50, # Reduce max_length for faster responses
25
  num_return_sequences=1,
26
  truncation=True, # Explicitly enable truncation
 
35
  # Physician's turn
36
  print(f"Physician Turn {turn} Prompt: {patient_response}") # Debugging
37
  physician_response = physician(
38
+ f"Physician: {patient_response}", # Only the physician's response to the patient's message
39
  max_length=50, # Reduce max_length for faster responses
40
  num_return_sequences=1,
41
  truncation=True, # Explicitly enable truncation
 
49
  # Patient's turn
50
  print(f"Patient Turn {turn} Prompt: {physician_response}") # Debugging
51
  patient_response = patient(
52
+ f"Patient: {physician_response}", # Only the patient's response to the physician's message
53
  max_length=50, # Reduce max_length for faster responses
54
  num_return_sequences=1,
55
  truncation=True, # Explicitly enable truncation