SteadySurfdom commited on
Commit
607080f
·
verified ·
1 Parent(s): b5d66d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -21,7 +21,12 @@ def generate_summary(file, prompt, model, output_format, temperature, top_p):
21
  return "Please provide a prompt."
22
 
23
  file_text = file_to_string(file) if file else ""
24
- full_prompt = f"{prompt}\n{file_text}" if file_text else prompt
 
 
 
 
 
25
 
26
  try:
27
  client = Groq(api_key=os.environ["GROQ_API_KEY"])
@@ -62,7 +67,7 @@ with gr.Blocks() as iface:
62
 
63
  with gr.Row():
64
  file_input = gr.File(label="Upload File (Optional)")
65
- prompt_input = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...", lines=3)
66
 
67
  with gr.Row():
68
  model_dropdown = gr.Dropdown(label="Choose Model", choices=["llama-3.1-8b-instant", "llama-3.1-70b-versatile"], value="llama-3.1-70b-versatile")
 
21
  return "Please provide a prompt."
22
 
23
  file_text = file_to_string(file) if file else ""
24
+
25
+ # Check if the {PDF_TEXT} token is in the prompt
26
+ if "{PDF_TEXT}" in prompt and file_text:
27
+ full_prompt = prompt.replace("{PDF_TEXT}", file_text)
28
+ else:
29
+ full_prompt = f"{prompt}\n{file_text}" if file_text else prompt
30
 
31
  try:
32
  client = Groq(api_key=os.environ["GROQ_API_KEY"])
 
67
 
68
  with gr.Row():
69
  file_input = gr.File(label="Upload File (Optional)")
70
+ prompt_input = gr.Textbox(label="Prompt", placeholder="Enter your prompt here... Use {PDF_TEXT} to insert PDF content at a specific location.", lines=3)
71
 
72
  with gr.Row():
73
  model_dropdown = gr.Dropdown(label="Choose Model", choices=["llama-3.1-8b-instant", "llama-3.1-70b-versatile"], value="llama-3.1-70b-versatile")