seanpedrickcase commited on
Commit
9b97b7b
·
1 Parent(s): 6da6ac6

Updated requirements. More generous spaces GPU timeouts

Browse files
requirements.txt CHANGED
@@ -1,8 +1,8 @@
1
- pandas==2.3.1
2
  gradio==5.44.1
3
- transformers==4.55.2
4
  spaces==0.40.1
5
- boto3==1.40.11
6
  pyarrow==21.0.0
7
  openpyxl==3.1.5
8
  markdown==3.7
 
1
+ pandas==2.3.2
2
  gradio==5.44.1
3
+ transformers==4.56.0
4
  spaces==0.40.1
5
+ boto3==1.40.22
6
  pyarrow==21.0.0
7
  openpyxl==3.1.5
8
  markdown==3.7
requirements_aws.txt CHANGED
@@ -1,8 +1,8 @@
1
- pandas==2.3.1
2
  gradio==5.44.1
3
- transformers==4.55.2
4
  spaces==0.40.1
5
- boto3==1.40.11
6
  pyarrow==21.0.0
7
  openpyxl==3.1.5
8
  markdown==3.7
 
1
+ pandas==2.3.2
2
  gradio==5.44.1
3
+ transformers==4.56.0
4
  spaces==0.40.1
5
+ boto3==1.40.22
6
  pyarrow==21.0.0
7
  openpyxl==3.1.5
8
  markdown==3.7
requirements_gpu.txt CHANGED
@@ -1,8 +1,8 @@
1
- pandas==2.3.1
2
  gradio==5.44.1
3
- transformers==4.55.2
4
  spaces==0.40.1
5
- boto3==1.40.11
6
  pyarrow==21.0.0
7
  openpyxl==3.1.5
8
  markdown==3.7
 
1
+ pandas==2.3.2
2
  gradio==5.44.1
3
+ transformers==4.56.0
4
  spaces==0.40.1
5
+ boto3==1.40.22
6
  pyarrow==21.0.0
7
  openpyxl==3.1.5
8
  markdown==3.7
tools/dedup_summaries.py CHANGED
@@ -140,9 +140,6 @@ def deduplicate_topics(reference_df:pd.DataFrame,
140
  file_data = pd.DataFrame()
141
  deduplicated_unique_table_markdown = ""
142
 
143
- print('len(reference_df["Response References"].unique()):', len(reference_df["Response References"].unique()))
144
- print('len(topic_summary_df["Topic_number"].unique()):', len(topic_summary_df["Topic_number"].unique()))
145
-
146
  if (len(reference_df["Response References"].unique()) == 1) | (len(topic_summary_df["Topic_number"].unique()) == 1):
147
  print("Data file outputs are too short for deduplicating. Returning original data.")
148
 
@@ -449,9 +446,7 @@ def summarise_output_topics_query(model_choice:str, in_api_key:str, temperature:
449
 
450
  return response_text, conversation_history, whole_conversation_metadata
451
 
452
-
453
-
454
- @spaces.GPU
455
  def summarise_output_topics(sampled_reference_table_df:pd.DataFrame,
456
  topic_summary_df:pd.DataFrame,
457
  reference_table_df:pd.DataFrame,
@@ -670,6 +665,7 @@ def summarise_output_topics(sampled_reference_table_df:pd.DataFrame,
670
 
671
  return sampled_reference_table_df, topic_summary_df_revised, reference_table_df_revised, output_files, summarised_outputs, latest_summary_completed, out_metadata_str, summarised_output_markdown, log_output_files, output_files, acc_input_tokens, acc_output_tokens, acc_number_of_calls, time_taken
672
 
 
673
  def overall_summary(topic_summary_df:pd.DataFrame,
674
  model_choice:str,
675
  in_api_key:str,
 
140
  file_data = pd.DataFrame()
141
  deduplicated_unique_table_markdown = ""
142
 
 
 
 
143
  if (len(reference_df["Response References"].unique()) == 1) | (len(topic_summary_df["Topic_number"].unique()) == 1):
144
  print("Data file outputs are too short for deduplicating. Returning original data.")
145
 
 
446
 
447
  return response_text, conversation_history, whole_conversation_metadata
448
 
449
+ @spaces.GPU(duration=300)
 
 
450
  def summarise_output_topics(sampled_reference_table_df:pd.DataFrame,
451
  topic_summary_df:pd.DataFrame,
452
  reference_table_df:pd.DataFrame,
 
665
 
666
  return sampled_reference_table_df, topic_summary_df_revised, reference_table_df_revised, output_files, summarised_outputs, latest_summary_completed, out_metadata_str, summarised_output_markdown, log_output_files, output_files, acc_input_tokens, acc_output_tokens, acc_number_of_calls, time_taken
667
 
668
+ @spaces.GPU(duration=120)
669
  def overall_summary(topic_summary_df:pd.DataFrame,
670
  model_choice:str,
671
  in_api_key:str,
tools/llm_api_call.py CHANGED
@@ -648,7 +648,7 @@ def generate_zero_shot_topics_df(zero_shot_topics:pd.DataFrame,
648
 
649
  return zero_shot_topics_df
650
 
651
- @spaces.GPU(duration=60)
652
  def extract_topics(in_data_file: GradioFileData,
653
  file_data:pd.DataFrame,
654
  existing_topics_table:pd.DataFrame,
 
648
 
649
  return zero_shot_topics_df
650
 
651
+ @spaces.GPU(duration=300)
652
  def extract_topics(in_data_file: GradioFileData,
653
  file_data:pd.DataFrame,
654
  existing_topics_table:pd.DataFrame,
tools/llm_funcs.py CHANGED
@@ -533,7 +533,7 @@ def send_request(prompt: str, conversation_history: List[dict], google_client: a
533
  progress_bar = range(0,number_of_api_retry_attempts)
534
 
535
  # Generate the model's response
536
- if "gemini" in model_choice:
537
 
538
  for i in progress_bar:
539
  try:
@@ -541,7 +541,7 @@ def send_request(prompt: str, conversation_history: List[dict], google_client: a
541
 
542
  response = google_client.models.generate_content(model=model_choice, contents=full_prompt, config=config)
543
 
544
- print("Successful call to Gemini model.")
545
  break
546
  except Exception as e:
547
  # If fails, try again after X seconds in case there is a throttle limit
@@ -551,13 +551,13 @@ def send_request(prompt: str, conversation_history: List[dict], google_client: a
551
 
552
  if i == number_of_api_retry_attempts:
553
  return ResponseObject(text="", usage_metadata={'RequestId':"FAILED"}), conversation_history
554
- elif "anthropic.claude" in model_choice:
555
  for i in progress_bar:
556
  try:
557
  print("Calling AWS Claude model, attempt", i + 1)
558
  response = call_aws_claude(prompt, system_prompt, temperature, max_tokens, model_choice, bedrock_runtime=bedrock_runtime, assistant_prefill=assistant_prefill)
559
 
560
- print("Successful call to Claude model.")
561
  break
562
  except Exception as e:
563
  # If fails, try again after X seconds in case there is a throttle limit
@@ -566,7 +566,7 @@ def send_request(prompt: str, conversation_history: List[dict], google_client: a
566
 
567
  if i == number_of_api_retry_attempts:
568
  return ResponseObject(text="", usage_metadata={'RequestId':"FAILED"}), conversation_history
569
- else:
570
  # This is the local model
571
  for i in progress_bar:
572
  try:
@@ -577,7 +577,7 @@ def send_request(prompt: str, conversation_history: List[dict], google_client: a
577
 
578
  response = call_llama_cpp_chatmodel(prompt, system_prompt, gen_config, model=local_model)
579
 
580
- print("Successful call to local model.")
581
  break
582
  except Exception as e:
583
  # If fails, try again after X seconds in case there is a throttle limit
@@ -586,7 +586,10 @@ def send_request(prompt: str, conversation_history: List[dict], google_client: a
586
  time.sleep(timeout_wait)
587
 
588
  if i == number_of_api_retry_attempts:
589
- return ResponseObject(text="", usage_metadata={'RequestId':"FAILED"}), conversation_history
 
 
 
590
 
591
  # Update the conversation history with the new prompt and response
592
  conversation_history.append({'role': 'user', 'parts': [prompt]})
 
533
  progress_bar = range(0,number_of_api_retry_attempts)
534
 
535
  # Generate the model's response
536
+ if "Gemini" in model_source:
537
 
538
  for i in progress_bar:
539
  try:
 
541
 
542
  response = google_client.models.generate_content(model=model_choice, contents=full_prompt, config=config)
543
 
544
+ #print("Successful call to Gemini model.")
545
  break
546
  except Exception as e:
547
  # If fails, try again after X seconds in case there is a throttle limit
 
551
 
552
  if i == number_of_api_retry_attempts:
553
  return ResponseObject(text="", usage_metadata={'RequestId':"FAILED"}), conversation_history
554
+ elif "AWS" in model_source:
555
  for i in progress_bar:
556
  try:
557
  print("Calling AWS Claude model, attempt", i + 1)
558
  response = call_aws_claude(prompt, system_prompt, temperature, max_tokens, model_choice, bedrock_runtime=bedrock_runtime, assistant_prefill=assistant_prefill)
559
 
560
+ #print("Successful call to Claude model.")
561
  break
562
  except Exception as e:
563
  # If fails, try again after X seconds in case there is a throttle limit
 
566
 
567
  if i == number_of_api_retry_attempts:
568
  return ResponseObject(text="", usage_metadata={'RequestId':"FAILED"}), conversation_history
569
+ elif "Local" in model_source:
570
  # This is the local model
571
  for i in progress_bar:
572
  try:
 
577
 
578
  response = call_llama_cpp_chatmodel(prompt, system_prompt, gen_config, model=local_model)
579
 
580
+ #print("Successful call to local model.")
581
  break
582
  except Exception as e:
583
  # If fails, try again after X seconds in case there is a throttle limit
 
586
  time.sleep(timeout_wait)
587
 
588
  if i == number_of_api_retry_attempts:
589
+ return ResponseObject(text="", usage_metadata={'RequestId':"FAILED"}), conversation_history
590
+ else:
591
+ print("Model source not recognised")
592
+ return ResponseObject(text="", usage_metadata={'RequestId':"FAILED"}), conversation_history
593
 
594
  # Update the conversation history with the new prompt and response
595
  conversation_history.append({'role': 'user', 'parts': [prompt]})