Skip to content

Commit

Permalink
chore add datetime in prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
ArslanSaleem committed Jun 18, 2024
1 parent 8f0079a commit 3177843
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
from typing import Any

from pandasai.ee.agents.judge_agent.prompts.judge_agent_prompt import JudgeAgentPrompt
Expand Down Expand Up @@ -30,8 +31,14 @@ def execute(self, input_data: JudgePipelineInput, **kwargs) -> Any:
self.context = kwargs.get("context")
self.logger: Logger = kwargs.get("logger")

now = datetime.datetime.now()
human_readable_datetime = now.strftime("%A, %B %d, %Y %I:%M %p")

prompt = JudgeAgentPrompt(
query=input_data.query, code=input_data.code, context=self.context
query=input_data.query,
code=input_data.code,
context=self.context,
date=human_readable_datetime,
)
self.logger.log(f"Using prompt: {prompt}")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Today is {{date}}
### QUERY
{{query}}
### GENERATED CODE
Expand Down
10 changes: 9 additions & 1 deletion tests/unit_tests/ee/judge_agent/test_judge_prompt_gen.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from typing import Optional
from unittest.mock import patch

Expand Down Expand Up @@ -155,9 +156,16 @@ def test_validate_input_semantic_prompt(self, sample_df, context, logger):
input_data=input_data, context=context, logger=logger
)

match = re.search(
r"Today is ([A-Za-z]+, [A-Za-z]+ \d{1,2}, \d{4} \d{2}:\d{2} [APM]{2})",
response.output.to_string(),
)
datetime_str = match.group(1)

assert (
response.output.to_string()
== """### QUERY
== f"""Today is {datetime_str}
### QUERY
What is test?
### GENERATED CODE
print('Code Data')
Expand Down

0 comments on commit 3177843

Please sign in to comment.