-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AGPT-432] Provide Request & Response checking on Function Generation #64
[AGPT-432] Provide Request & Response checking on Function Generation #64
Conversation
codex/__main__.py
Outdated
deployment_id = deploy_data["deployment"]["id"] | ||
deployment_file_name = deploy_data["deployment"]["file_name"] | ||
deployment_id = deploy_data["id"] | ||
deployment_file_name = deploy_data["file_name"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API is changed, this to make the benchmark work again.
@@ -44,6 +44,10 @@ class config: | |||
arbitrary_types_allowed = True | |||
|
|||
|
|||
# This can be used for synchronous testing without making an actual API call | |||
MOCK_RESPONSE = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm adding this for testing without LLM call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in discord, I think its a clear design to mock the openai class
data=model, | ||
include={"FunctionArgs": True, "FunctionReturn": True}, | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we create the Function.Definition before recursing.
This simplifies a lot of stuff:
- Develop AIBlock only do update,
create_item
andupdate_item
can be merged. - Created the objectfields for args and return types before generation, so we can validate inside the AIblock
function_name (str): The name of the function to create. | ||
function_id (str): The id of the function to create. If not provided, a new root-function will be created. | ||
function_template (str): The docstring/template of the function to create. | ||
function (Function): The function to develop. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's easier to group this to a single object
self.imports = [] | ||
self.pydantic_classes = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are tracking all classes, there is is_pydantic
in self.objects
isinstance(node, ast.AnnAssign) or | ||
isinstance(node, ast.AugAssign) | ||
) and node.col_offset == 0: | ||
self.globals.append(ast.unparse(node)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm tracking globals for now so that at least the generated code is working.
@@ -226,94 +250,6 @@ def validate( | |||
async def create_item( | |||
self, ids: Identifiers, validated_response: ValidatedResponse | |||
) -> Function: | |||
"""This is just a temporary that doesnt have a database model""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging this with update_item
function_code: str | ||
function_template: str = None | ||
|
||
def __generate_function_template(f) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be used only for the first function, we let llm output template for the rest to be used.
@@ -1,7 +1,7 @@ | |||
import ast | |||
|
|||
import pytest | |||
from numpy import VisibleDeprecationWarning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Boilerplate changes to make the test work
…eration-is-applying-strict-check-on-args-and' into zamilmajdy/agpt-432-function-generation-is-applying-strict-check-on-args-and
…tegrate-complex-types-into-all-compiling-step [AGPT-250] Add compiler support for complex types
description="Identifier for the user who is creating the invoice.", | ||
), | ||
Parameter( | ||
name="items", | ||
param_type="Array<InvoiceItemInput>", | ||
param_type="List[InvoiceItemInput]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list with no capital?
@@ -2229,22 +2229,22 @@ def invoice_payment_tracking() -> ApplicationRequirements: | |||
params=[ | |||
Parameter( | |||
name="invoices", | |||
param_type="Array<InvoiceSummary>", | |||
param_type="List[InvoiceSummary]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
@@ -95,6 +96,8 @@ async def fetch_deliverable(session, user_id, app_id): | |||
return deploy_data | |||
except Exception as e: | |||
click.echo(f"Error fetching deliverable: {e}") | |||
print("Problematic URL: ", url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use click.echo
or logger
instead of print here
@@ -44,6 +44,10 @@ class config: | |||
arbitrary_types_allowed = True | |||
|
|||
|
|||
# This can be used for synchronous testing without making an actual API call | |||
MOCK_RESPONSE = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in discord, I think its a clear design to mock the openai class
…unction-generation-is-applying-strict-check-on-args-and
Changes:
Testing:
./run benchmark
due to the latest API change.Code:
Out of scope: