329 except Exception as e: 330 print(f"Failed to import submodules for {module_name}: {e}") 331 332 try: 333 exec(sanitize_code(code_string), globals_dict, locals_dict) 334 except Exception as e: 335 print("An error occurred:") 336 traceback.print_exc()
41 with open(self.registry_file, "w") as f: 42 json.dump(self.registry, f, indent=4) 43 44 def hash_prompt(self, prompt): 45 return hashlib.md5(prompt.encode('utf-8')).hexdigest() 46 47 def add_function(self, prompt, function_code, imports, comment, input_types): 48 prompt_hash = self.hash_prompt(prompt)
22 {"role": "user", "content": prompt}], 23 "temperature": temperature, 24 "max_tokens": max_tokens 25 } 26 response = requests.post(self.api_url, headers=headers, json=payload) 27 if response.status_code == 200: 28 return response.json().get('choices', [{}])[0].get('message', {}).get('content', '').strip() 29 else: