Created
November 7, 2023 02:35
-
-
Save Kurry/c5cadabab5626fc35411a8715e3deebc to your computer and use it in GitHub Desktop.
Prompt As A Service for BQL Query Syntax
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
import requests | |
import bql | |
def get_bql_query_from_service(user_question): | |
url = "https://api.promptperfect.jina.ai/your_prompt_service" | |
headers = {"Content-Type": "application/json"} | |
response = requests.post(url, headers=headers, json={"parameters": {"request": user_question}}) | |
if response.status_code == 200: | |
return response.json()['data'] | |
else: | |
print(response.text) | |
return None | |
bq = bql.Service() | |
user_question = "Calculate the 30-day moving average closing price for Apple over the last 5 years." | |
# Define the BQL query | |
request = get_bql_query_from_service(user_question) | |
if request is not None: | |
# Execute the BQL query | |
response = bq.execute(request) | |
# Convert the response to a pandas DataFrame | |
df = bql.combined_df(response) | |
# Print the DataFrame | |
print(df) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment