Spaces:
Sleeping
Sleeping
Update app.py
Browse files11 unmodified lines12131415151617181919202122232425262728291 unmodified line31323334353637383940414243444546474849502 unmodified lines5354555657585921 unmodified lines818283728485868719 unmodified lines1071081099811011111211311 unmodified lines response = 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": "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} ] ) return response.choices[0].message.content code = response.choices[0].message.content # Clean up the code: remove leading/trailing whitespace and any markdown code blocks code = 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 line def __init__(self, api_url): self.api_url = api_url self.data = None self.processing_time = 0
def 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_time except Exception as e: self.data = {"error": str(e)} self.processing_time = time.time() - start_time
class SwarmNeuralNetwork: def __init__(self, api_url, num_agents, calls_per_agent, special_config):2 unmodified lines self.calls_per_agent = calls_per_agent self.special_config = special_config self.agents = [Agent(api_url) for _ in range(num_agents)] self.execution_time = 0
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. 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 lines else: return process_data_code
# Define the Gradio interface (same as before)# Define the Gradio interfaceiface = gr.Interface( fn=execute_snn, inputs=[app.py+16-4