acecalisto3 commited on
Commit
850e677
·
verified ·
1 Parent(s): ff2d6be

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -20
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import os
2
  import subprocess
3
  import random
 
4
  from transformers import pipeline
5
  import gradio as gr
6
  from safe_search import safe_search
@@ -37,7 +38,7 @@ def run_gpt(
37
  **prompt_kwargs,
38
  ):
39
  seed = random.randint(1,1111111111111111)
40
- print (seed)
41
  generate_kwargs = dict(
42
  temperature=1.0,
43
  max_new_tokens=2096,
@@ -90,7 +91,7 @@ def call_search(purpose, task, history, directory, action_input):
90
  print(response)
91
  history += "observation: search result is: {}\n".format(response)
92
  else:
93
- history += "observation: I need to provide a valid URL to 'action: SEARCH action_input = {}\n".format(action_input)
94
  except Exception as e:
95
  history += "observation: {}'\n".format(e)
96
  return "MAIN", None, history, task
@@ -132,7 +133,8 @@ def call_main(purpose, task, history, directory, action_input):
132
 
133
 
134
  def call_set_task(purpose, task, history, directory, action_input):
135
- task = run_gpt(
 
136
  TASK_PROMPT,
137
  stop_tokens=[],
138
  max_tokens=64,
@@ -159,7 +161,7 @@ def run_action(purpose, task, history, directory, action_name, action_input):
159
  print(f'action_name::{action_name}')
160
  try:
161
  if "RESPONSE" in action_name or "COMPLETE" in action_name:
162
- action_name = action_name
163
  task = "COMPLETE"
164
  return action_name, "COMPLETE", history, task
165
 
@@ -167,11 +169,11 @@ def run_action(purpose, task, history, directory, action_name, action_input):
167
  if len(history.split("\n")) > 5:
168
  if True:
169
  print("COMPRESSING HISTORY")
170
- history = compress_history(purpose, task, history, directory)
171
  if not action_name in NAME_TO_FUNC:
172
- action_name = action_name
173
- if action_name == "MAIN":
174
- action_name = action_name
175
  assert action_name in NAME_TO_FUNC
176
 
177
  print("RUN: ", action_name, action_input)
@@ -185,15 +187,15 @@ def run(purpose,history):
185
 
186
  #print(purpose)
187
  #print(hist)
188
- task = "MAIN"
189
- directory = "MAIN"
190
  if history:
191
  history = history
192
  if not history:
193
  history = ""
194
 
195
  action_name = "MAIN"
196
- action_input = ""
197
  while True:
198
  print("")
199
  print("")
@@ -307,8 +309,6 @@ additional_inputs=[
307
  interactive=True,
308
  info="Penalize repeated tokens",
309
  ),
310
-
311
-
312
  ]
313
 
314
  examples=[["What are the biggest news stories today?", None, None, None, None, None, ],
@@ -321,10 +321,16 @@ examples=[["What are the biggest news stories today?", None, None, None, None, N
321
  ["What are some unique features of Rust that make it stand out compared to other systems programming languages like C++?", None, None, None, None, None,],
322
  ]
323
 
324
- gr.ChatInterface(
325
- fn=run,
326
- chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
327
- title="Mixtral 46.7B\nMicro-Agent\nInternet Search <br> development test",
328
- examples=examples,
329
- concurrency_limit=20,
330
- ).launch(show_api=False)
 
 
 
 
 
 
 
1
  import os
2
  import subprocess
3
  import random
4
+ import torch
5
  from transformers import pipeline
6
  import gradio as gr
7
  from safe_search import safe_search
 
38
  **prompt_kwargs,
39
  ):
40
  seed = random.randint(1,1111111111111111)
41
+ print(seed)
42
  generate_kwargs = dict(
43
  temperature=1.0,
44
  max_new_tokens=2096,
 
91
  print(response)
92
  history += "observation: search result is: {}\n".format(response)
93
  else:
94
+ history += "observation: I need to provide a valid URL to 'action: SEARCH'\n"
95
  except Exception as e:
96
  history += "observation: {}'\n".format(e)
97
  return "MAIN", None, history, task
 
133
 
134
 
135
  def call_set_task(purpose, task, history, directory, action_input):
136
+ task = "COMPLETE"
137
+ resp = run_gpt(
138
  TASK_PROMPT,
139
  stop_tokens=[],
140
  max_tokens=64,
 
161
  print(f'action_name::{action_name}')
162
  try:
163
  if "RESPONSE" in action_name or "COMPLETE" in action_name:
164
+ action_name = "COMPLETE"
165
  task = "COMPLETE"
166
  return action_name, "COMPLETE", history, task
167
 
 
169
  if len(history.split("\n")) > 5:
170
  if True:
171
  print("COMPRESSING HISTORY")
172
+ history = history
173
  if not action_name in NAME_TO_FUNC:
174
+ action_name = "MAIN"
175
+ if action_name == "SEARCH":
176
+ action_name = "SEARCH"
177
  assert action_name in NAME_TO_FUNC
178
 
179
  print("RUN: ", action_name, action_input)
 
187
 
188
  #print(purpose)
189
  #print(hist)
190
+ task = "COMPLETE"
191
+ directory = "directory"
192
  if history:
193
  history = history
194
  if not history:
195
  history = ""
196
 
197
  action_name = "MAIN"
198
+ action_input = "input"
199
  while True:
200
  print("")
201
  print("")
 
309
  interactive=True,
310
  info="Penalize repeated tokens",
311
  ),
 
 
312
  ]
313
 
314
  examples=[["What are the biggest news stories today?", None, None, None, None, None, ],
 
321
  ["What are some unique features of Rust that make it stand out compared to other systems programming languages like C++?", None, None, None, None, None,],
322
  ]
323
 
324
+ import transformers
325
+ import torch
326
+
327
+ def launch_interface():
328
+ gr.ChatInterface(
329
+ fn=run,
330
+ chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
331
+ title="Mixtral 46.7B\nMicro-Agent\nInternet Search <br> development test",
332
+ examples=examples,
333
+ concurrency_limit=20,
334
+ ).launch(show_api=False)
335
+
336
+ launch_interface()