Skip to content

Commit

Permalink
improved reliability for informal logic. Gens working, tho some test …
Browse files Browse the repository at this point in the history
…data failures
  • Loading branch information
valhuber committed Nov 1, 2024
1 parent 1000b9b commit 787b9e3
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 10 deletions.
4 changes: 2 additions & 2 deletions api_logic_server_cli/api_logic_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
Called from api_logic_server_cli.py, by instantiating the ProjectRun object.
'''

__version__ = "12.00.16"
__version__ = "12.00.17"
recent_changes = \
f'\n\nRecent Changes:\n' +\
"\t10/31/2024 - 12.00.16: genai: fix format bug, iteration prompt update, multi base, rule objs/doc/inf \n"\
"\t10/31/2024 - 12.00.17: genai: fix format bug, iteration prompt update, multi base, rule objs/doc/informal \n"\
"\t10/27/2024 - 12.00.11: genai: major revision for parsed ChatGPT responses \n"\
"\t10/27/2024 - 12.00.09: genai: incr logic completion, interations now have db hints, diagnostics in dirs \n"\
"\t10/25/2024 - 12.00.05: Fix ChatGPT table gen, align genai_demo add-cust \n"\
Expand Down
4 changes: 3 additions & 1 deletion api_logic_server_cli/genai.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ def __init__(self, project: Project):

if self.project.genai_repaired_response == '': # normal path - get response from ChatGPT
api_version = f'{self.project.genai_version}' # eg, "gpt-4o"
api_version = "gpt-4o-2024-08-06"
start_time = time.time()
client = OpenAI(api_key=os.getenv("APILOGICSERVER_CHATGPT_APIKEY"))
completion = client.beta.chat.completions.parse(
messages=self.messages, response_format=WGResult,
model=api_version, temperature=0.0
# temperature=0.0,
model=api_version
)
log.debug(f'ChatGPT ({str(int(time.time() - start_time))} secs) - response at: system/genai/temp/chatgpt_original.response')

Expand Down
38 changes: 38 additions & 0 deletions api_logic_server_cli/prototypes/manager/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,44 @@
"console": "internalConsole",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": " - GenAI informal logic - genai_demo",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/venv/lib/python3.12/site-packages/api_logic_server_cli/cli.py",
"redirectOutput": true,
"cwd": "${workspaceFolder}",
"env": {
"PYTHONPATH": "",
"SECURITY_ENABLED": "False",
"PYTHONHASHSEED": "0",
"APILOGICSERVER_DEBUG": "False",
"OPT_LOCKING": "optional"},
"justMyCode": false,
"args": [ "genai", "--retries=-1",
"--using=${workspaceFolder}/system/genai/examples/genai_demo/genai_demo_informal.prompt"],
"console": "internalConsole",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": " - GenAI informal logic - emp_depts",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/venv/lib/python3.12/site-packages/api_logic_server_cli/cli.py",
"redirectOutput": true,
"cwd": "${workspaceFolder}",
"env": {
"PYTHONPATH": "",
"SECURITY_ENABLED": "False",
"PYTHONHASHSEED": "0",
"APILOGICSERVER_DEBUG": "False",
"OPT_LOCKING": "optional"},
"justMyCode": false,
"args": [ "genai", "--retries=-1",
"--using=${workspaceFolder}/system/genai/examples/emp_depts/emp_dept.prompt"],
"console": "internalConsole",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": " - retry repaired-response",
"type": "debugpy",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -194,5 +194,15 @@ def declare_logic(): # created by Web/GenAI for ApiLogicServer, LogicBank
as_condition=lambda row: row.balance <= row.credit_limit,
error_msg="Customer balance ({row.balance}) exceeds credit limit ({row.credit_limit})")

Do not use the python sum or count functions for intermediate sum/count values.
Intermediate sum/count values require a new column, with a LogicBank sum/count rule.
Intermediate sum/count values require a new column, with a LogicBank sum/count rule. For example:

Prompt:
The sum of the child value cannot exceed the parent limit

Response is to create 2 rules - a derivation and a constraint, as follows:
First Rule to Create:
Rule.sum(derive=Parent.value_total, as_sum_of=Child.value)
And, be sure to create the second Rule:
Rule.constraint(validate=Parent,
as_condition=lambda row: row.value_total <= row.limit,
error_msg="Parent value total ({row.value_total}) exceeds limit ({row.limit})")

0 comments on commit 787b9e3

Please sign in to comment.