-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaffirmative_interrogative.py
More file actions
37 lines (25 loc) · 1.04 KB
/
affirmative_interrogative.py
File metadata and controls
37 lines (25 loc) · 1.04 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
'''
Classify the statements as affirmative or interrogative (prolog propositions and questions).
'''
class AffimativeInterrogative(BaseModel):
affirmative: str
interrogative: str
api = Gpt4oMiniInterface()
instructions = """
You are a english teacher explaining to your students the difference between affirmative and interrogative sentences.
You will recieve a short paregraph that states facts and in then asks a question.
You must extract the affirmative and interrogative sentences from the paragraph without changing the original text.
"""
extractor_resolver = api.of_format(AffimativeInterrogative, instructions)
def main():
with shelve.open('extracted') as db:
prompt = db["prompt"]
extracted = extractor_resolver(prompt)
with shelve.open('extracted') as db:
db["affirmative"] = extracted.affirmative
db["interrogative"] = extracted.interrogative
print(extracted.affirmative)
print(extracted.interrogative)