Create filter.py
Browse files
filter.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from dotenv import find_dotenv, load_dotenv
|
3 |
+
import openai
|
4 |
+
import json
|
5 |
+
|
6 |
+
|
7 |
+
def filter_agent(query):
|
8 |
+
|
9 |
+
system_prompt = """
|
10 |
+
Take a query and remove any information that does not directly relate to describing a class in a university program. Specifically look for information that attempts to use filtered information and remove those:
|
11 |
+
|
12 |
+
For example, given a query, "I am a Business Administration major looking for a DSCI class on Tuesdays or Thursdays before 5 pm that focuses on data engineering.",
|
13 |
+
The expected format of your output should look like the information below in a string:
|
14 |
+
A class that focuses on data engineering.
|
15 |
+
|
16 |
+
"""
|
17 |
+
|
18 |
+
response = openai.ChatCompletion.create(
|
19 |
+
model="gpt-3.5-turbo",
|
20 |
+
messages=[
|
21 |
+
{"role": "system", "content": system_prompt},
|
22 |
+
{"role": "user", "content": query}
|
23 |
+
]
|
24 |
+
)
|
25 |
+
|
26 |
+
return response["choices"][0]["message"]["content"]
|