Update app.py
Browse files216 unmodified lines21721821922022122222322422522622722822923013 unmodified lines244245246247248249250144 unmodified lines395396397398399400401402216 unmodified lines"temperature": temperature,"top_p": top_p,"repetition_penalty": repetition_penalty,"max_length": 1000},huggingfacehub_api_token=huggingface_token)MAX_PROMPT_CHARS = 24000 # Adjust based on your model's limitationsdef chunk_text(text: str, max_chunk_size: int = 1000) -> List[str]:chunks = []current_chunk = ""for sentence in re.split(r'(?<=[.!?])\s+', text):13 unmodified linestop_indices = np.argsort(similarities)[-top_k:]return [chunks[i] for i in top_indices]def generate_chunked_response(model, prompt, max_tokens=1000, max_chunks=5):full_response = ""for i in range(max_chunks):try:144 unmodified linesdatabase = Nonemax_attempts = 3max_input_tokens = 31000 # Leave room for the model's responsemax_output_tokens = 1000if web_search:contextualized_question, topics, entity_tracker, _ = chatbot.process_question(question)216 unmodified lines21721821922022122222322422522622722822923013 unmodified lines244245246247248249250144 unmodified lines395396397398399400401402216 unmodified lines"temperature": temperature,"top_p": top_p,"repetition_penalty": repetition_penalty,"max_length": 800},huggingfacehub_api_token=huggingface_token)MAX_PROMPT_CHARS = 20000 # Adjust based on your model's limitationsdef chunk_text(text: str, max_chunk_size: int = 800) -> List[str]:chunks = []current_chunk = ""for sentence in re.split(r'(?<=[.!?])\s+', text):13 unmodified linestop_indices = np.argsort(similarities)[-top_k:]return [chunks[i] for i in top_indices]def generate_chunked_response(model, prompt, max_tokens=800, max_chunks=5):full_response = ""for i in range(max_chunks):try:144 unmodified linesdatabase = Nonemax_attempts = 3max_input_tokens = 20000 # Leave room for the model's responsemax_output_tokens = 800if web_search:contextualized_question, topics, entity_tracker, _ = chatbot.process_question(question)
app.py+6-6