bhulston commited on
Commit
a0afdfa
1 Parent(s): ed2be0a

Create keyword.py

Browse files
Files changed (1) hide show
  1. keyword.py +20 -0
keyword.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+
3
+ def keyword_agent(query, key):
4
+
5
+ system_prompt = """
6
+ You are an AI assistant that looks at a given query about a school class, and comes up with a list of 3 keywords related to the query.
7
+ Two keywords will be used that are similar in semantics to the given query but not already used in query.
8
+ The third keyword should focus on an aspect related to the query that is less obvious, but might be helpful when finding similar data entries.
9
+ If the query does not seem to relate to a school class, please output nothing or just spaces " ".
10
+ """
11
+
12
+ response = openai.ChatCompletion.create(
13
+ model="gpt-3.5-turbo",
14
+ messages=[
15
+ {"role": "system", "content": system_prompt},
16
+ {"role": "user", "content": query}
17
+ ]
18
+ )
19
+
20
+ return response["choices"][0]["message"]["content"]