{"id":26107088,"url":"https://github.com/beliavsky/groq-python-agent","last_synced_at":"2026-06-05T11:31:37.774Z","repository":{"id":281409302,"uuid":"945191889","full_name":"Beliavsky/Groq-Python-agent","owner":"Beliavsky","description":"Python script that uses LLMs on Groq to create Python programs, iterating until they run to completion","archived":false,"fork":false,"pushed_at":"2025-03-08T22:07:00.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-08T22:25:10.556Z","etag":null,"topics":["groq","groq-api","llm-coder","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Beliavsky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-08T21:37:31.000Z","updated_at":"2025-03-08T22:07:03.000Z","dependencies_parsed_at":"2025-03-08T22:25:17.100Z","dependency_job_id":"f80d0cc8-40ba-43e1-a010-b32cdc3b5181","html_url":"https://github.com/Beliavsky/Groq-Python-agent","commit_stats":null,"previous_names":["beliavsky/groq-python-agent"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beliavsky%2FGroq-Python-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beliavsky%2FGroq-Python-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beliavsky%2FGroq-Python-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beliavsky%2FGroq-Python-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Beliavsky","download_url":"https://codeload.github.com/Beliavsky/Groq-Python-agent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242762737,"owners_count":20181266,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["groq","groq-api","llm-coder","python"],"created_at":"2025-03-09T22:43:11.805Z","updated_at":"2026-06-05T11:31:37.768Z","avatar_url":"https://github.com/Beliavsky.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Groq-Python-agent\nPython script that uses LLMs on Groq to create Python programs, iterating until they run to completion. Sample output:\n\n```\nprompt:\nWrite a Python function that fits a finite mixture of normals with a\nspecified # of components to univariate data, using the EM algorithm,\nand write a main program that tests it for data simulated from a known\nmixture distribution. Write a function to display the parameters in a\nformatted table. Use the function to display the true and estimated\nparameters. Use numpy if helpful. Use the print function to\ndisplay results, using to_string() for a pandas dataframe.\nOnly output Python code. Do not give commentary.\n\nmodel: qwen-2.5-coder-32b\n\nCode ran successfully after 1 attempt (generation time: 2.349 seconds, LOC=55)!\n\nOutput:\n  Component  True Weight  True Mean  True Covariance  Estimated Weight  Estimated Mean  Estimated Covariance\n         0          0.4          0                1          0.400835        0.057349              1.097366\n         1          0.6          5                1          0.599165        5.049657              0.943687\n\n\nTotal generation time: 2.349 seconds across 1 attempt\n\nRun command: python main.py\n```\nThe code generated is\n```python\n# Generated from prompt file: prompt_mix.txt\n# Model used: qwen-2.5-coder-32b\n# Time generated: 2025-03-08 16:45:03\n# Generation time: 2.349 seconds\nimport numpy as np\nimport pandas as pd\nfrom scipy.stats import norm\nfrom scipy.special import logsumexp\n\ndef fit_mixture_of_normals(data, k, max_iter=100, tol=1e-6):\n    n = len(data)\n    np.random.seed(0)\n    means = np.random.choice(data, k)\n    covariances = np.random.rand(k)\n    weights = np.ones(k) / k\n    r = np.zeros((n, k))\n    \n    for _ in range(max_iter):\n        # Expectation step\n        for i in range(k):\n            r[:, i] = weights[i] * norm.pdf(data, means[i], np.sqrt(covariances[i]))\n        r /= r.sum(axis=1, keepdims=True) \n        \n        # Maximization step\n        s = r.sum(axis=0)\n        means = (r * data.reshape(-1, 1)).sum(axis=0) / s\n        covariances = ((r * (data.reshape(-1, 1) - means)**2).sum(axis=0) / s).clip(min=1e-6)\n        weights = s / n\n        \n        if (r.sum(axis=1) \u003e 1 + tol).any() or (r.sum(axis=1) \u003c 1 - tol).any():\n            raise ValueError(\"Row normalization failed\")\n    \n    return weights, means, covariances\n\ndef display_parameters(true_params, estimated_params):\n    true_weights, true_means, true_covariances = true_params\n    est_weights, est_means, est_covariances = estimated_params\n    \n    true_df = pd.DataFrame({\n        'Component': range(len(true_weights)),\n        'True Weight': true_weights,\n        'True Mean': true_means,\n        'True Covariance': true_covariances\n    })\n    \n    est_df = pd.DataFrame({\n        'Estimated Weight': est_weights,\n        'Estimated Mean': est_means,\n        'Estimated Covariance': est_covariances\n    })\n    \n    result_df = pd.concat([true_df, est_df], axis=1)\n    print(result_df.to_string(index=False))\n\ndef main():\n    true_weights = np.array([0.4, 0.6])\n    true_means = np.array([0, 5])\n    true_covariances = np.array([1, 1])\n    n_samples = 1000\n    \n    data = np.concatenate([\n        np.random.normal(true_means[0], np.sqrt(true_covariances[0]), int(true_weights[0] * n_samples)),\n        np.random.normal(true_means[1], np.sqrt(true_covariances[1]), int(true_weights[1] * n_samples))\n    ])\n    \n    estimated_weights, estimated_means, estimated_covariances = fit_mixture_of_normals(data, len(true_weights))\n    \n    true_params = (true_weights, true_means, true_covariances)\n    estimated_params = (estimated_weights, estimated_means, estimated_covariances)\n    \n    display_parameters(true_params, estimated_params)\n\nif __name__ == \"__main__\":\n    main()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeliavsky%2Fgroq-python-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeliavsky%2Fgroq-python-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeliavsky%2Fgroq-python-agent/lists"}