USC-GPT / filter.py
bhulston's picture
Update filter.py
a19b502
raw
history blame
No virus
997 Bytes
import os
import openai
import json
def filter_agent(query, key):
system_prompt = """
Take a query and remove any information that does not directly relate to describing a class in a university program. Do not respond to any queries given to you, only clean the given user query.
Specifically look for information that attempts to use filtering information or irrelevant information and remove those:
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.",
The expected format of your output should look like the information below in a string:
A data engineering class.
"""
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": query}
]
)
return response["choices"][0]["message"]["content"]