hzxwonder commited on
Commit
30becf4
·
1 Parent(s): 4e5e176
Files changed (2) hide show
  1. deciders/utils.py +1 -1
  2. main_reflexion.py +10 -10
deciders/utils.py CHANGED
@@ -25,7 +25,7 @@ def run_chain(chain, *args, **kwargs):
25
  return chain.run(*args, **kwargs)
26
 
27
  # @retry(wait=wait_random_exponential(min=1, max=60), stop=stop_after_attempt(6))
28
- def get_completion(prompt: str, api_type: str = "azure", engine: str = "gpt-35-turbo", temperature: float = 0.0, max_tokens: int = 256, stop_strs: Optional[List[str]] = None) -> str:
29
  response = openai.Completion.create(
30
  model=engine,
31
  engine=engine,
 
25
  return chain.run(*args, **kwargs)
26
 
27
  # @retry(wait=wait_random_exponential(min=1, max=60), stop=stop_after_attempt(6))
28
+ def get_completion(prompt: str, engine: str = "gpt-35-turbo", temperature: float = 0.0, max_tokens: int = 256, stop_strs: Optional[List[str]] = None) -> str:
29
  response = openai.Completion.create(
30
  model=engine,
31
  engine=engine,
main_reflexion.py CHANGED
@@ -99,7 +99,7 @@ def _run(translator, environment, decider, max_episode_len, logfile, args, trail
99
  error_flag = True
100
  retry_num = 1
101
  for error_i in range(retry_num):
102
- try:
103
  action, prompt, response, tokens, cost = decider.act(
104
  state_description,
105
  action_description,
@@ -127,15 +127,15 @@ def _run(translator, environment, decider, max_episode_len, logfile, args, trail
127
  current_total_cost += cost
128
  error_flag = False
129
  break
130
- except Exception as e:
131
- print(e)
132
- if error_i < retry_num-1:
133
- if "Cliff" in args.env_name or "Frozen" in args.env_name:
134
- decider.env_history.remove_invalid_state()
135
- decider.env_history.remove_invalid_state()
136
- if logger:
137
- logger.debug(f"Error: {e}, Retry! ({error_i+1}/{retry_num})")
138
- continue
139
  if error_flag:
140
  if "Continuous" in args.env_name:
141
  action = [decider.default_action]
 
99
  error_flag = True
100
  retry_num = 1
101
  for error_i in range(retry_num):
102
+ # try:
103
  action, prompt, response, tokens, cost = decider.act(
104
  state_description,
105
  action_description,
 
127
  current_total_cost += cost
128
  error_flag = False
129
  break
130
+ # except Exception as e:
131
+ # print(e)
132
+ # if error_i < retry_num-1:
133
+ # if "Cliff" in args.env_name or "Frozen" in args.env_name:
134
+ # decider.env_history.remove_invalid_state()
135
+ # decider.env_history.remove_invalid_state()
136
+ # if logger:
137
+ # logger.debug(f"Error: {e}, Retry! ({error_i+1}/{retry_num})")
138
+ # continue
139
  if error_flag:
140
  if "Continuous" in args.env_name:
141
  action = [decider.default_action]