├── LICENSE ├── README.md ├── instructions.txt ├── main.py ├── openapi.json └── requirements.txt /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 rUv 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FastAPI Gateway to GitHub (Ai API Fabric) 2 | 3 | This repository hosts a FastAPI Coding Co-pilot designed as an interface with GitHub's search API. It facilitates a range of search operations including issues, commits, code, users, topics, and repositories. The application strikes a balance by offering a scalable, extensible, and robust infrastructure, tailored to enhance AI applications. It's adept at managing intricate data processing tasks and adeptly delivering intelligent functionalities with efficiency. 4 | 5 | Try the GPT here: 6 | https://chat.openai.com/g/g-rvFHm9pMe-the-coding-wingman 7 | 8 | Complete Tutorial: 9 | https://www.linkedin.com/pulse/creating-your-own-intelligent-gpt-agent-coding-wingman-reuven-cohen-gad9f/ 10 | 11 | ## Features 12 | 13 | - OAuth2 and Bearer token based security for endpoints. 14 | - GitHub API integration to search for different entities (code, commits, issues, labels, repositories, topics, users). 15 | - Asynchronous HTTP requests for improved performance. 16 | - Paginated responses for large result sets. 17 | - CORS middleware for cross-origin resource sharing. 18 | - Automatic redirection to FastAPI's auto-generated interactive API documentation. 19 | 20 | # API Fabric for AI Applications 21 | 22 | The structure provided by `main.py` using FastAPI serves as a core element for an API fabric, initially built on the GitHub Search API. This fabric underpins AI applications such as ChatGPT with GPT-3 assistants by enabling efficient, scalable, and secure interactions with diverse data sources and services. 23 | 24 | ## Modular Design and API Compatibility 25 | 26 | FastAPI's modular nature allows for straightforward expansion and management of endpoints. While the current structure is tied to GitHub's Search API, it could easily be modified to integrate with other APIs such as Stripe for payments, Microsoft Graph for Office 365 services, or Google's various APIs. 27 | 28 | ## Asynchronous Processing 29 | 30 | The asynchronous processing capabilities of FastAPI benefit AI application requests that may take longer to process. This functionality is key to improved concurrency, reduced response times, and increased system throughput. 31 | 32 | ## Security and Access Control 33 | 34 | The existing security implementations demonstrate how application access can be controlled and secured—a key aspect for handling sensitive AI-generated data or proprietary algorithms. The platform is designed to support advanced OAuth2 flows, enhancing security as applications evolve. 35 | 36 | ## Extensibility and Integration 37 | 38 | Developers can extend this API fabric to integrate additional APIs, orchestrate complex data workflows, and standardize communication protocols. This facilitates efficient AI functions like natural language understanding, response generation, and user interaction handling typical of GPT-3 assistants. 39 | 40 | ## Real-time Processing and Task Management 41 | 42 | With support for background tasks and real-time processing, the FastAPI infrastructure is well-suited for high-demand and real-time AI interactions, such as streaming data analysis and conversational agents, catering to the needs of dynamic AI applications. 43 | 44 | ## Prerequisites 45 | 46 | To run this API gateway, you will need: 47 | 48 | - Python 3.6+ 49 | - Packages: `fastapi`, `httpx`, `uvicorn`, `pydantic`, `python-multipart`, `python-jose`, `passlib`, `bcrypt` 50 | 51 | ## Environment Variables 52 | 53 | Before running the server, ensure the following environment variables are set: 54 | 55 | - `FASTAPI_SERVER_URL`: The server URL where FastAPI will serve the API (optional). 56 | - `GITHUB_TOKEN`: Personal GitHub token for API access. 57 | - `API_BEARER_TOKEN`: Secret token that clients should use to access the API. 58 | 59 | ## Installation 60 | 61 | Clone the repository and install dependencies: 62 | 63 | ```bash 64 | git clone https://github.com/ruvnet/coding-wingman.git 65 | cd coding-wingman 66 | python -m venv venv 67 | source venv/bin/activate # For Windows: venv\Scripts\activate 68 | pip install -r requirements.txt 69 | ``` 70 | ## Usage 71 | To start the server, run: 72 | ``` 73 | uvicorn main:app --reload 74 | ``` 75 | Visit http://localhost:8000/docs in your web browser to see the interactive API documentation provided by FastAPI. 76 | 77 | # Endpoints Overview 78 | The following endpoints are available in the API: 79 | 80 | - `POST /search/code/`: Search for code snippets on GitHub. 81 | - `POST /search/commits/`: Search for commits on GitHub. 82 | - `POST /search/issues/`: Search for issues on GitHub, with automatic pagination. 83 | - `POST /search/labels/`: Search for labels on GitHub. 84 | - `POST /search/repositories/`: Search for repositories on GitHub. 85 | - `POST /search/topics/`: Search for topics on GitHub. 86 | - `POST /search/users/`: Search for users on GitHub. 87 | 88 | To access the endpoints, provide a Bearer token in the Authorization header of your request. 89 | 90 | ## Security 91 | This application uses the HTTPBearer security scheme. Ensure that only authorized clients can access the API by setting up the `API_BEARER_TOKEN` environment variable. 92 | 93 | ## Prerequisites 94 | - Python 3.6+ 95 | - FastAPI 96 | - Uvicorn 97 | - HTTPX 98 | - Pydantic 99 | 100 | ## Installation 101 | To install the required packages, run the following command: 102 | 103 | ```bash 104 | pip install fastapi uvicorn httpx pydantic 105 | ``` 106 | To set the environment variables for local development, you can use the export command (on Unix-based systems) or set command (on Windows): 107 | ``` 108 | export GITHUB_TOKEN='your_github_token' 109 | export API_BEARER_TOKEN='your_api_bearer_token' 110 | export FASTAPI_SERVER_URL='your_fastapi_server_url' # Optional 111 | ``` 112 | Alternatively, you can use a .env file and load it with a library such as python-dotenv. 113 | 114 | Running the Application 115 | To start the application, run the following command: 116 | 117 | ``` 118 | uvicorn main:app --host 0.0.0.0 --port 8000 119 | ``` 120 | The application will be available at the URL specified by the FASTAPI_SERVER_URL environment variable, or by default at http://localhost:8000. 121 | 122 | ## GPT Instructions 123 | ``` 124 | The Coding Wingman, an advanced AI coding assistant with GitHub integration, offers comprehensive support for GitHub API requests. It helps users construct API requests for various GitHub operations, understand API structures, and interpret responses effectively. 125 | 126 | I also have a knowledge base of PDFs I can search. 127 | 128 | You copy this and deploy your version of the Coding Wingman from our Github 129 | https://github.com/ruvnet/coding-wingman/ 130 | 131 | Here's a more streamlined description of its capabilities and commands: 132 | 133 | Key Features: 134 | API Request Construction: Guides in building GitHub API requests for operations like managing repositories, gists, searching code, commits, issues, labels, repositories, topics, and users. 135 | API Structure Understanding: Explains API endpoints' structures, including paths, methods, and necessary parameters for each operation. 136 | Parameter Clarification: Offers insights into the usage of various API request parameters. 137 | Response Interpretation: Assists in understanding API responses, including status codes and response data. 138 | Security: Provides guidance on OAuth2 authentication and authorization processes for different data types. 139 | Schema Insights: Explains GitHub API schemas, detailing properties and types. 140 | 141 | GitHub Code Search Syntax Guide: 142 | 143 | Use Bing for queries, with URL structure: https://github.com/search?q=. 144 | Basic Search: https://github.com/search?q=http-push (searches in file content and paths). 145 | Exact Match: Enclose in quotes, e.g., "sparse index". 146 | Escape Characters: Use backslashes, e.g., "name = \"tensorflow\"" or double backslashes \\. 147 | Boolean Operations: Combine terms with AND, OR, NOT. 148 | Using Qualifiers like repo:, org:, user:, language:, path:, symbol:, content:, is: for refined searches. 149 | Regular Expressions: Enclose regex in slashes, e.g., /sparse.*index/. 150 | Separate Search Terms with spaces, except within parentheses. 151 | 152 | GitHub API Commands: 153 | 154 | /searchCode: Search for code snippets on GitHub. 155 | Example: /searchCode query="FastAPI filename:main.py" page=1 per_page=10 156 | 157 | /searchCommits: Search for commits on GitHub. 158 | Example: /searchCommits query="fix bug repo:openai/gpt-3" page=1 per_page=10 159 | 160 | /searchIssues: Search for issues on GitHub. 161 | Example: /searchIssues query="bug label:bug" page=1 per_page=10 162 | 163 | /searchLabels: Search for labels on GitHub. 164 | Example: /searchLabels query="bug repo:openai/gpt-3" page=1 per_page=10 165 | 166 | /searchRepositories: Search for repositories on GitHub. 167 | Example: /searchRepositories query="FastAPI stars:>1000" page=1 per_page=10 168 | 169 | /searchTopics: Search for topics on GitHub. 170 | Example: /searchTopics query="machine-learning" page=1 per_page=10 171 | 172 | /searchUsers: Search for users on GitHub. 173 | Example: /searchUsers query="ruvnet" page=1 per_page=10 174 | 175 | This assistant will continue to assist with coding, debugging, 3D design, and now, with a deeper focus on GitHub API interactions. Always follow the example URL structure for searches, such as https://github.com/search?q=owner%3Aruvnet&type=repositories. 176 | 177 | Use a helpful and friendly voice and tone. Use Emojis and bullets. Format text using mark down. 178 | 179 | Start - Create introduction Image 16.9 in stylish coding co-pilot style, after Provide Introductions and commands. Explain in simple terms. 180 | ``` 181 | 182 | -------------------------------------------------------------------------------- /instructions.txt: -------------------------------------------------------------------------------- 1 | The Coding Wingman, an advanced AI coding assistant with GitHub integration, offers comprehensive support for GitHub API requests. It helps users construct API requests for various GitHub operations, understand API structures, and interpret responses effectively. 2 | 3 | I also have a knowledge base of PDFs I can search. 4 | 5 | You copy this and deploy your version of the Coding Wingman from our Github 6 | https://github.com/ruvnet/coding-wingman/ 7 | 8 | Here's a more streamlined description of its capabilities and commands: 9 | 10 | Key Features: 11 | API Request Construction: Guides in building GitHub API requests for operations like managing repositories, gists, searching code, commits, issues, labels, repositories, topics, and users. 12 | API Structure Understanding: Explains API endpoints' structures, including paths, methods, and necessary parameters for each operation. 13 | Parameter Clarification: Offers insights into the usage of various API request parameters. 14 | Response Interpretation: Assists in understanding API responses, including status codes and response data. 15 | Security: Provides guidance on OAuth2 authentication and authorization processes for different data types. 16 | Schema Insights: Explains GitHub API schemas, detailing properties and types. 17 | 18 | GitHub Code Search Syntax Guide: 19 | 20 | Use Bing for queries, with URL structure: https://github.com/search?q=. 21 | Basic Search: https://github.com/search?q=http-push (searches in file content and paths). 22 | Exact Match: Enclose in quotes, e.g., "sparse index". 23 | Escape Characters: Use backslashes, e.g., "name = \"tensorflow\"" or double backslashes \\. 24 | Boolean Operations: Combine terms with AND, OR, NOT. 25 | Using Qualifiers like repo:, org:, user:, language:, path:, symbol:, content:, is: for refined searches. 26 | Regular Expressions: Enclose regex in slashes, e.g., /sparse.*index/. 27 | Separate Search Terms with spaces, except within parentheses. 28 | 29 | GitHub API Commands: 30 | 31 | /searchCode: Search for code snippets on GitHub. 32 | Example: /searchCode query="FastAPI filename:main.py" page=1 per_page=10 33 | 34 | /searchCommits: Search for commits on GitHub. 35 | Example: /searchCommits query="fix bug repo:openai/gpt-3" page=1 per_page=10 36 | 37 | /searchIssues: Search for issues on GitHub. 38 | Example: /searchIssues query="bug label:bug" page=1 per_page=10 39 | 40 | /searchLabels: Search for labels on GitHub. 41 | Example: /searchLabels query="bug repo:openai/gpt-3" page=1 per_page=10 42 | 43 | /searchRepositories: Search for repositories on GitHub. 44 | Example: /searchRepositories query="FastAPI stars:>1000" page=1 per_page=10 45 | 46 | /searchTopics: Search for topics on GitHub. 47 | Example: /searchTopics query="machine-learning" page=1 per_page=10 48 | 49 | /searchUsers: Search for users on GitHub. 50 | Example: /searchUsers query="ruvnet" page=1 per_page=10 51 | 52 | This assistant will continue to assist with coding, debugging, 3D design, and now, with a deeper focus on GitHub API interactions. Always follow the example URL structure for searches, such as https://github.com/search?q=owner%3Aruvnet&type=repositories. 53 | 54 | Use a helpful and friendly voice and tone. Use Emojis and bullets. Format text using mark down. 55 | 56 | Start - Create introduction Image 16.9 in stylish coding co-pilot style, after Provide Introductions and commands. Explain in simple terms. 57 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | # - Coding Wingman 2 | # /\__/\ - main.py 3 | # ( o.o ) - v0.0.1 4 | # >^< - by @rUv 5 | 6 | from fastapi.security import HTTPBearer, OAuth2AuthorizationCodeBearer 7 | from fastapi import FastAPI, HTTPException, Depends 8 | from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials 9 | from fastapi.middleware.cors import CORSMiddleware 10 | from pydantic import BaseModel 11 | from starlette.responses import RedirectResponse 12 | import httpx 13 | import os 14 | import json 15 | from fastapi.responses import StreamingResponse 16 | 17 | # Initialize a new FastAPI application, 18 | # and use the FASTAPI_SERVER_URL environment variable to specify the server url. 19 | # If FASTAPI_SERVER_URL is not set, the servers list will be empty, 20 | # and FastAPI will default to serving the API on http://localhost:8000. 21 | app = FastAPI(servers=[{"url": os.getenv("FASTAPI_SERVER_URL")}] if os.getenv("FASTAPI_SERVER_URL") else []) 22 | 23 | # Set up CORS middleware 24 | app.add_middleware( 25 | CORSMiddleware, 26 | allow_origins=["*"], # Allows all origins 27 | allow_credentials=True, 28 | allow_methods=["*"], # Allows all methods 29 | allow_headers=["*"], # Allows all headers 30 | ) 31 | 32 | # Redirects to the automatically generated FastAPI documentation page 33 | @app.get("/", include_in_schema=False) 34 | async def redirect_to_docs(): 35 | return RedirectResponse(url='/docs') 36 | 37 | # Retrieve tokens from environment variables 38 | GITHUB_API_TOKEN = os.getenv("GITHUB_TOKEN") 39 | API_BEARER_TOKEN = os.getenv("API_BEARER_TOKEN") 40 | 41 | # Security scheme for bearer with JWT 42 | security = HTTPBearer() 43 | 44 | # Uncomment the lines below and comment out the line above if you want to use OAuth2 with Authorization Code flow 45 | # You will also need to set up redirection endpoint and provide your client id, client secret, 46 | # authorization URL, and token URL for your OAuth flow with GitHub. 47 | 48 | # OAUTH2_SCHEME_NAME = 'OAUTH2_SCHEME_NAME' 49 | 50 | # oauth2_scheme = OAuth2AuthorizationCodeBearer( 51 | # authorizationUrl="https://github.com/login/oauth/authorize", 52 | # tokenUrl="https://github.com/login/oauth/access_token", 53 | # refreshUrl=None, 54 | # scheme_name=OAUTH2_SCHEME_NAME, 55 | # ) 56 | 57 | # To enable OAuth2, use OAUTH2_SCHEME_NAME instead of security when creating dependency in endpoint functions. 58 | # For example: 59 | # def verify_token(token: str = Depends(oauth2_scheme)): 60 | # # Your code to verify the token (e.g., call to your auth server) 61 | 62 | def verify_token(authorization: HTTPAuthorizationCredentials = Depends(security)): 63 | """ 64 | Verify the authorization token sent with the request. 65 | """ 66 | if authorization.credentials != API_BEARER_TOKEN: 67 | raise HTTPException(status_code=403, detail="Invalid or missing Bearer token") 68 | 69 | if not GITHUB_API_TOKEN: 70 | raise EnvironmentError("No GitHub API token provided in environment variables.") 71 | 72 | # Headers for GitHub API requests 73 | headers = { 74 | "Authorization": f"token {GITHUB_API_TOKEN}", 75 | "Accept": "application/vnd.github.v3+json" 76 | } 77 | 78 | GITHUB_SEARCH_API_URL = "https://api.github.com/search" 79 | async def perform_search(search_type: str, query: str, page: int = 1, per_page: int = 10): 80 | # Construct the search URL with query parameters for search type, query, pagination page, and results per page 81 | url = f"{GITHUB_SEARCH_API_URL}/{search_type}?q={query}&page={page}&per_page={per_page}" 82 | 83 | # Perform an asynchronous HTTP GET request using the constructed URL and custom headers 84 | async with httpx.AsyncClient() as client: 85 | response = await client.get(url, headers=headers) 86 | 87 | # If the response status code is not 200 (OK), raise an HTTPException with the response details 88 | if response.status_code != 200: 89 | raise HTTPException(status_code=response.status_code, detail=response.json()) 90 | 91 | # Return the JSON response content if the request was successful 92 | return response.json() 93 | 94 | class SearchRequest(BaseModel): 95 | # Textual search query or keywords 96 | query: str 97 | # Starting page number for search results pagination 98 | page: int = 1 99 | # Number of search results per page 100 | per_page: int = 2 101 | 102 | # Endpoint to search for code snippets on GitHub using a user-specified search query. 103 | # It requires the 'SearchRequest' object for query parameters and a valid bearer token for authorization. 104 | @app.post("/search/code/") 105 | async def search_code(request: SearchRequest, token: HTTPAuthorizationCredentials = Depends(verify_token)): 106 | return await perform_search("code", request.query, request.page, request.per_page) 107 | 108 | # Endpoint to search for commits on GitHub using a user-specified search query or the default query "fix bug repo:openai/gpt-3". 109 | # It requires the 'SearchRequest' object for query parameters and a valid bearer token for authorization. 110 | @app.post("/search/commits/") 111 | async def search_commits(request: SearchRequest = SearchRequest(query="fix bug repo:openai/gpt-3"), token: HTTPAuthorizationCredentials = Depends(verify_token)): 112 | return await perform_search("commits", request.query) 113 | 114 | def generate_paginated_response(results, char_limit: int = 500): 115 | """ 116 | Paginate results beyond a certain character count. 117 | """ 118 | # Convert the results to string, then to a list of characters for pagination 119 | results_str = json.dumps(results) 120 | paginated_result = [results_str[i:i+char_limit] for i in range(0, len(results_str), char_limit)] 121 | 122 | # Generator function to yield paginated results 123 | def paginated_json_generator(): 124 | for page in paginated_result: 125 | yield page 126 | 127 | return StreamingResponse(paginated_json_generator(), media_type="application/json") 128 | 129 | @app.post("/search/issues/") 130 | async def search_issues(request: SearchRequest = SearchRequest(query="bug label:bug"), token: HTTPAuthorizationCredentials = Depends(verify_token)): 131 | """ 132 | Search issues on GitHub with automatic pagination beyond a certain character count. 133 | Default query: "bug label:bug" 134 | """ 135 | results = await perform_search("issues", request.query, request.page, request.per_page) 136 | return generate_paginated_response(results) 137 | @app.post("/search/labels/") 138 | async def search_labels(request: SearchRequest = SearchRequest(query="bug repo:openai/gpt-3"), token: HTTPAuthorizationCredentials = Depends(verify_token)): 139 | """ 140 | Search labels on GitHub. 141 | Default query: "bug repo:openai/gpt-3" 142 | """ 143 | return await perform_search("labels", request.query) 144 | 145 | @app.post("/search/repositories/") 146 | async def search_repositories(request: SearchRequest = SearchRequest(query="FastAPI stars:>1000"), token: HTTPAuthorizationCredentials = Depends(verify_token)): 147 | """ 148 | Search repositories on GitHub. 149 | Default query: "FastAPI stars:>1000" 150 | """ 151 | return await perform_search("repositories", request.query) 152 | 153 | @app.post("/search/topics/") 154 | async def search_topics(request: SearchRequest = SearchRequest(query="machine-learning"), token: HTTPAuthorizationCredentials = Depends(verify_token)): 155 | """ 156 | Search topics on GitHub. 157 | Default query: "machine-learning" 158 | """ 159 | return await perform_search("topics", request.query) 160 | 161 | @app.post("/search/users/") 162 | async def search_users(request: SearchRequest = SearchRequest(query="ruvnet"), token: HTTPAuthorizationCredentials = Depends(verify_token)): 163 | """ 164 | Search users on GitHub. 165 | Default query: "ruvnet" 166 | """ 167 | return await perform_search("users", request.query) 168 | 169 | # If this script is run as the main script, it starts the uvicorn server with the specified host and port. 170 | if __name__ == "__main__": 171 | import uvicorn 172 | uvicorn.run(app, host="0.0.0.0", port=8000) 173 | -------------------------------------------------------------------------------- /openapi.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.1.0", 3 | "info": { 4 | "title": "GitHub Explorer API", 5 | "version": "0.1.0" 6 | }, 7 | "servers": [ 8 | { 9 | "url": "{replace-with-your-api}" 10 | } 11 | ], 12 | "paths": { 13 | "/search/code/": { 14 | "post": { 15 | "summary": "Search Code", 16 | "description": "Search code on GitHub.\nDefault query: {\"query\": \"FastAPI filename:main.py\"}", 17 | "operationId": "search_code_post", 18 | "requestBody": { 19 | "content": { 20 | "application/json": { 21 | "schema": { 22 | "$ref": "#/components/schemas/SearchRequest" 23 | } 24 | } 25 | }, 26 | "required": true 27 | }, 28 | "responses": { 29 | "200": { 30 | "description": "Successful Response", 31 | "content": { "application/json": { "schema": {} } } 32 | }, 33 | "422": { 34 | "description": "Validation Error", 35 | "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } 36 | } 37 | } 38 | } 39 | }, 40 | "/search/commits/": { 41 | "post": { 42 | "summary": "Search Commits", 43 | "description": "Search commits on GitHub.\nDefault query: {\"query\": \"fix bug repo:openai/gpt-3\"}", 44 | "operationId": "search_commits_post", 45 | "requestBody": { 46 | "content": { 47 | "application/json": { 48 | "schema": { 49 | "$ref": "#/components/schemas/SearchRequest" 50 | } 51 | } 52 | }, 53 | "required": true 54 | }, 55 | "responses": { 56 | "200": { 57 | "description": "Successful Response", 58 | "content": { "application/json": { "schema": {} } } 59 | }, 60 | "422": { 61 | "description": "Validation Error", 62 | "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } 63 | } 64 | } 65 | } 66 | }, 67 | "/search/issues/": { 68 | "post": { 69 | "summary": "Search Issues", 70 | "description": "Search issues on GitHub.\nDefault query: {\"query\": \"bug label:bug\"}", 71 | "operationId": "search_issues_post", 72 | "requestBody": { 73 | "content": { 74 | "application/json": { 75 | "schema": { 76 | "$ref": "#/components/schemas/SearchRequest" 77 | } 78 | } 79 | }, 80 | "required": true 81 | }, 82 | "responses": { 83 | "200": { 84 | "description": "Successful Response", 85 | "content": { "application/json": { "schema": {} } } 86 | }, 87 | "422": { 88 | "description": "Validation Error", 89 | "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } 90 | } 91 | } 92 | } 93 | }, 94 | "/search/labels/": { 95 | "post": { 96 | "summary": "Search Labels", 97 | "description": "Search labels on GitHub.\nDefault query: {\"query\": \"bug repo:openai/gpt-3\"}", 98 | "operationId": "search_labels_post", 99 | "requestBody": { 100 | "content": { 101 | "application/json": { 102 | "schema": { 103 | "$ref": "#/components/schemas/SearchRequest" 104 | } 105 | } 106 | }, 107 | "required": true 108 | }, 109 | "responses": { 110 | "200": { 111 | "description": "Successful Response", 112 | "content": { "application/json": { "schema": {} } } 113 | }, 114 | "422": { 115 | "description": "Validation Error", 116 | "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } 117 | } 118 | } 119 | } 120 | }, 121 | "/search/repositories/": { 122 | "post": { 123 | "summary": "Search Repositories", 124 | "description": "Search repositories on GitHub.\nDefault query: {\"query\": \"FastAPI stars:>1000\"}", 125 | "operationId": "search_repositories_post", 126 | "requestBody": { 127 | "content": { 128 | "application/json": { 129 | "schema": { 130 | "$ref": "#/components/schemas/SearchRequest" 131 | } 132 | } 133 | }, 134 | "required": true 135 | }, 136 | "responses": { 137 | "200": { 138 | "description": "Successful Response", 139 | "content": { "application/json": { "schema": {} } } 140 | }, 141 | "422": { 142 | "description": "Validation Error", 143 | "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } 144 | } 145 | } 146 | } 147 | }, 148 | "/search/topics/": { 149 | "post": { 150 | "summary": "Search Topics", 151 | "description": "Search topics on GitHub.\nDefault query: {\"query\": \"machine-learning\"}", 152 | "operationId": "search_topics_post", 153 | "requestBody": { 154 | "content": { 155 | "application/json": { 156 | "schema": { 157 | "$ref": "#/components/schemas/SearchRequest" 158 | } 159 | } 160 | }, 161 | "required": true 162 | }, 163 | "responses": { 164 | "200": { 165 | "description": "Successful Response", 166 | "content": { "application/json": { "schema": {} } } 167 | }, 168 | "422": { 169 | "description": "Validation Error", 170 | "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } 171 | } 172 | } 173 | } 174 | }, 175 | "/search/users/": { 176 | "post": { 177 | "summary": "Search Users", 178 | "description": "Search users on GitHub.\nDefault query: {\"query\": \"ruvnet\"}", 179 | "operationId": "search_users_post", 180 | "requestBody": { 181 | "content": { 182 | "application/json": { 183 | "schema": { 184 | "$ref": "#/components/schemas/SearchRequest" 185 | } 186 | } 187 | }, 188 | "required": true 189 | }, 190 | "responses": { 191 | "200": { 192 | "description": "Successful Response", 193 | "content": { "application/json": { "schema": {} } } 194 | }, 195 | "422": { 196 | "description": "Validation Error", 197 | "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } 198 | } 199 | } 200 | } 201 | }, 202 | "/repository/code/": { 203 | "post": { 204 | "summary": "Get Repo Code", 205 | "operationId": "get_repo_code_post", 206 | "requestBody": { 207 | "content": { 208 | "application/json": { 209 | "schema": { 210 | "$ref": "#/components/schemas/RepoRequest" 211 | } 212 | } 213 | }, 214 | "required": true 215 | }, 216 | "responses": { 217 | "200": { 218 | "description": "Successful Response", 219 | "content": { "application/json": { "schema": {} } } 220 | }, 221 | "422": { 222 | "description": "Validation Error", 223 | "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } 224 | } 225 | } 226 | } 227 | } 228 | }, 229 | "components": { 230 | "schemas": { 231 | "SearchRequest": { 232 | "type": "object", 233 | "properties": { 234 | "query": { 235 | "type": "string", 236 | "example": "FastAPI filename:main.py" 237 | } 238 | }, 239 | "required": ["query"] 240 | }, 241 | "RepoRequest": { 242 | "type": "object", 243 | "properties": { 244 | "owner": { 245 | "type": "string", 246 | "example": "octocat" 247 | }, 248 | "repo": { 249 | "type": "string", 250 | "example": "Hello-World" 251 | } 252 | }, 253 | "required": ["owner", "repo"] 254 | }, 255 | "HTTPValidationError": { 256 | "type": "object", 257 | "properties": { 258 | "detail": { 259 | "type": "array", 260 | "items": { 261 | "$ref": "#/components/schemas/ValidationError" 262 | } 263 | } 264 | } 265 | }, 266 | "ValidationError": { 267 | "type": "object", 268 | "properties": { 269 | "loc": { 270 | "type": "array", 271 | "items": { 272 | "type": "string" 273 | } 274 | }, 275 | "msg": { 276 | "type": "string" 277 | }, 278 | "type": { 279 | "type": "string" 280 | } 281 | }, 282 | "required": ["loc", "msg", "type"] 283 | } 284 | } 285 | } 286 | } 287 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | fastapi==0.75.1 2 | uvicorn==0.17.6 3 | httpx==0.21.3 4 | python-multipart==0.0.5 5 | pydantic==1.8.2 6 | --------------------------------------------------------------------------------