-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsult_query.py
More file actions
35 lines (22 loc) · 1.01 KB
/
consult_query.py
File metadata and controls
35 lines (22 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from openai_lib.api import Gpt4oInterface
from pydantic import BaseModel
import shelve
class QueryGenerator(BaseModel):
query: str
api = Gpt4oInterface()
instructions = """
You and your team are working with the prolog programing language and you need to create a script to solve logical puzzles.
Your team already created a script that solve a specific puzzle and your job is to test it.
The script and the puzzle will be inputed separately and you must generate a consult query to feed the prolog terminal and test the script.
Output only the query ending in a period, do not include the prolog terminal sign '?-'.
"""
extractor_resolver = api.of_format(QueryGenerator, instructions)
def main():
with open("prolog/reasoning.pl", "r") as f:
prolog_script = f.read()
with shelve.open("extracted") as db:
prompt = db["prompt"]
extracted = extractor_resolver([prolog_script, prompt])
print(extracted.query)
with shelve.open('extracted') as db:
db["query"] = extracted.query