mirror of
https://github.com/Significant-Gravitas/AutoGPT-Code-Ability.git
synced 2026-11-12 09:51:26 -10:00
* Route schema changes * Delete ruff.config.json * save current changes * style fixes by ruff * Add class parsing capability * Fix bugs * Address comments * Fix benchmarks * Fix benchmarks * Fix benchmarks * Add comments * fixing types * Add error handling and status messages for application creation * Refactor fetch_deliverable function and update application creation status * Refactor benchmark output formatting * Remove unnecessary print statement in fetch_deliverable function * Propagate DB schema changes: Function <-> CompiledRouteSpec (#65) Propagate DB schema changes: Function <-> CompiledRouteSpec (#65) --------- Co-authored-by: majdyz <[email protected]> Co-authored-by: Swifty <[email protected]> Co-authored-by: majdyz <[email protected]> * emoved broken hardcoded requirements * Add benchmarking functionality * Update branch restrictions in GitHub workflows * Add pytest-cov to dependencies * Update ruff formatter command to include --check option * Update workflow names * Refactor code formatting and fix indentation issues * Update Python dependency caching and installation process * Add Prisma client generation step to CI workflow * Refactor test_process_object_type to use async/await * Add pytest and ValidationError imports, update arg_types assertion, and add test for ValidationError * Remove unused imports and commented code * Add logger to OpenAIChatClient class * Add async context manager for database connection and disconnection * Add blank line for readability * Refactor function_def.arg_types assignment in ast_test.py * mark integration tests * Update test workflow name * Add OpenAI API key configuration * Better Types for Requirements Request/Response (#76) Better Types for Requirements Request/Response --------- Co-authored-by: majdyz <[email protected]> * [AGPT-474] End-to-end Benchmark (#77) * Remove unnecessary fetch_deliverable calls and update invoice_generator_requirements * Fix typo in hardcoded.py * Add missing app IDs and interview IDs for calendar booking, inventory management, and invoicing systems * Add options to benchmark and example commands * Refactor benchmarking code and add new functions * Add task description method to ExampleTask enum * Added end-to-end running * Add hardcoded flag to filter examples in benchmark.py * Refactor run_benchmark_example function to handle exceptions * Fix error handling in specification routes * Fix Function generation bug on nested object type (#79) Co-authored-by: majdyz <[email protected]> * Speeding up requirements system --------- Co-authored-by: Zamil Majdy <[email protected]> Co-authored-by: majdyz <[email protected]> * Refactor code: Remove unused imports and clean up formatting * [AGPT-478] Add Support for Composite Type with multiple Pydantic/nont-primitive classes (#78) * [AGPT-478] Add support for multiple composite Pydantic objects * Ruff Ruff! * Fix failing test * formatting * fix populate-db command * fix run all benchmarks --------- Co-authored-by: majdyz <[email protected]> Co-authored-by: Swifty <[email protected]> * Refactor package handling in packager.py (#81) * [Fix] User provided app name being replaced (#82) * Only make databases when required (#83) * feat: make the name match * feat: database becomes optional * Update agent.py * Integrate related types into the requirements system (#84) * feat: make the name match * feat: database becomes optional * feat: initial model changes * feat: add prompts * feat: more prompts * fix: nits * fix: wrong type 😢 * feat: improved prompts * Cleanup for field type (#85) Co-authored-by: majdyz <[email protected]> * [AGPT-489] Improve type composite-type matching & extracting algorithm (#86) Co-authored-by: majdyz <[email protected]> * [AGPT-489] Add Autogeneration of Typing import (#87) Co-authored-by: majdyz <[email protected]> * [AGPT-489] Fix broken class compiling logic (#88) Co-authored-by: majdyz <[email protected]> * [AGPT-489] Fix function fetching to always include RelatedTypes (#89) [AGPT-489] Fix function fetching to always include RelatedTypes --------- Co-authored-by: majdyz <[email protected]> * fix lock file * feat: endpoint updates (#95) * feat: endpoint updates * fix: ambiguous param * [AGPT-486] Fix codegen generate code with missing pydantic object (#92) Co-authored-by: majdyz <[email protected]> * Fix retry prompt (#96) Co-authored-by: majdyz <[email protected]> * Allow benchmark on $PORT (#98) * Ntindle/agpt 506 add a bit of debug tooling for requirements gen (#100) * [AGPT-485] Fix missing pydantic object during requirement-step; leading to LLM to guess wrong signature (#97) [AGPT-485] Fix missing pydantic object during requirement-step; leading to LLM to guess wrong signature --------- Co-authored-by: majdyz <[email protected]> * [AGPT-157] Add Database Integration Generation (#90) * Added prisma client to server code * Add DatabaseSchema to INCLUDE_FUNC * Update functions to be async and add database schema documentation * Add DatabaseSchema and DatabaseTables to ApiRouteSpec * Updated dev prompts for db * Update profile management descriptions * Update route function definition to be async * Remove logging of database schema * Add Prisma schema file generation * Refactor benchmark and agent modules * Refactor code and comment out debug statements * formatting * Add available_functions to develop_route * Update prisma import and method calls * loading all related tables * Refactor create_prisma_scheama_file function to handle cases with no database schema * Fix async function call in packager.py * Fix database table query in packager.py * Fix database access and unnecessary imports * review comments * [AGPT-508] Enum support for Codex - Generation Logic Layer (#102) Co-authored-by: majdyz <[email protected]> * Add Enum Generation to Requriements (#101) * Added prisma client to server code * Add DatabaseSchema to INCLUDE_FUNC * Update functions to be async and add database schema documentation * Add DatabaseSchema and DatabaseTables to ApiRouteSpec * Updated dev prompts for db * Update profile management descriptions * Update route function definition to be async * Remove logging of database schema * Add Prisma schema file generation * Refactor benchmark and agent modules * Refactor code and comment out debug statements * formatting * Add available_functions to develop_route * Update prisma import and method calls * loading all related tables * Refactor create_prisma_scheama_file function to handle cases with no database schema * Fix async function call in packager.py * Fix database table query in packager.py * Fix database access and unnecessary imports * feat: add enums to the database gen * fix: formatting * Updated to new schema * update hardcoded requirements * fix: objectType generation without type bool * Add database enum import statement * removed unused var as failing lint check --------- Co-authored-by: SwiftyOS <[email protected]> * More Linting Issues Fixes (#99) * fix: more linting issues * Remove error log for async functions * Fix return_type default value in FunctionDef class * Added another validation check --------- Co-authored-by: Swifty <[email protected]> * [AGPT-463] Add code generation validation using Ruff (#103) --------- Co-authored-by: majdyz <[email protected]> --------- Co-authored-by: majdyz <[email protected]> Co-authored-by: majdyz <[email protected]> Co-authored-by: Zamil Majdy <[email protected]> Co-authored-by: Nicholas Tindle <[email protected]>
168 lines
4.7 KiB
Python
168 lines
4.7 KiB
Python
import json
|
|
|
|
import requests
|
|
|
|
|
|
def fetch_bounties(after_cursor=None):
|
|
url = "https://replit.com/graphql"
|
|
headers = {
|
|
"Accept": "*/*",
|
|
"Accept-Language": "en-GB,en;q=0.9",
|
|
"Connection": "keep-alive",
|
|
"Content-Type": "application/json",
|
|
"Host": "replit.com",
|
|
"Origin": "https://replit.com",
|
|
"Referer": "https://replit.com/bounties?status=completed&order=creationDateDescending",
|
|
"Sec-Fetch-Dest": "empty",
|
|
"Sec-Fetch-Mode": "cors",
|
|
"Sec-Fetch-Site": "same-origin",
|
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15",
|
|
"x-client-version": "c6ef787e",
|
|
"x-forwarded-host": "replit.com",
|
|
"x-requested-with": "XMLHttpRequest",
|
|
}
|
|
query = """
|
|
query BountiesPageSearch($input: BountySearchInput!) {
|
|
bountySearch(input: $input) {
|
|
... on BountySearchConnection {
|
|
items {
|
|
id
|
|
title
|
|
descriptionPreview
|
|
description
|
|
cycles
|
|
deadline
|
|
status
|
|
slug
|
|
solverPayout
|
|
timeCreated
|
|
applicationCount
|
|
isUnlisted
|
|
solver {
|
|
id
|
|
username
|
|
image
|
|
url
|
|
}
|
|
user {
|
|
id
|
|
username
|
|
image
|
|
url
|
|
}
|
|
}
|
|
pageInfo {
|
|
hasNextPage
|
|
nextCursor
|
|
}
|
|
}
|
|
}
|
|
}
|
|
"""
|
|
variables = {
|
|
"input": {
|
|
"after": after_cursor,
|
|
"count": 10, # Adjust the count as needed
|
|
"searchQuery": "",
|
|
"statuses": ["completed"],
|
|
"order": "creationDateDescending",
|
|
"listingState": "listed",
|
|
}
|
|
}
|
|
response = requests.post(
|
|
url, headers=headers, json={"query": query, "variables": variables}
|
|
)
|
|
|
|
try:
|
|
response.raise_for_status() # Check if the response status code is 200
|
|
return response.json()
|
|
except requests.exceptions.HTTPError as e:
|
|
print(f"HTTP error occurred: {e}") # HTTP error
|
|
|
|
except requests.exceptions.JSONDecodeError as e:
|
|
print(f"JSON decode error: {e}")
|
|
print("Raw response:", response.text) # Print raw response text
|
|
except requests.exceptions.RequestException as e:
|
|
print(f"Request error occurred: {e}") # Other errors
|
|
|
|
return None
|
|
|
|
|
|
def download_bounties():
|
|
all_bounties = []
|
|
next_cursor = None
|
|
try:
|
|
while True:
|
|
print("Fetching bounties")
|
|
data = fetch_bounties(after_cursor=next_cursor)
|
|
if not data:
|
|
raise ValueError("Failed to download bounties")
|
|
|
|
bounties = data["data"]["bountySearch"]["items"]
|
|
all_bounties.extend(bounties)
|
|
page_info = data["data"]["bountySearch"]["pageInfo"]
|
|
if page_info["hasNextPage"]:
|
|
next_cursor = page_info["nextCursor"]
|
|
else:
|
|
break
|
|
except Exception as e:
|
|
print(e)
|
|
print("Failed to download bounties")
|
|
return
|
|
finally:
|
|
# Save the data
|
|
with open("bounties.json", "w") as file:
|
|
json.dump(all_bounties, file, indent=4)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
with open("bounties.json", "r") as file:
|
|
data = json.load(file)
|
|
print(len(data))
|
|
total = 0
|
|
cycles_total = 0
|
|
for bounty in data:
|
|
total += bounty["solverPayout"]
|
|
cycles_total += bounty["cycles"]
|
|
|
|
print((cycles_total - total) * 0.01)
|
|
|
|
import numpy as np
|
|
from sklearn.cluster import KMeans
|
|
from sklearn.feature_extraction.text import TfidfVectorizer
|
|
|
|
# Extracting the 'descriptionPreview' field
|
|
descriptions = [
|
|
bounty["descriptionPreview"]
|
|
for bounty in data
|
|
if "descriptionPreview" in bounty
|
|
]
|
|
|
|
# Using TF-IDF to vectorize the descriptions
|
|
vectorizer = TfidfVectorizer(stop_words="english")
|
|
X = vectorizer.fit_transform(descriptions)
|
|
|
|
# Perform KMeans clustering with 3 clusters
|
|
kmeans = KMeans(n_clusters=10, random_state=42)
|
|
kmeans.fit(X)
|
|
|
|
# Find the cluster centers
|
|
centers = kmeans.cluster_centers_
|
|
|
|
# Find the index of the closest point in each cluster to its center
|
|
closest_points = []
|
|
for i in range(3):
|
|
center_vec = centers[i]
|
|
distances = np.linalg.norm(X - center_vec, axis=1)
|
|
closest_point_index = np.argmin(distances)
|
|
closest_points.append(closest_point_index)
|
|
|
|
# Extract the corresponding descriptions
|
|
closest_descriptions = [descriptions[i] for i in closest_points]
|
|
|
|
print(closest_descriptions)
|
|
|
|
print(total * 0.01)
|
|
|
|
# download_bounties()
|