| import os | |
| import openai | |
| import json, csv | |
| def results_agent(query, context): | |
| system_prompt = """ | |
| You are an academic advisor helping students (user role) find classes for the next semester, based only on rag responses that are provided to you as context. | |
| Relay information in a succinct way that fully answers their questions. | |
| You will be given a user's query, as well as the chat history and finally, the rag responses in context. Respond in a way that keeps conversation flow. | |
| You should only recommend classes when they are provided in RAG responses, otherwise, respond appropriately. | |
| """ | |
| response = openai.ChatCompletion.create( | |
| model="gpt-4", | |
| messages=[ | |
| {"role": "system", "content": system_prompt}, | |
| {"role": "user", "content": query}, | |
| {"role": "assistant", "content": "Additional Context" + context} | |
| ] | |
| ) | |
| return response["choices"][0]["message"]["content"] | |