Spaces:
Running
Running
Update chatbot.py
Browse files- chatbot.py +6 -56
chatbot.py
CHANGED
@@ -26,11 +26,11 @@ from gradio_client import Client, file
|
|
26 |
from groq import Groq
|
27 |
|
28 |
# You can also use models that are commented below
|
29 |
-
|
30 |
-
model_id = "llava-hf/llava-interleave-qwen-7b-hf"
|
31 |
# model_id = "llava-hf/llava-interleave-qwen-7b-dpo-hf"
|
32 |
processor = LlavaProcessor.from_pretrained(model_id)
|
33 |
-
model = LlavaForConditionalGeneration.from_pretrained(model_id,torch_dtype=torch.
|
34 |
model.to("cpu")
|
35 |
# Credit to merve for code of llava interleave qwen
|
36 |
|
@@ -64,57 +64,7 @@ examples_path = os.path.dirname(__file__)
|
|
64 |
EXAMPLES = [
|
65 |
[
|
66 |
{
|
67 |
-
"text": "
|
68 |
-
}
|
69 |
-
],
|
70 |
-
[
|
71 |
-
{
|
72 |
-
"text": "Write me a Python function to generate unique passwords.",
|
73 |
-
}
|
74 |
-
],
|
75 |
-
[
|
76 |
-
{
|
77 |
-
"text": "What's the latest price of Bitcoin?",
|
78 |
-
}
|
79 |
-
],
|
80 |
-
[
|
81 |
-
{
|
82 |
-
"text": "Search and give me list of spaces trending on HuggingFace.",
|
83 |
-
}
|
84 |
-
],
|
85 |
-
[
|
86 |
-
{
|
87 |
-
"text": "Create a Beautiful Picture of Effiel at Night.",
|
88 |
-
}
|
89 |
-
],
|
90 |
-
[
|
91 |
-
{
|
92 |
-
"text": "Create image of cute cat.",
|
93 |
-
}
|
94 |
-
],
|
95 |
-
[
|
96 |
-
{
|
97 |
-
"text": "What unusual happens in this video.",
|
98 |
-
"files": [f"{examples_path}/example_video/accident.gif"],
|
99 |
-
}
|
100 |
-
],
|
101 |
-
[
|
102 |
-
{
|
103 |
-
"text": "What's name of superhero in this clip",
|
104 |
-
"files": [f"{examples_path}/example_video/spiderman.gif"],
|
105 |
-
}
|
106 |
-
],
|
107 |
-
[
|
108 |
-
{
|
109 |
-
"text": "What's written on this paper",
|
110 |
-
"files": [f"{examples_path}/example_images/paper_with_text.png"],
|
111 |
-
}
|
112 |
-
],
|
113 |
-
[
|
114 |
-
{
|
115 |
-
"text": "Who are they? Tell me about both of them",
|
116 |
-
"files": [f"{examples_path}/example_images/elon_smoking.jpg",
|
117 |
-
f"{examples_path}/example_images/steve_jobs.jpg", ]
|
118 |
}
|
119 |
]
|
120 |
]
|
@@ -123,7 +73,7 @@ EXAMPLES = [
|
|
123 |
BOT_AVATAR = "OpenAI_logo.png"
|
124 |
|
125 |
# Perform a Google search and return the results
|
126 |
-
@lru_cache(maxsize=
|
127 |
def extract_text_from_webpage(html_content):
|
128 |
"""Extracts visible text from HTML content using BeautifulSoup."""
|
129 |
soup = BeautifulSoup(html_content, "html.parser")
|
@@ -137,7 +87,7 @@ def search(query):
|
|
137 |
term = query
|
138 |
start = 0
|
139 |
all_results = []
|
140 |
-
max_chars_per_page =
|
141 |
with requests.Session() as session:
|
142 |
resp = session.get(
|
143 |
url="https://www.google.com/search",
|
|
|
26 |
from groq import Groq
|
27 |
|
28 |
# You can also use models that are commented below
|
29 |
+
model_id = "llava-hf/llava-interleave-qwen-0.5b-hf"
|
30 |
+
# model_id = "llava-hf/llava-interleave-qwen-7b-hf"
|
31 |
# model_id = "llava-hf/llava-interleave-qwen-7b-dpo-hf"
|
32 |
processor = LlavaProcessor.from_pretrained(model_id)
|
33 |
+
model = LlavaForConditionalGeneration.from_pretrained(model_id,torch_dtype=torch.int8) #, use_flash_attention_2=True)
|
34 |
model.to("cpu")
|
35 |
# Credit to merve for code of llava interleave qwen
|
36 |
|
|
|
64 |
EXAMPLES = [
|
65 |
[
|
66 |
{
|
67 |
+
"text": "Should I wear pyjamas in an office meeting?",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
}
|
69 |
]
|
70 |
]
|
|
|
73 |
BOT_AVATAR = "OpenAI_logo.png"
|
74 |
|
75 |
# Perform a Google search and return the results
|
76 |
+
@lru_cache(maxsize=64)
|
77 |
def extract_text_from_webpage(html_content):
|
78 |
"""Extracts visible text from HTML content using BeautifulSoup."""
|
79 |
soup = BeautifulSoup(html_content, "html.parser")
|
|
|
87 |
term = query
|
88 |
start = 0
|
89 |
all_results = []
|
90 |
+
max_chars_per_page = 4000
|
91 |
with requests.Session() as session:
|
92 |
resp = session.get(
|
93 |
url="https://www.google.com/search",
|