USC-GPT / router.py
bhulston's picture
Update router.py
3305431
raw
history blame
1.03 kB
import os
import openai
import json, csv
def routing_agent(query, key, chat_history):
system_prompt = """
You are a routing agent, purely designed to determine if a user's query is a request for the use of a vector database for semantic search.
You will determine this based on the chat message history. A vector database is only needed to search for new classes. A user might ask for additional filtering on classes, but this is not necessarily a request for a new search.
Relay information in a way that is the bare minimum. You should only answer with a "1" when a vector db is needed or "0" otherwise and no other text at all.
"""
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": query},
{"role": "assistant", "content": "Here is the chat history: " + chat_history}
]
)
return response["choices"][0]["message"]["content"]