Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ from i_search import google
|
|
8 |
from i_search import i_search as i_s
|
9 |
from datetime import datetime
|
10 |
import logging
|
|
|
11 |
|
12 |
now = datetime.now()
|
13 |
date_time_str = now.strftime("%Y-%m-%d %H:%M:%S")
|
@@ -73,7 +74,7 @@ What do you want to know about the test results?
|
|
73 |
thought:
|
74 |
"""
|
75 |
|
76 |
-
def format_prompt(message, history, max_history_turns=
|
77 |
prompt = "<s>"
|
78 |
# Keep only the last 'max_history_turns' turns
|
79 |
for user_prompt, bot_response in history[-max_history_turns:]:
|
@@ -91,15 +92,21 @@ def run_gpt(
|
|
91 |
):
|
92 |
seed = random.randint(1,1111111111111111)
|
93 |
logging.info(f"Seed: {seed}") # Log the seed
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
102 |
|
|
|
103 |
content = PREFIX.format(
|
104 |
date_time_str=date_time_str,
|
105 |
purpose=purpose,
|
|
|
8 |
from i_search import i_search as i_s
|
9 |
from datetime import datetime
|
10 |
import logging
|
11 |
+
import json
|
12 |
|
13 |
now = datetime.now()
|
14 |
date_time_str = now.strftime("%Y-%m-%d %H:%M:%S")
|
|
|
74 |
thought:
|
75 |
"""
|
76 |
|
77 |
+
def format_prompt(message, history, max_history_turns=2):
|
78 |
prompt = "<s>"
|
79 |
# Keep only the last 'max_history_turns' turns
|
80 |
for user_prompt, bot_response in history[-max_history_turns:]:
|
|
|
92 |
):
|
93 |
seed = random.randint(1,1111111111111111)
|
94 |
logging.info(f"Seed: {seed}") # Log the seed
|
95 |
+
|
96 |
+
content = PREFIX.format(
|
97 |
+
date_time_str=date_time_str,
|
98 |
+
purpose=purpose,
|
99 |
+
safe_search=safe_search,
|
100 |
+
) + prompt_template.format(**prompt_kwargs)
|
101 |
+
if VERBOSE:
|
102 |
+
logging.info(LOG_PROMPT.format(content)) # Log the prompt
|
103 |
+
|
104 |
+
resp = client.text_generation(content, max_new_tokens=max_tokens, stop_sequences=stop_tokens, temperature=0.7, top_p=0.8, repetition_penalty=1.5)
|
105 |
+
if VERBOSE:
|
106 |
+
logging.info(LOG_RESPONSE.format(resp)) # Log the response
|
107 |
+
return resp
|
108 |
|
109 |
+
def generate( prompt, history, agent_name=agents[0], sys_prompt="", temperature=0.7, max_new_tokens=2048, top_p=0.8, repetition_penalty=1.5, ):
|
110 |
content = PREFIX.format(
|
111 |
date_time_str=date_time_str,
|
112 |
purpose=purpose,
|