callanwu commited on
Commit
3c40284
1 Parent(s): cd14fc6
Files changed (4) hide show
  1. app.py +2 -0
  2. config.json +1 -1
  3. gradio_backend.py +1 -1
  4. gradio_base.py +21 -6
app.py CHANGED
@@ -209,6 +209,8 @@ class DebateUI(WebUI):
209
  default_cos_play_id = self.cache["default_cos_play_id"] if default_cos_play_id is None else default_cos_play_id
210
 
211
  with gr.Blocks(css=gc.CSS) as demo:
 
 
212
  with gr.Row():
213
  with gr.Column():
214
  self.text_api = gr.Textbox(
 
209
  default_cos_play_id = self.cache["default_cos_play_id"] if default_cos_play_id is None else default_cos_play_id
210
 
211
  with gr.Blocks(css=gc.CSS) as demo:
212
+ gr.Markdown("""# Agents""")
213
+ gr.Markdown("""**Agents** is an open-source library/framework for building autonomous language agents.if you want to know more about **Agents**, please check our<a href="https://arxiv.org/pdf/2309.07870.pdf">📄 Paper</a> and<a href="http://www.aiwaves-agents.com/">📦 Github</a>. Here is a demo of **Agents**.""")
214
  with gr.Row():
215
  with gr.Column():
216
  self.text_api = gr.Textbox(
config.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "config": {
3
- "API_KEY": "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",
4
  "PROXY": "",
5
  "MAX_CHAT_HISTORY": "5",
6
  "TOP_K": "1",
 
1
  {
2
  "config": {
3
+ "API_KEY": "",
4
  "PROXY": "",
5
  "MAX_CHAT_HISTORY": "5",
6
  "TOP_K": "1",
gradio_backend.py CHANGED
@@ -7,7 +7,7 @@ from agents.Agent import Agent
7
  from agents.Environment import Environment
8
  from agents.Memory import Memory
9
  from gradio_base import Client
10
- from run_gradio import DebateUI
11
 
12
  def process(action):
13
  response = action.response
 
7
  from agents.Environment import Environment
8
  from agents.Memory import Memory
9
  from gradio_base import Client
10
+ from app import DebateUI
11
 
12
  def process(action):
13
  response = action.response
gradio_base.py CHANGED
@@ -25,7 +25,22 @@ import socket
25
  import psutil
26
  import os
27
  from abc import abstractmethod
 
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  def convert2list4agentname(sop):
30
  """
31
  Extract the agent names of all states
@@ -304,7 +319,7 @@ class Client:
304
  self.send_message(message=message)
305
 
306
  def send_message(self, message):
307
- """Send the messaget to the server."""
308
  if isinstance(message, list) or isinstance(message, dict):
309
  message = str(message)
310
  assert isinstance(message, str)
@@ -339,7 +354,7 @@ class Client:
339
  continue
340
  else:
341
  remaining = list_dataset[-1]
342
- # Recieve successfully
343
  list_dataset = list_dataset[:-1]
344
  return_value = []
345
  for item in list_dataset:
@@ -488,12 +503,12 @@ class WebUI:
488
 
489
  def _second_send(self, message:dict):
490
  # Send the modified message.
491
- # It will be executed in `self.send_start_cmd()` automtically.
492
  self.send_message(str(message))
493
 
494
  def _third_send(self):
495
  # Send start command.
496
- # It will be executed in `self.send_start_cmd()` automtically.
497
  self.send_message(self.SIGN['START'])
498
 
499
  def send_start_cmd(self, message:dict={"hello":"hello"}):
@@ -526,7 +541,7 @@ class WebUI:
526
  self._connect()
527
 
528
  def _start_client(self):
529
- print(f"server: excuting `{' '.join(self.client_cmd)}` ...")
530
  self.backend = subprocess.Popen(self.client_cmd)
531
 
532
  def _close_client(self):
@@ -556,4 +571,4 @@ class WebUI:
556
 
557
 
558
  if __name__ == '__main__':
559
- pass
 
25
  import psutil
26
  import os
27
  from abc import abstractmethod
28
+ import openai
29
 
30
+ def test_apikey_connection(api_key=None, model="gpt-3.5-turbo"):
31
+ openai.api_key = api_key if api_key is not None else os.environ["API_KEY"]
32
+ if "PROXY" in os.environ:
33
+ openai.proxy = os.environ["PROXY"]
34
+ messages = [{"role": "user", "content": "what's your name?"}]
35
+ try:
36
+ response = openai.ChatCompletion.create(
37
+ model=model,
38
+ messages=messages,
39
+ )
40
+ return True
41
+ except:
42
+ return False
43
+
44
  def convert2list4agentname(sop):
45
  """
46
  Extract the agent names of all states
 
319
  self.send_message(message=message)
320
 
321
  def send_message(self, message):
322
+ """Send the message to the server."""
323
  if isinstance(message, list) or isinstance(message, dict):
324
  message = str(message)
325
  assert isinstance(message, str)
 
354
  continue
355
  else:
356
  remaining = list_dataset[-1]
357
+ # Receive successfully
358
  list_dataset = list_dataset[:-1]
359
  return_value = []
360
  for item in list_dataset:
 
503
 
504
  def _second_send(self, message:dict):
505
  # Send the modified message.
506
+ # It will be executed in `self.send_start_cmd()` automatically.
507
  self.send_message(str(message))
508
 
509
  def _third_send(self):
510
  # Send start command.
511
+ # It will be executed in `self.send_start_cmd()` automatically.
512
  self.send_message(self.SIGN['START'])
513
 
514
  def send_start_cmd(self, message:dict={"hello":"hello"}):
 
541
  self._connect()
542
 
543
  def _start_client(self):
544
+ print(f"server: executing `{' '.join(self.client_cmd)}` ...")
545
  self.backend = subprocess.Popen(self.client_cmd)
546
 
547
  def _close_client(self):
 
571
 
572
 
573
  if __name__ == '__main__':
574
+ pass