movie-chat / tools.py
leek2's picture
first commit
3009d0e
raw
history blame
No virus
697 Bytes
"""
External functions that the chatbot can use at its discretion.
"""
import os
import openai
openai.api_key = os.environ['OPENAI_API_KEY']
def get_movie_recs(context, K=5):
system_prompt=f"""
Pretend you are a movie recommendation system. I will give you a conversation between a user
and you (a recommender system). Based on the conversation, reply to me with {K} recommendations
without extra sentences.
"""
user_query=f"Here is the conversation:\n{context}"
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[{'role': 'system', 'content': system_prompt}, {'role': 'user', 'content': user_query}],
)
return response.choices[0].message.content