From 461e5e06e9c57919ab64f9b691e37b9078948c75 Mon Sep 17 00:00:00 2001 From: DhananjayMukhedkar Date: Fri, 14 Jun 2024 16:44:10 +0200 Subject: [PATCH 1/3] fix for single day --- .../ch03/functions/air_quality_data_retrieval.py | 4 ++-- notebooks/ch03/functions/context_engineering.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/notebooks/ch03/functions/air_quality_data_retrieval.py b/notebooks/ch03/functions/air_quality_data_retrieval.py index 1abcef18..90911628 100644 --- a/notebooks/ch03/functions/air_quality_data_retrieval.py +++ b/notebooks/ch03/functions/air_quality_data_retrieval.py @@ -21,8 +21,8 @@ def get_historical_data_for_date(date: str, feature_view, weather_fg, model) -> date_datetime = datetime.datetime.strptime(date, "%Y-%m-%d").date() features_df, labels_df = feature_view.training_data( - start_time=date_datetime - datetime.timedelta(days=1), - end_time=date_datetime, + start_time=date_datetime, + end_time=date_datetime + datetime.timedelta(days=1), # event_time=True, statistics_config=False ) diff --git a/notebooks/ch03/functions/context_engineering.py b/notebooks/ch03/functions/context_engineering.py index 274af337..b32ed32d 100644 --- a/notebooks/ch03/functions/context_engineering.py +++ b/notebooks/ch03/functions/context_engineering.py @@ -65,9 +65,12 @@ def get_function_calling_prompt(user_query): ###INSTRUCTIONS: - You need to choose one function to use and retrieve paramenters for this function from the user input. -- If the user query contains 'will', and specifies a single day or date, use get_future_data_for_date function -- If the user query contains 'will', and specifies a range of days or dates, use or get_future_data_in_date_range function. -- If the user query is for future data, but only includes a single day or date, use the get_future_data_for_date function. +- If the user query contains 'will', and specifies a single day or date, use get_future_data_in_date_range function +- If the user query contains 'will', and specifies a range of days or dates, use get_future_data_in_date_range function. +- If the user query is for future data, but only includes a single day or date, use the get_future_data_in_date_range function, +- If the user query contains 'today' or 'yesterday', use get_historical_data_for_date function. +- If the user query contains 'tomorrow', use get_future_data_in_date_range function. +- If the user query is for historical data, and specifies a range of days or dates, use use get_historical_data_for_date function. - If the user says a day of the week, assume the date of that day is when that day next arrives. - Do not include feature_view and model parameters. - Provide dates STRICTLY in the YYYY-MM-DD format. @@ -148,7 +151,7 @@ def function_calling_with_openai(user_query: str, client) -> str: instructions = get_function_calling_prompt(user_query).split('<|im_start|>user')[0] completion = client.chat.completions.create( - model="gpt-3.5-turbo", + model="gpt-4-0125-preview", messages=[ {"role": "system", "content": instructions}, {"role": "user", "content": user_query}, @@ -227,11 +230,13 @@ def get_context_data(user_query: str, feature_view, weather_fg, model_air_qualit # Extract function calls from the completion functions = extract_function_calls(completion) + print(f"found functions:{functions}") # If function calls were found if functions: # Invoke the function with provided arguments data = invoke_function(functions[0], feature_view, weather_fg, model_air_quality) + print(f"data from invoke_func: {data}") # Return formatted data as string if isinstance(data, pd.DataFrame): From 8925a6be953c9845420248311f27c70b942d98bd Mon Sep 17 00:00:00 2001 From: DhananjayMukhedkar Date: Fri, 14 Jun 2024 16:45:59 +0200 Subject: [PATCH 2/3] revert gpt model --- notebooks/ch03/functions/context_engineering.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebooks/ch03/functions/context_engineering.py b/notebooks/ch03/functions/context_engineering.py index b32ed32d..60da437b 100644 --- a/notebooks/ch03/functions/context_engineering.py +++ b/notebooks/ch03/functions/context_engineering.py @@ -151,7 +151,7 @@ def function_calling_with_openai(user_query: str, client) -> str: instructions = get_function_calling_prompt(user_query).split('<|im_start|>user')[0] completion = client.chat.completions.create( - model="gpt-4-0125-preview", + model="gpt-3.5-turbo", messages=[ {"role": "system", "content": instructions}, {"role": "user", "content": user_query}, From 83fa43526ede43416d86758385ce90267cbdc43f Mon Sep 17 00:00:00 2001 From: DhananjayMukhedkar Date: Fri, 14 Jun 2024 16:47:56 +0200 Subject: [PATCH 3/3] undo prints --- notebooks/ch03/functions/context_engineering.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/notebooks/ch03/functions/context_engineering.py b/notebooks/ch03/functions/context_engineering.py index 60da437b..19c1d9b8 100644 --- a/notebooks/ch03/functions/context_engineering.py +++ b/notebooks/ch03/functions/context_engineering.py @@ -230,13 +230,11 @@ def get_context_data(user_query: str, feature_view, weather_fg, model_air_qualit # Extract function calls from the completion functions = extract_function_calls(completion) - print(f"found functions:{functions}") # If function calls were found if functions: # Invoke the function with provided arguments data = invoke_function(functions[0], feature_view, weather_fg, model_air_quality) - print(f"data from invoke_func: {data}") # Return formatted data as string if isinstance(data, pd.DataFrame):