Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import pipeline
|
3 |
|
4 |
# Load the text-generation pipeline with Mistral model
|
5 |
-
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
# Define the function to process user input
|
8 |
def classify_text(text):
|
9 |
prompt = "Classify the following text into a category or topic:"
|
10 |
input_text = f"{prompt}\n{text}"
|
11 |
-
results =
|
12 |
-
return results
|
13 |
|
14 |
# Create Gradio interface
|
15 |
interface = gr.Interface(
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
# Load the text-generation pipeline with Mistral model
|
4 |
+
from langchain_huggingface import HuggingFaceEndpoint
|
5 |
|
6 |
+
|
7 |
+
# Initialize the LLM and other components
|
8 |
+
llm = HuggingFaceEndpoint(
|
9 |
+
repo_id="mistralai/Mistral-7B-Instruct-v0.3",
|
10 |
+
task="text-generation",
|
11 |
+
max_new_tokens=4096,
|
12 |
+
temperature=0.5,
|
13 |
+
do_sample=False,
|
14 |
+
)
|
15 |
# Define the function to process user input
|
16 |
def classify_text(text):
|
17 |
prompt = "Classify the following text into a category or topic:"
|
18 |
input_text = f"{prompt}\n{text}"
|
19 |
+
results = llm.invoke(input_text)
|
20 |
+
return results
|
21 |
|
22 |
# Create Gradio interface
|
23 |
interface = gr.Interface(
|