Spaces:
Runtime error
Runtime error
vaishakgkumar
commited on
Commit
·
12555c1
1
Parent(s):
989f6d4
Update app.py
Browse files
app.py
CHANGED
@@ -67,8 +67,8 @@ peft_model = PeftModel.from_pretrained(peft_model, "vaishakgkumar/stablemedv1",
|
|
67 |
class ChatBot:
|
68 |
def __init__(self):
|
69 |
self.history = []
|
70 |
-
|
71 |
-
def predict(self, user_input, system_prompt="You are an expert analyst and provide assessment:"):
|
72 |
prompt = [{'role': 'user', 'content': user_input + "\n" + system_prompt + ":"}]
|
73 |
inputs = tokenizer.apply_chat_template(
|
74 |
prompt,
|
@@ -77,9 +77,9 @@ def predict(self, user_input, system_prompt="You are an expert analyst and provi
|
|
77 |
)
|
78 |
|
79 |
# Generate a response using the model
|
80 |
-
tokens =
|
81 |
inputs.to(model.device),
|
82 |
-
max_new_tokens=
|
83 |
temperature=0.8,
|
84 |
do_sample=False
|
85 |
)
|
@@ -93,6 +93,7 @@ def predict(self, user_input, system_prompt="You are an expert analyst and provi
|
|
93 |
|
94 |
return response_text
|
95 |
|
|
|
96 |
bot = ChatBot()
|
97 |
|
98 |
|
|
|
67 |
class ChatBot:
|
68 |
def __init__(self):
|
69 |
self.history = []
|
70 |
+
|
71 |
+
def predict(self, user_input, system_prompt="You are an expert analyst and provide assessment:"):
|
72 |
prompt = [{'role': 'user', 'content': user_input + "\n" + system_prompt + ":"}]
|
73 |
inputs = tokenizer.apply_chat_template(
|
74 |
prompt,
|
|
|
77 |
)
|
78 |
|
79 |
# Generate a response using the model
|
80 |
+
tokens = model.generate(
|
81 |
inputs.to(model.device),
|
82 |
+
max_new_tokens=250,
|
83 |
temperature=0.8,
|
84 |
do_sample=False
|
85 |
)
|
|
|
93 |
|
94 |
return response_text
|
95 |
|
96 |
+
|
97 |
bot = ChatBot()
|
98 |
|
99 |
|