Spaces:
Sleeping
Sleeping
Update app.py
Browse files11 unmodified lines12131415161718192021221 unmodified line242526272829303132333435363738392 unmodified lines42434445464721 unmodified lines6970717273747519 unmodified lines959697989910010111 unmodified linesresponse = client.chat.completions.create(model="gpt-3.5-turbo",messages=[{"role": "system", "content": "You are a Python expert capable of implementing specific functions for a Swarm Neural Network (SNN). Return only the Python code for the requested function."},{"role": "user", "content": prompt}])return response.choices[0].message.contentexcept Exception as e:return f"Error calling GPT-3.5: {str(e)}"1 unmodified linedef __init__(self, api_url):self.api_url = api_urlself.data = Nonedef make_api_call(self):try:response = requests.get(self.api_url)if response.status_code == 200:self.data = response.json()else:self.data = {"error": f"API call failed with status code {response.status_code}"}except Exception as e:self.data = {"error": str(e)}class SwarmNeuralNetwork:def __init__(self, api_url, num_agents, calls_per_agent, special_config):2 unmodified linesself.calls_per_agent = calls_per_agentself.special_config = special_configself.agents = [Agent(api_url) for _ in range(num_agents)]def run(self):start_time = time.time()21 unmodified lines- Calls per Agent: {calls_per_agent}- Special Configuration: {special_config if special_config else 'None'}Provide only the Python code for the process_data method."""process_data_code = call_gpt3_5(prompt, openai_api_key)19 unmodified lineselse:return process_data_code# Define the Gradio interface (same as before)iface = gr.Interface(fn=execute_snn,inputs=[11 unmodified lines1213141516171819202122232425262728291 unmodified line31323334353637383940414243444546474849502 unmodified lines5354555657585921 unmodified lines8182838485868719 unmodified lines10710810911011111211311 unmodified linesresponse = client.chat.completions.create(model="gpt-3.5-turbo",messages=[{"role": "system", "content": "You are a Python expert capable of implementing specific functions for a Swarm Neural Network (SNN). Return only the Python code for the requested function, without any additional text."},{"role": "user", "content": prompt}])code = response.choices[0].message.content# Clean up the code: remove leading/trailing whitespace and any markdown code blockscode = code.strip()if code.startswith("```python"):code = code[10:]if code.endswith("```"):code = code[:-3]return code.strip()except Exception as e:return f"Error calling GPT-3.5: {str(e)}"1 unmodified linedef __init__(self, api_url):self.api_url = api_urlself.data = Noneself.processing_time = 0def make_api_call(self):try:start_time = time.time()response = requests.get(self.api_url)if response.status_code == 200:self.data = response.json()else:self.data = {"error": f"API call failed with status code {response.status_code}"}self.processing_time = time.time() - start_timeexcept Exception as e:self.data = {"error": str(e)}self.processing_time = time.time() - start_timeclass SwarmNeuralNetwork:def __init__(self, api_url, num_agents, calls_per_agent, special_config):2 unmodified linesself.calls_per_agent = calls_per_agentself.special_config = special_configself.agents = [Agent(api_url) for _ in range(num_agents)]self.execution_time = 0def run(self):start_time = time.time()21 unmodified lines- Calls per Agent: {calls_per_agent}- Special Configuration: {special_config if special_config else 'None'}Provide only the Python code for the process_data method, without any additional text or markdown formatting."""process_data_code = call_gpt3_5(prompt, openai_api_key)19 unmodified lineselse:return process_data_code# Define the Gradio interfaceiface = gr.Interface(fn=execute_snn,inputs=[
app.py+16-4