Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ from unsloth import FastLanguageModel
|
|
3 |
import torch
|
4 |
|
5 |
# Load the model and tokenizer
|
6 |
-
model_name = "Rafay17/Llama3.2_1b_customModle2" #
|
7 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
|
9 |
model = FastLanguageModel.from_pretrained(
|
@@ -18,38 +18,7 @@ FastLanguageModel.for_inference(model) # Call this immediately after loading th
|
|
18 |
# Function to generate a response
|
19 |
def generate_response(input_text):
|
20 |
# Prepare the labeled prompt for the model
|
21 |
-
labeled_prompt =
|
22 |
-
"Please provide the response with the following labels:\n"
|
23 |
-
"Speaker: [SPEAKER]\n"
|
24 |
-
"Text: [TEXT]\n"
|
25 |
-
"Sentiment: [SENTIMENT]\n"
|
26 |
-
"Emotion: [EMOTION]\n"
|
27 |
-
"Intent: [INTENT]\n"
|
28 |
-
"Tone: [TONE]\n"
|
29 |
-
"Confidence Level: [CONFIDENCE]\n"
|
30 |
-
"Frustration Level: [FRUSTRATION]\n"
|
31 |
-
"Response Length: [LENGTH]\n"
|
32 |
-
"Action Required: [ACTION]\n"
|
33 |
-
"Interruption: [INTERRUPTION]\n"
|
34 |
-
"Cooperation Level: [COOPERATION]\n"
|
35 |
-
"Clarity: [CLARITY]\n"
|
36 |
-
"Objective: [OBJECTIVE]\n"
|
37 |
-
"Timeline: [TIMELINE]\n"
|
38 |
-
"Motivation: [MOTIVATION]\n"
|
39 |
-
"Conversation Stage: [STAGE]\n"
|
40 |
-
"Resolution: [RESOLUTION]\n"
|
41 |
-
"Context: [CONTEXT]\n"
|
42 |
-
"Urgency: [URGENCY]\n"
|
43 |
-
"Problem Type: [PROBLEM]\n"
|
44 |
-
"Key Words: [KEYWORDS]\n"
|
45 |
-
"Expected Detail: [DETAIL]\n"
|
46 |
-
"Time Gap: [TIME]\n"
|
47 |
-
"Client Expectation: [EXPECTATION]\n"
|
48 |
-
"Channel: [CHANNEL]\n"
|
49 |
-
"Power Relationship: [POWER]\n\n"
|
50 |
-
f"User Input: {input_text}\n"
|
51 |
-
"Response:"
|
52 |
-
)
|
53 |
|
54 |
# Prepare the input for the model
|
55 |
inputs = tokenizer(
|
@@ -75,12 +44,13 @@ def generate_response(input_text):
|
|
75 |
|
76 |
# Function to take user input and generate output
|
77 |
def user_interaction():
|
|
|
78 |
while True:
|
79 |
-
user_input = input("
|
80 |
if user_input.lower() == 'exit':
|
81 |
-
print("Exiting the
|
82 |
break
|
83 |
-
print("
|
84 |
generate_response(user_input)
|
85 |
|
86 |
# Start the user interaction
|
|
|
3 |
import torch
|
4 |
|
5 |
# Load the model and tokenizer
|
6 |
+
model_name = "Rafay17/Llama3.2_1b_customModle2" # Your model name
|
7 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
|
9 |
model = FastLanguageModel.from_pretrained(
|
|
|
18 |
# Function to generate a response
|
19 |
def generate_response(input_text):
|
20 |
# Prepare the labeled prompt for the model
|
21 |
+
labeled_prompt = f"User Input: {input_text}\nResponse:"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
# Prepare the input for the model
|
24 |
inputs = tokenizer(
|
|
|
44 |
|
45 |
# Function to take user input and generate output
|
46 |
def user_interaction():
|
47 |
+
print("Welcome to the Chatbot! Type 'exit' to quit.")
|
48 |
while True:
|
49 |
+
user_input = input("You: ")
|
50 |
if user_input.lower() == 'exit':
|
51 |
+
print("Exiting the chatbot. Goodbye!")
|
52 |
break
|
53 |
+
print("Chatbot is generating a response...")
|
54 |
generate_response(user_input)
|
55 |
|
56 |
# Start the user interaction
|