Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -17,7 +17,7 @@ def extract_text_from_webpage(html_content):
|
|
17 |
"""Extracts visible text from HTML content using BeautifulSoup."""
|
18 |
soup = BeautifulSoup(html_content, 'html.parser')
|
19 |
# Remove unwanted tags
|
20 |
-
for tag in soup(["script", "style", "header", "footer"
|
21 |
tag.extract()
|
22 |
return soup.get_text(strip=True)
|
23 |
|
@@ -62,7 +62,7 @@ def search(query):
|
|
62 |
return all_results
|
63 |
|
64 |
|
65 |
-
client = InferenceClient("
|
66 |
|
67 |
def respond(
|
68 |
message, history
|
@@ -128,6 +128,10 @@ def respond(
|
|
128 |
"type": "string",
|
129 |
"description": "image generation prompt in detail.",
|
130 |
},
|
|
|
|
|
|
|
|
|
131 |
},
|
132 |
"required": ["query"],
|
133 |
},
|
@@ -158,14 +162,8 @@ def respond(
|
|
158 |
client_mixtral = InferenceClient("NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO")
|
159 |
client_llama = InferenceClient("meta-llama/Meta-Llama-3-8B-Instruct")
|
160 |
generate_kwargs = dict( max_new_tokens=2000, do_sample=True, stream=True, details=True, return_full_text=False )
|
161 |
-
question_history = ""
|
162 |
-
system_message = f'You are a helpful assistant with access to the following functions: \n {str(functions_metadata)}\n\nTo use these functions respond with:\n<functioncall> {{ "name": "function_name", "arguments": {{ "arg_1": "value_1", "arg_1": "value_1", ... }} }} </functioncall> Choose functions wisely and Also reply wisely, reply with just functioncall only as tell you before, Make function while learning from Prev Questions But make sure to create function call only for Curent Question.'
|
163 |
-
messages = [{"role": "system", "content": system_message}]
|
164 |
-
for val in history:
|
165 |
-
if val[0]:
|
166 |
-
messages.append({"role": "user", "content": f"{str(val[0])}"})
|
167 |
|
168 |
-
messages.append({"role": "user", "content": message_text})
|
169 |
|
170 |
response = client.chat_completion( messages, max_tokens=150)
|
171 |
response = str(response)
|
|
|
17 |
"""Extracts visible text from HTML content using BeautifulSoup."""
|
18 |
soup = BeautifulSoup(html_content, 'html.parser')
|
19 |
# Remove unwanted tags
|
20 |
+
for tag in soup(["script", "style", "header", "footer"]):
|
21 |
tag.extract()
|
22 |
return soup.get_text(strip=True)
|
23 |
|
|
|
62 |
return all_results
|
63 |
|
64 |
|
65 |
+
client = InferenceClient("google/gemma-1.1-7b-it")
|
66 |
|
67 |
def respond(
|
68 |
message, history
|
|
|
128 |
"type": "string",
|
129 |
"description": "image generation prompt in detail.",
|
130 |
},
|
131 |
+
"number_of_image": {
|
132 |
+
"type": "integer",
|
133 |
+
"description": "number of images to generate.",
|
134 |
+
}
|
135 |
},
|
136 |
"required": ["query"],
|
137 |
},
|
|
|
162 |
client_mixtral = InferenceClient("NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO")
|
163 |
client_llama = InferenceClient("meta-llama/Meta-Llama-3-8B-Instruct")
|
164 |
generate_kwargs = dict( max_new_tokens=2000, do_sample=True, stream=True, details=True, return_full_text=False )
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
|
166 |
+
messages.append({"role": "user", "content": f'[SYSTEM]You are a helpful assistant with access to the following functions: \n {str(functions_metadata)}\n\nTo use these functions respond with:\n<functioncall> {{ "name": "function_name", "arguments": {{ "arg_1": "value_1", "arg_1": "value_1", ... }} }} </functioncall> Choose functions wisely and Also reply wisely, reply with just functioncall only as tell you before. [USER] {message_text} {vqa}'})
|
167 |
|
168 |
response = client.chat_completion( messages, max_tokens=150)
|
169 |
response = str(response)
|