Skip to content
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

Added api call example #1587

Merged
merged 5 commits into from
Feb 12, 2025
Merged

Added api call example #1587

merged 5 commits into from
Feb 12, 2025

Conversation

yoavkatz
Copy link
Member

@yoavkatz yoavkatz commented Feb 9, 2025

No description provided.

Signed-off-by: Yoav Katz <[email protected]>
Comment on lines 266 to 285
print("Example prompt:")

print(json.dumps(results.instance_scores[0]["source"], indent=4))

print("Instance Results:")
df = results.instance_scores.to_df(
columns=[
"user_request",
"reference_query",
"prediction",
"processed_references",
"processed_prediction",
"score",
]
)
for index, row in df.iterrows():
print(f"Row {index}:")
for col_name, value in row.items():
print(f"{col_name}: {value}")
print("-" * 20)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we simplify that part in any way?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened an issue about this (#1588) The current 'results.instance_scores.summary' is not usable because it prints too long lines. I think we want to change it to print in a different way, and then we could use it here.

Copy link
Member

@elronbandel elronbandel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice example that share a lot of similarity with Text to SQL.
In both cases there is (1) user query (2) api/database and that target is to translate the user query to the api/database language.
I think its worth looking at how the SQL was implemented: specifically:

(1) The database is defined by its unique identifier (in this case could be OpenAPI(url="https://petstore.swagger.io/v2/pets")
(2) the representation of the database to the model is determined by a dedicated type serializer (in this case it could be OpenAPISpecificationSerializer(format="json") # can be yaml)
(3) Metrics could also use deterministic verification like with. https://pypi.org/project/openapi-spec-validator/ that can use the OpenAPI directly to verify schema/syntax/execution

@yoavkatz
Copy link
Member Author

yoavkatz commented Feb 9, 2025

This is a nice example that share a lot of similarity with Text to SQL. In both cases there is (1) user query (2) api/database and that target is to translate the user query to the api/database language. I think its worth looking at how the SQL was implemented: specifically:

(1) The database is defined by its unique identifier (in this case could be OpenAPI(url="https://petstore.swagger.io/v2/pets") (2) the representation of the database to the model is determined by a dedicated type serializer (in this case it could be OpenAPISpecificationSerializer(format="json") # can be yaml) (3) Metrics could also use deterministic verification like with. https://pypi.org/project/openapi-spec-validator/ that can use the OpenAPI directly to verify schema/syntax/execution

  1. I wanted to keep this simple for now (I did it to show one of the users, who actually had their internal API spec representation). That's why I did not put the task in the catalog yet - and left it as a standalone example file - I felt it's not mature enough to be general.
    2.I agree a more elaborate approach could be done with a serializer for OpenAPI specs.
  2. I think the above library validates the scheme (which I assume to be correct), while we want to validate the CURL commands generated based on the schema.

@yoavkatz
Copy link
Member Author

This is a nice example that share a lot of similarity with Text to SQL. In both cases there is (1) user query (2) api/database and that target is to translate the user query to the api/database language. I think its worth looking at how the SQL was implemented: specifically:
(1) The database is defined by its unique identifier (in this case could be OpenAPI(url="https://petstore.swagger.io/v2/pets") (2) the representation of the database to the model is determined by a dedicated type serializer (in this case it could be OpenAPISpecificationSerializer(format="json") # can be yaml) (3) Metrics could also use deterministic verification like with. https://pypi.org/project/openapi-spec-validator/ that can use the OpenAPI directly to verify schema/syntax/execution

  1. I wanted to keep this simple for now (I did it to show one of the users, who actually had their internal API spec representation). That's why I did not put the task in the catalog yet - and left it as a standalone example file - I felt it's not mature enough to be general.
    2.I agree a more elaborate approach could be done with a serializer for OpenAPI specs.
  2. I think the above library validates the scheme (which I assume to be correct), while we want to validate the CURL commands generated based on the schema.

Given the above - you think we can merge?

@elronbandel elronbandel enabled auto-merge (squash) February 12, 2025 08:51
@elronbandel elronbandel merged commit 6c82ceb into main Feb 12, 2025
17 checks passed
@elronbandel elronbandel deleted the api_call_evaluation branch February 12, 2025 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants