Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -14,6 +14,7 @@ client = InferenceClient(
|
|
14 |
"mistralai/Mixtral-8x7B-Instruct-v0.1"
|
15 |
)
|
16 |
history = []
|
|
|
17 |
def format_prompt(message, history):
|
18 |
prompt = "<s>"
|
19 |
for user_prompt, bot_response in history:
|
@@ -68,6 +69,8 @@ def question_generate(prompt, history, agent_name=agents[0], sys_prompt="", temp
|
|
68 |
return output
|
69 |
|
70 |
def generate(prompt, history, agent_name=agents[0], sys_prompt="", temperature=0.9, max_new_tokens=1048, top_p=0.95, repetition_penalty=1.0,):
|
|
|
|
|
71 |
seed = random.randint(1,1111111111111111)
|
72 |
|
73 |
agent=prompts.AI_REPORT_WRITER
|
@@ -102,7 +105,6 @@ def generate(prompt, history, agent_name=agents[0], sys_prompt="", temperature=0
|
|
102 |
seed=seed,
|
103 |
)
|
104 |
while True:
|
105 |
-
print(datetime.datetime.now())
|
106 |
uid=uuid.uuid4()
|
107 |
formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
|
108 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
@@ -121,10 +123,11 @@ def generate(prompt, history, agent_name=agents[0], sys_prompt="", temperature=0
|
|
121 |
print ( f'output:: {output}')
|
122 |
print ( f'history:: {history}')
|
123 |
out_json = [{"prompt":prompt},{"output":output}]
|
|
|
124 |
#try:
|
125 |
# for ea in
|
126 |
with open(f'{uid}.json', 'w') as f:
|
127 |
-
json_obj=json.dumps(
|
128 |
f.write(json_obj)
|
129 |
f.close()
|
130 |
|
|
|
14 |
"mistralai/Mixtral-8x7B-Instruct-v0.1"
|
15 |
)
|
16 |
history = []
|
17 |
+
hist_out= []
|
18 |
def format_prompt(message, history):
|
19 |
prompt = "<s>"
|
20 |
for user_prompt, bot_response in history:
|
|
|
69 |
return output
|
70 |
|
71 |
def generate(prompt, history, agent_name=agents[0], sys_prompt="", temperature=0.9, max_new_tokens=1048, top_p=0.95, repetition_penalty=1.0,):
|
72 |
+
print(datetime.datetime.now())
|
73 |
+
|
74 |
seed = random.randint(1,1111111111111111)
|
75 |
|
76 |
agent=prompts.AI_REPORT_WRITER
|
|
|
105 |
seed=seed,
|
106 |
)
|
107 |
while True:
|
|
|
108 |
uid=uuid.uuid4()
|
109 |
formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
|
110 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
|
|
123 |
print ( f'output:: {output}')
|
124 |
print ( f'history:: {history}')
|
125 |
out_json = [{"prompt":prompt},{"output":output}]
|
126 |
+
hist_out.append(out_json)
|
127 |
#try:
|
128 |
# for ea in
|
129 |
with open(f'{uid}.json', 'w') as f:
|
130 |
+
json_obj=json.dumps(hist_out, indent=4)
|
131 |
f.write(json_obj)
|
132 |
f.close()
|
133 |
|