#How to get a context (from data) based response

1 messages · Page 1 of 1 (latest)

timber badge
#

I'm trying to generate a response based on the data (a list with information on movies), how do I set the parameters such that I get a response which suggests a movie from the list I provided? Kinda trying to imitate RAG


def generate_response(query, movies):
    movie_list = "\n".join([f"{movie['title']}: {movie['description']}" for movie in movies if movie])
    prompt = f"User query: {query}\n\nMovies:\n{movie_list}\n\nRespond to the user query based on the movies listed above."

    response = client.chat.completions.create(
        model="gpt-3.5-turbo",
        stream=False,
        messages = [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": prompt},
        ],        
    )```

This is how I have defined the function, but I still get recommendations outside my data list