-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatements.py
More file actions
37 lines (23 loc) · 1.06 KB
/
statements.py
File metadata and controls
37 lines (23 loc) · 1.06 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
35
36
from openai_lib.api import Gpt4oMiniInterface
from pydantic import BaseModel
import shelve
class StatemtExtractor(BaseModel):
statements: list[str]
api = Gpt4oMiniInterface()
instructions = """
You are a math professor teaching a class about logic, specifically about statements.
To ilustrate the subject, you ask the students to give an example of a sentence, containg atomic propositions.
You will, then, write the atomic propositions that can be stracted from the example.
A atomic propositions is a declaration of a sigle fact.
A sentence can contain multiple atomic propositions.
The example given by the student will be inputed, output the atomic propositions that can be extracted from the example.
"""
statement_resolver = api.of_format(StatemtExtractor, instructions)
def main():
with shelve.open('extracted') as db:
affirmative = db["affirmative"]
extracted = statement_resolver(affirmative)
with shelve.open('extracted') as db:
db["statements"] = extracted.statements
for s in extracted.statements:
print(s)