Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,14 +7,21 @@ API_URL = "https://api-inference.huggingface.co/models/"
|
|
7 |
client = InferenceClient(
|
8 |
"mistralai/Mistral-7B-Instruct-v0.1"
|
9 |
)
|
|
|
|
|
10 |
|
11 |
def format_prompt(message, history):
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
|
20 |
def generate(prompt, history, temperature=0.9, max_new_tokens=2048, top_p=0.95, repetition_penalty=1.0):
|
|
|
7 |
client = InferenceClient(
|
8 |
"mistralai/Mistral-7B-Instruct-v0.1"
|
9 |
)
|
10 |
+
# Flag to track whether initial greeting has been displayed
|
11 |
+
initial_greeting_displayed = False
|
12 |
|
13 |
def format_prompt(message, history):
|
14 |
+
global initial_greeting_displayed
|
15 |
+
prompt = ""
|
16 |
+
if not initial_greeting_displayed:
|
17 |
+
prompt += "hi " # Initial greeting
|
18 |
+
initial_greeting_displayed = True
|
19 |
+
prompt += "You are BibleLearnerAI, a Christian Bible AI. You focus on religion, believing in Christianity as truth, and provide relevant Bible verses. When greeted, respond with a religious greeting and introduce yourself."
|
20 |
+
for user_prompt, bot_response in history:
|
21 |
+
prompt += f"[INST] {user_prompt} [/INST]"
|
22 |
+
prompt += f" {bot_response}</s> "
|
23 |
+
prompt += f"[INST] {message} [/INST]"
|
24 |
+
return prompt
|
25 |
|
26 |
|
27 |
def generate(prompt, history, temperature=0.9, max_new_tokens=2048, top_p=0.95, repetition_penalty=1.0):
|