Spaces:
Runtime error
Runtime error
Fix: try to remove proxy
Browse files
app.py
CHANGED
|
@@ -67,7 +67,7 @@ class DemoRunner:
|
|
| 67 |
|
| 68 |
return lmp_planner
|
| 69 |
|
| 70 |
-
def setup(self, api_key, n_blocks, n_bowls,
|
| 71 |
openai.api_key = api_key
|
| 72 |
|
| 73 |
# self._env = PickPlaceEnv(render=True, high_res=True, high_frame_rate=False)
|
|
@@ -112,18 +112,14 @@ class DemoRunner:
|
|
| 112 |
return self._md_logger.get_log(), None, video_file_name
|
| 113 |
|
| 114 |
|
| 115 |
-
def setup(api_key, n_blocks, n_bowls,
|
|
|
|
| 116 |
if not api_key:
|
| 117 |
return 'Please enter your OpenAI API key!', None, None
|
| 118 |
|
| 119 |
if n_blocks + n_bowls == 0:
|
| 120 |
return 'Please select at least one object!', None, None
|
| 121 |
|
| 122 |
-
if proxy_addr is not None and "http://" in proxy_addr:
|
| 123 |
-
openai.proxy = proxy_addr
|
| 124 |
-
elif proxy_addr is not None:
|
| 125 |
-
openai.proxy = f"http://{proxy_addr}"
|
| 126 |
-
|
| 127 |
# ip_status, ip_info = get_geoip(openai.proxy)
|
| 128 |
# if ip_status == -1:
|
| 129 |
# return ip_info, None, None
|
|
@@ -141,7 +137,7 @@ def setup(api_key, n_blocks, n_bowls, proxy_addr, cfg_choice):
|
|
| 141 |
|
| 142 |
demo_runner = DemoRunner(cfg_file)
|
| 143 |
|
| 144 |
-
info, img = demo_runner.setup(api_key, n_blocks, n_bowls,
|
| 145 |
return info, img, demo_runner
|
| 146 |
|
| 147 |
|
|
@@ -166,7 +162,7 @@ if __name__ == '__main__':
|
|
| 166 |
with gr.Column():
|
| 167 |
with gr.Column():
|
| 168 |
inp_api_key = gr.Textbox(label='OpenAI API Key (this is not stored anywhere)', lines=1)
|
| 169 |
-
inp_proxy_addr = gr.Textbox(label='Your local proxy address', lines=1)
|
| 170 |
inp_cfg = gr.Dropdown(label='Configuration', choices=['voxposer', 'agibot'])
|
| 171 |
with gr.Row():
|
| 172 |
inp_n_blocks = gr.Slider(label='Number of Blocks', minimum=0, maximum=4, value=3, step=1)
|
|
@@ -187,7 +183,7 @@ if __name__ == '__main__':
|
|
| 187 |
|
| 188 |
btn_setup.click(
|
| 189 |
setup,
|
| 190 |
-
inputs=[inp_api_key, inp_n_blocks, inp_n_bowls,
|
| 191 |
outputs=[info_setup, img_setup, state]
|
| 192 |
)
|
| 193 |
btn_run.click(
|
|
|
|
| 67 |
|
| 68 |
return lmp_planner
|
| 69 |
|
| 70 |
+
def setup(self, api_key, n_blocks, n_bowls, cfg_choice):
|
| 71 |
openai.api_key = api_key
|
| 72 |
|
| 73 |
# self._env = PickPlaceEnv(render=True, high_res=True, high_frame_rate=False)
|
|
|
|
| 112 |
return self._md_logger.get_log(), None, video_file_name
|
| 113 |
|
| 114 |
|
| 115 |
+
def setup(api_key, n_blocks, n_bowls, cfg_choice):
|
| 116 |
+
|
| 117 |
if not api_key:
|
| 118 |
return 'Please enter your OpenAI API key!', None, None
|
| 119 |
|
| 120 |
if n_blocks + n_bowls == 0:
|
| 121 |
return 'Please select at least one object!', None, None
|
| 122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
# ip_status, ip_info = get_geoip(openai.proxy)
|
| 124 |
# if ip_status == -1:
|
| 125 |
# return ip_info, None, None
|
|
|
|
| 137 |
|
| 138 |
demo_runner = DemoRunner(cfg_file)
|
| 139 |
|
| 140 |
+
info, img = demo_runner.setup(api_key, n_blocks, n_bowls, cfg_choice)
|
| 141 |
return info, img, demo_runner
|
| 142 |
|
| 143 |
|
|
|
|
| 162 |
with gr.Column():
|
| 163 |
with gr.Column():
|
| 164 |
inp_api_key = gr.Textbox(label='OpenAI API Key (this is not stored anywhere)', lines=1)
|
| 165 |
+
# inp_proxy_addr = gr.Textbox(label='Your local proxy address', lines=1)
|
| 166 |
inp_cfg = gr.Dropdown(label='Configuration', choices=['voxposer', 'agibot'])
|
| 167 |
with gr.Row():
|
| 168 |
inp_n_blocks = gr.Slider(label='Number of Blocks', minimum=0, maximum=4, value=3, step=1)
|
|
|
|
| 183 |
|
| 184 |
btn_setup.click(
|
| 185 |
setup,
|
| 186 |
+
inputs=[inp_api_key, inp_n_blocks, inp_n_bowls, inp_cfg],
|
| 187 |
outputs=[info_setup, img_setup, state]
|
| 188 |
)
|
| 189 |
btn_run.click(
|
lmp.py
CHANGED
|
@@ -57,7 +57,7 @@ class LMP:
|
|
| 57 |
temperature=self._cfg['temperature'],
|
| 58 |
model=self._cfg['model'],
|
| 59 |
max_tokens=self._cfg['max_tokens'],
|
| 60 |
-
proxy=openai.proxy,
|
| 61 |
)
|
| 62 |
code_str = response.json()["choices"][0]["message"]['content']
|
| 63 |
|
|
@@ -114,7 +114,7 @@ class LMPFGen:
|
|
| 114 |
temperature=self._cfg['temperature'],
|
| 115 |
model=self._cfg['model'],
|
| 116 |
max_tokens=self._cfg['max_tokens'],
|
| 117 |
-
proxy=openai.proxy,
|
| 118 |
)
|
| 119 |
f_src = response.json()["choices"][0]["message"]['content']
|
| 120 |
|
|
|
|
| 57 |
temperature=self._cfg['temperature'],
|
| 58 |
model=self._cfg['model'],
|
| 59 |
max_tokens=self._cfg['max_tokens'],
|
| 60 |
+
# proxy=openai.proxy,
|
| 61 |
)
|
| 62 |
code_str = response.json()["choices"][0]["message"]['content']
|
| 63 |
|
|
|
|
| 114 |
temperature=self._cfg['temperature'],
|
| 115 |
model=self._cfg['model'],
|
| 116 |
max_tokens=self._cfg['max_tokens'],
|
| 117 |
+
# proxy=openai.proxy,
|
| 118 |
)
|
| 119 |
f_src = response.json()["choices"][0]["message"]['content']
|
| 120 |
|
utils.py
CHANGED
|
@@ -70,7 +70,7 @@ def get_geoip(proxy=None):
|
|
| 70 |
return 1, text
|
| 71 |
|
| 72 |
|
| 73 |
-
@retry(wait=wait_random_exponential(multiplier=1, max=
|
| 74 |
def chat_completion_request(
|
| 75 |
messages,
|
| 76 |
functions=None,
|
|
@@ -91,18 +91,18 @@ def chat_completion_request(
|
|
| 91 |
json_data.update({"function_call": function_call})
|
| 92 |
if kwargs is not None:
|
| 93 |
json_data.update(kwargs)
|
| 94 |
-
with retrieve_proxy(proxy):
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
|
| 107 |
|
| 108 |
def generate_messages(prompt):
|
|
|
|
| 70 |
return 1, text
|
| 71 |
|
| 72 |
|
| 73 |
+
@retry(wait=wait_random_exponential(multiplier=1, max=3), stop=stop_after_attempt(5))
|
| 74 |
def chat_completion_request(
|
| 75 |
messages,
|
| 76 |
functions=None,
|
|
|
|
| 91 |
json_data.update({"function_call": function_call})
|
| 92 |
if kwargs is not None:
|
| 93 |
json_data.update(kwargs)
|
| 94 |
+
# with retrieve_proxy(proxy):
|
| 95 |
+
try:
|
| 96 |
+
response = requests.post(
|
| 97 |
+
"https://api.openai.com/v1/chat/completions",
|
| 98 |
+
headers=headers,
|
| 99 |
+
json=json_data,
|
| 100 |
+
)
|
| 101 |
+
return response
|
| 102 |
+
except Exception as e:
|
| 103 |
+
print("Unable to generate ChatCompletion response")
|
| 104 |
+
print(f"Exception: {e}")
|
| 105 |
+
return e
|
| 106 |
|
| 107 |
|
| 108 |
def generate_messages(prompt):
|