Spaces:
Runtime error
Runtime error
Update chatbot.py
Browse files25 unmodified lines262728293031323334353627 unmodified lines6465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191202 unmodified lines1231241251261271281297 unmodified lines13713813914014114214325 unmodified linesfrom groq import Groq# You can also use models that are commented below# model_id = "llava-hf/llava-interleave-qwen-0.5b-hf"model_id = "llava-hf/llava-interleave-qwen-7b-hf"# model_id = "llava-hf/llava-interleave-qwen-7b-dpo-hf"processor = LlavaProcessor.from_pretrained(model_id)model = LlavaForConditionalGeneration.from_pretrained(model_id,torch_dtype=torch.float16) #, use_flash_attention_2=True)model.to("cpu")# Credit to merve for code of llava interleave qwen27 unmodified linesEXAMPLES = [[{"text": "What is Friction? Explain in Detail.",}],[{"text": "Write me a Python function to generate unique passwords.",}],[{"text": "What's the latest price of Bitcoin?",}],[{"text": "Search and give me list of spaces trending on HuggingFace.",}],[{"text": "Create a Beautiful Picture of Effiel at Night.",}],[{"text": "Create image of cute cat.",}],[{"text": "What unusual happens in this video.","files": [f"{examples_path}/example_video/accident.gif"],}],[{"text": "What's name of superhero in this clip","files": [f"{examples_path}/example_video/spiderman.gif"],}],[{"text": "What's written on this paper","files": [f"{examples_path}/example_images/paper_with_text.png"],}],[{"text": "Who are they? Tell me about both of them","files": [f"{examples_path}/example_images/elon_smoking.jpg",f"{examples_path}/example_images/steve_jobs.jpg", ]}]]2 unmodified linesBOT_AVATAR = "OpenAI_logo.png"# Perform a Google search and return the results@lru_cache(maxsize=128)def extract_text_from_webpage(html_content):"""Extracts visible text from HTML content using BeautifulSoup."""soup = BeautifulSoup(html_content, "html.parser")7 unmodified linesterm = querystart = 0all_results = []max_chars_per_page = 8000with requests.Session() as session:resp = session.get(url="https://www.google.com/search",25 unmodified lines262728293031323334353627 unmodified lines646566676869702 unmodified lines737475767778797 unmodified lines8788899091929325 unmodified linesfrom groq import Groq# You can also use models that are commented belowmodel_id = "llava-hf/llava-interleave-qwen-0.5b-hf"# model_id = "llava-hf/llava-interleave-qwen-7b-hf"# model_id = "llava-hf/llava-interleave-qwen-7b-dpo-hf"processor = LlavaProcessor.from_pretrained(model_id)model = LlavaForConditionalGeneration.from_pretrained(model_id,torch_dtype=torch.int8) #, use_flash_attention_2=True)model.to("cpu")# Credit to merve for code of llava interleave qwen27 unmodified linesEXAMPLES = [[{"text": "Should I wear pyjamas in an office meeting?",}]]2 unmodified linesBOT_AVATAR = "OpenAI_logo.png"# Perform a Google search and return the results@lru_cache(maxsize=64)def extract_text_from_webpage(html_content):"""Extracts visible text from HTML content using BeautifulSoup."""soup = BeautifulSoup(html_content, "html.parser")7 unmodified linesterm = querystart = 0all_results = []max_chars_per_page = 4000with requests.Session() as session:resp = session.get(url="https://www.google.com/search",
chatbot.py+6-56