File size: 901 Bytes
d8083af
 
 
 
6f0f963
d8083af
 
36fde6a
 
 
d8083af
 
 
 
 
 
36fde6a
3305431
d8083af
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
import openai
import json, csv

def routing_agent(query, chat_history):
    
    system_prompt = """
    You are an AI assistant, solely made to output a "1" or a "0". 
        You will output a "1" when, based on the most recent query and the recent chat history, you determine that the user is looking for additional classes not already included in the chat history.
        In the scenario where it seems the user is asking a question not related to the classes they could take, please output a "0".
    """

    response = openai.ChatCompletion.create(
        model="gpt-3.5-turbo",
        messages=[
            {"role": "system", "content": system_prompt},
            {"role": "user", "content": "Query:" + query},
            {"role": "assistant", "content": "Here is the chat history: " + chat_history}
        ]
    )

    return response["choices"][0]["message"]["content"]