Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,23 +8,16 @@ client = InferenceClient(
|
|
8 |
"mistralai/Mistral-7B-Instruct-v0.1"
|
9 |
)
|
10 |
|
11 |
-
# Flag to track whether initial greeting has been displayed
|
12 |
-
initial_greeting_displayed = False
|
13 |
|
14 |
def format_prompt(message, history):
|
15 |
-
|
16 |
-
prompt = ""
|
17 |
-
if not initial_greeting_displayed:
|
18 |
-
prompt += "hi " # Initial greeting
|
19 |
-
initial_greeting_displayed = True
|
20 |
-
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."
|
21 |
for user_prompt, bot_response in history:
|
22 |
prompt += f"[INST] {user_prompt} [/INST]"
|
23 |
prompt += f" {bot_response}</s> "
|
24 |
prompt += f"[INST] {message} [/INST]"
|
25 |
return prompt
|
26 |
|
27 |
-
def generate(prompt, history, temperature=0.
|
28 |
temperature = float(temperature)
|
29 |
if temperature < 1e-2:
|
30 |
temperature = 1e-2
|
@@ -49,12 +42,6 @@ def generate(prompt, history, temperature=0.9, max_new_tokens=2048, top_p=0.95,
|
|
49 |
yield output
|
50 |
return output
|
51 |
|
52 |
-
def generate_initial_prompt():
|
53 |
-
initial_prompt = format_prompt("", [])
|
54 |
-
for output in generate(initial_prompt, []):
|
55 |
-
print(output, end='')
|
56 |
-
|
57 |
-
generate_initial_prompt() # Call the function to display initial greeting
|
58 |
|
59 |
customCSS = """
|
60 |
#component-7 { # this is the default element ID of the chat component
|
|
|
8 |
"mistralai/Mistral-7B-Instruct-v0.1"
|
9 |
)
|
10 |
|
|
|
|
|
11 |
|
12 |
def format_prompt(message, history):
|
13 |
+
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."
|
|
|
|
|
|
|
|
|
|
|
14 |
for user_prompt, bot_response in history:
|
15 |
prompt += f"[INST] {user_prompt} [/INST]"
|
16 |
prompt += f" {bot_response}</s> "
|
17 |
prompt += f"[INST] {message} [/INST]"
|
18 |
return prompt
|
19 |
|
20 |
+
def generate(prompt, history, temperature=0.7, max_new_tokens=2048, top_p=0.95, repetition_penalty=1.2):
|
21 |
temperature = float(temperature)
|
22 |
if temperature < 1e-2:
|
23 |
temperature = 1e-2
|
|
|
42 |
yield output
|
43 |
return output
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
customCSS = """
|
47 |
#component-7 { # this is the default element ID of the chat component
|