-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- setup poetry to use a local venv - add that venv to node-calls-python - simple dependency import test for sig-gen
- Loading branch information
1 parent
4272153
commit b180554
Showing
18 changed files
with
2,318 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# set up a .venv in this project | ||
virtualenvs.in-project = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
[tool.poetry] | ||
name = "code-generator" | ||
name = "apollo" | ||
version = "0.1.0" | ||
description = "A python monorepo for AI code generation" | ||
authors = ["Isma-Ilou Sadou <[email protected]>"] | ||
license = "LGPLv3" | ||
readme = "README.md" | ||
package-mode = false | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.9" | ||
requests = "^2.31.0" | ||
fastapi = "^0.110.2" | ||
|
||
|
||
[build-system] | ||
|
@@ -20,34 +22,34 @@ line-length = 120 | |
|
||
[tool.ruff] | ||
select = [ | ||
"E", # pycodestyle | ||
"F", # pyflakes | ||
"W", # pycodestyle (warnings) | ||
"I", # isort | ||
"N", # pep8-naming | ||
"UP", # pyupgrade | ||
"ANN", # flake8-annotations | ||
"B", # flake8-bugbear | ||
"A", # flake8-builtins | ||
"COM", # flake8-commas | ||
"C4", # flake8-comprehensions | ||
"DTZ", # flake8-datetimez | ||
"EXE", # flake8-executable | ||
"PIE", # flake8-pie | ||
"T20", # flake8-print | ||
"PT", # flake8-pytest | ||
"SIM", # flake8-simplify | ||
"ARG", # flake8-unused-arguments | ||
"PTH", # flake8--use-pathlib | ||
"ERA", # flake8-eradicate | ||
"RUF", # ruff specific rules | ||
"PL", # pylint | ||
"E", # pycodestyle | ||
"F", # pyflakes | ||
"W", # pycodestyle (warnings) | ||
"I", # isort | ||
"N", # pep8-naming | ||
"UP", # pyupgrade | ||
"ANN", # flake8-annotations | ||
"B", # flake8-bugbear | ||
"A", # flake8-builtins | ||
"COM", # flake8-commas | ||
"C4", # flake8-comprehensions | ||
"DTZ", # flake8-datetimez | ||
"EXE", # flake8-executable | ||
"PIE", # flake8-pie | ||
"T20", # flake8-print | ||
"PT", # flake8-pytest | ||
"SIM", # flake8-simplify | ||
"ARG", # flake8-unused-arguments | ||
"PTH", # flake8--use-pathlib | ||
"ERA", # flake8-eradicate | ||
"RUF", # ruff specific rules | ||
"PL", # pylint | ||
] | ||
ignore = [ | ||
"ANN101", # Missing type annotation for self in method | ||
"ANN204", # Missing type annotation for special method | ||
"ANN003", # Missing type annotation for `**kwargs` | ||
"UP007", # Use `X | Y` for type annotations instead of Union | ||
"UP007", # Use `X | Y` for type annotations instead of Union | ||
"E501", | ||
] | ||
line-length = 120 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
from log import log | ||
|
||
# Simple python service to echo requests back to the caller | ||
# Used in test | ||
def main(x): | ||
print('Echoing request') | ||
log() | ||
return x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def log(): | ||
print('Echoing request') |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# API Constants | ||
HOST = "0.0.0.0" | ||
PORT = 8001 | ||
|
||
# Inference Endpoints | ||
# CODET5_ENDPOINT = "http://localhost:8002/codet5/generate_code/" | ||
|
||
# codes | ||
SUCCESS_CODE: int = 200 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import logging | ||
from typing import Union | ||
from fastapi import HTTPException | ||
|
||
import requests | ||
from pydantic import BaseModel | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
|
||
# TODO - remove all the HTTP stuff from this | ||
class SignatureGenerator: | ||
def __init__(self, endpoint_url: str): | ||
self.endpoint_url = endpoint_url | ||
self.logger = logging.getLogger(__name__) | ||
|
||
def generate(self, prompt: str) -> str: | ||
try: | ||
headers = {"Content-Type": "application/json"} | ||
data = {"prompt": prompt} | ||
|
||
response = requests.post(self.endpoint_url, headers=headers, json=data) | ||
response.raise_for_status() | ||
return response.json().get("generated_code") | ||
except requests.exceptions.HTTPError as e: | ||
error_message = f"HTTP error occurred: {e.response.status_code}, {e.response.text}, {self.endpoint_url}" | ||
self.logger.error(error_message) | ||
raise HTTPException( | ||
status_code=e.response.status_code, detail=error_message | ||
) from e | ||
except Exception as e: | ||
error_message = f"An unexpected error occurred in code gen: {e}" | ||
self.logger.error(error_message) | ||
raise HTTPException(status_code=500, detail=error_message) | ||
|
||
|
||
class SignatureInput(BaseModel): | ||
open_api_spec: Union[str, dict] | ||
instruction: str | ||
model: str = "codet5" |
Oops, something went wrong.