Spaces:
Running
on
Zero
Running
on
Zero
seanpedrickcase
commited on
Commit
·
d4f58e6
1
Parent(s):
d9427a2
Moved spaces GPU calls back to main functions as otherwise it doesn't seem to work correctly
Browse files- app.py +4 -4
- tools/chatfuncs.py +1 -3
- tools/llm_api_call.py +3 -2
app.py
CHANGED
@@ -171,12 +171,12 @@ with app:
|
|
171 |
|
172 |
with gr.Accordion("Prompt settings", open = True):
|
173 |
number_of_prompts = gr.Number(value=1, label="Number of prompts to send to LLM in sequence", minimum=1, maximum=3)
|
174 |
-
system_prompt_textbox = gr.Textbox(label="
|
175 |
-
initial_table_prompt_textbox = gr.Textbox(label = "
|
176 |
prompt_2_textbox = gr.Textbox(label = "Prompt 2", lines = 8, value = prompt2, visible=False)
|
177 |
prompt_3_textbox = gr.Textbox(label = "Prompt 3", lines = 8, value = prompt3, visible=False)
|
178 |
-
add_to_existing_topics_system_prompt_textbox = gr.Textbox(label="
|
179 |
-
add_to_existing_topics_prompt_textbox = gr.Textbox(label = "
|
180 |
|
181 |
log_files_output = gr.File(label="Log file output", interactive=False)
|
182 |
conversation_metadata_textbox = gr.Textbox(label="Query metadata - usage counts and other parameters", interactive=False, lines=8)
|
|
|
171 |
|
172 |
with gr.Accordion("Prompt settings", open = True):
|
173 |
number_of_prompts = gr.Number(value=1, label="Number of prompts to send to LLM in sequence", minimum=1, maximum=3)
|
174 |
+
system_prompt_textbox = gr.Textbox(label="Initial system prompt", lines = 4, value = system_prompt)
|
175 |
+
initial_table_prompt_textbox = gr.Textbox(label = "Initial topics prompt", lines = 8, value = initial_table_prompt)
|
176 |
prompt_2_textbox = gr.Textbox(label = "Prompt 2", lines = 8, value = prompt2, visible=False)
|
177 |
prompt_3_textbox = gr.Textbox(label = "Prompt 3", lines = 8, value = prompt3, visible=False)
|
178 |
+
add_to_existing_topics_system_prompt_textbox = gr.Textbox(label="Additional topics system prompt", lines = 4, value = add_existing_topics_system_prompt)
|
179 |
+
add_to_existing_topics_prompt_textbox = gr.Textbox(label = "Additional topics prompt", lines = 8, value = add_existing_topics_prompt)
|
180 |
|
181 |
log_files_output = gr.File(label="Log file output", interactive=False)
|
182 |
conversation_metadata_textbox = gr.Textbox(label="Query metadata - usage counts and other parameters", interactive=False, lines=8)
|
tools/chatfuncs.py
CHANGED
@@ -2,7 +2,6 @@ from typing import TypeVar
|
|
2 |
import torch.cuda
|
3 |
import os
|
4 |
import time
|
5 |
-
import spaces
|
6 |
from llama_cpp import Llama
|
7 |
from huggingface_hub import hf_hub_download
|
8 |
from tools.helper_functions import RUN_LOCAL_MODEL
|
@@ -126,7 +125,6 @@ def get_model_path():
|
|
126 |
print(f"Checking default Hugging Face folder. Downloading model from Hugging Face Hub if not found")
|
127 |
return hf_hub_download(repo_id=repo_id, filename=filename)
|
128 |
|
129 |
-
@spaces.GPU
|
130 |
def load_model(local_model_type:str=local_model_type, gpu_layers:int=gpu_layers, max_context_length:int=context_length, gpu_config:llama_cpp_init_config_gpu=gpu_config, cpu_config:llama_cpp_init_config_cpu=cpu_config, torch_device:str=torch_device):
|
131 |
'''
|
132 |
Load in a model from Hugging Face hub via the transformers package, or using llama_cpp_python by downloading a GGUF file from Huggingface Hub.
|
@@ -173,7 +171,7 @@ def load_model(local_model_type:str=local_model_type, gpu_layers:int=gpu_layers,
|
|
173 |
print(load_confirmation)
|
174 |
return model, tokenizer
|
175 |
|
176 |
-
|
177 |
def call_llama_cpp_model(formatted_string:str, gen_config:str, model=model):
|
178 |
"""
|
179 |
Calls your generation model with parameters from the LlamaCPPGenerationConfig object.
|
|
|
2 |
import torch.cuda
|
3 |
import os
|
4 |
import time
|
|
|
5 |
from llama_cpp import Llama
|
6 |
from huggingface_hub import hf_hub_download
|
7 |
from tools.helper_functions import RUN_LOCAL_MODEL
|
|
|
125 |
print(f"Checking default Hugging Face folder. Downloading model from Hugging Face Hub if not found")
|
126 |
return hf_hub_download(repo_id=repo_id, filename=filename)
|
127 |
|
|
|
128 |
def load_model(local_model_type:str=local_model_type, gpu_layers:int=gpu_layers, max_context_length:int=context_length, gpu_config:llama_cpp_init_config_gpu=gpu_config, cpu_config:llama_cpp_init_config_cpu=cpu_config, torch_device:str=torch_device):
|
129 |
'''
|
130 |
Load in a model from Hugging Face hub via the transformers package, or using llama_cpp_python by downloading a GGUF file from Huggingface Hub.
|
|
|
171 |
print(load_confirmation)
|
172 |
return model, tokenizer
|
173 |
|
174 |
+
|
175 |
def call_llama_cpp_model(formatted_string:str, gen_config:str, model=model):
|
176 |
"""
|
177 |
Calls your generation model with parameters from the LlamaCPPGenerationConfig object.
|
tools/llm_api_call.py
CHANGED
@@ -10,6 +10,7 @@ import json
|
|
10 |
import math
|
11 |
import string
|
12 |
import re
|
|
|
13 |
from rapidfuzz import process, fuzz
|
14 |
from tqdm import tqdm
|
15 |
from gradio import Progress
|
@@ -878,7 +879,7 @@ def write_llm_output_and_logs(responses: List[ResponseObject],
|
|
878 |
|
879 |
return topic_table_out_path, reference_table_out_path, unique_topics_df_out_path, topic_with_response_df, markdown_table, out_reference_df, out_unique_topics_df, batch_file_path_details, is_error
|
880 |
|
881 |
-
|
882 |
def extract_topics(in_data_file,
|
883 |
file_data:pd.DataFrame,
|
884 |
existing_topics_table:pd.DataFrame,
|
@@ -1614,7 +1615,7 @@ def summarise_output_topics_query(model_choice:str, in_api_key:str, temperature:
|
|
1614 |
|
1615 |
return latest_response_text, conversation_history, whole_conversation_metadata
|
1616 |
|
1617 |
-
|
1618 |
def summarise_output_topics(summarised_references:pd.DataFrame,
|
1619 |
unique_table_df:pd.DataFrame,
|
1620 |
reference_table_df:pd.DataFrame,
|
|
|
10 |
import math
|
11 |
import string
|
12 |
import re
|
13 |
+
import spaces
|
14 |
from rapidfuzz import process, fuzz
|
15 |
from tqdm import tqdm
|
16 |
from gradio import Progress
|
|
|
879 |
|
880 |
return topic_table_out_path, reference_table_out_path, unique_topics_df_out_path, topic_with_response_df, markdown_table, out_reference_df, out_unique_topics_df, batch_file_path_details, is_error
|
881 |
|
882 |
+
@spaces.GPU
|
883 |
def extract_topics(in_data_file,
|
884 |
file_data:pd.DataFrame,
|
885 |
existing_topics_table:pd.DataFrame,
|
|
|
1615 |
|
1616 |
return latest_response_text, conversation_history, whole_conversation_metadata
|
1617 |
|
1618 |
+
@spaces.GPU
|
1619 |
def summarise_output_topics(summarised_references:pd.DataFrame,
|
1620 |
unique_table_df:pd.DataFrame,
|
1621 |
reference_table_df:pd.DataFrame,
|