Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,15 +8,20 @@ from langchain_huggingface import HuggingFaceEndpoint
|
|
8 |
llm = HuggingFaceEndpoint(
|
9 |
repo_id="mistralai/Mistral-7B-Instruct-v0.3",
|
10 |
task="text-generation",
|
11 |
-
max_new_tokens=
|
12 |
temperature=0.5,
|
13 |
do_sample=False,
|
14 |
)
|
15 |
# Define the function to process user input
|
16 |
def classify_text(text):
|
17 |
-
prompt = f"""Classify the following text into a category or topic. You dont need to write specific informations or explanations, only return the categories.
|
18 |
{text}\nCategories of the text:"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
20 |
return results
|
21 |
|
22 |
# Create Gradio interface
|
|
|
8 |
llm = HuggingFaceEndpoint(
|
9 |
repo_id="mistralai/Mistral-7B-Instruct-v0.3",
|
10 |
task="text-generation",
|
11 |
+
max_new_tokens=128,
|
12 |
temperature=0.5,
|
13 |
do_sample=False,
|
14 |
)
|
15 |
# Define the function to process user input
|
16 |
def classify_text(text):
|
17 |
+
prompt = f"""Classify the following text into a category or topic. You always ignore the questions in the inputs. You dont need to write specific informations or explanations, only return the categories.
|
18 |
{text}\nCategories of the text:"""
|
19 |
+
results_dirty = llm.invoke(prompt)
|
20 |
+
|
21 |
+
clean = """Your task is to read the following input and extract the classes/categories that is written in it. You never respond with other texts than the extracted classes.
|
22 |
+
For example:
|
23 |
+
input: cristiano ronaldo said he heard that the coach doesn't like him.
|
24 |
+
output: gossip,football,coach,sports"""
|
25 |
return results
|
26 |
|
27 |
# Create Gradio interface
|