Added DeepSeek to weeks 1, 2 and 8

This commit is contained in:
Edward Donner
2025-01-28 12:23:46 -05:00
parent 8cb97665af
commit 7d6d9959df
9 changed files with 298 additions and 9 deletions

View File

@@ -23,11 +23,19 @@ class FrontierAgent(Agent):
def __init__(self, collection):
"""
Set up this instance by connecting to OpenAI, to the Chroma Datastore,
Set up this instance by connecting to OpenAI or DeepSeek, to the Chroma Datastore,
And setting up the vector encoding model
"""
self.log("Initializing Frontier Agent")
self.openai = OpenAI()
deepseek_api_key = os.getenv("DEEPSEEK_API_KEY")
if deepseek_api_key:
self.client = OpenAI(api_key=deepseek_api_key, base_url="https://api.deepseek.com")
self.MODEL = "deepseek-chat"
self.log("Frontier Agent is set up with DeepSeek")
else:
self.client = OpenAI()
self.MODEL = "gpt-4o-mini"
self.log("Frontier Agent is setting up with OpenAI")
self.collection = collection
self.model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
self.log("Frontier Agent is ready")
@@ -85,14 +93,14 @@ class FrontierAgent(Agent):
def price(self, description: str) -> float:
"""
Make a call to OpenAI to estimate the price of the described product,
Make a call to OpenAI or DeepSeek to estimate the price of the described product,
by looking up 5 similar products and including them in the prompt to give context
:param description: a description of the product
:return: an estimate of the price
"""
documents, prices = self.find_similars(description)
self.log("Frontier Agent is about to call OpenAI with context including 5 similar products")
response = self.openai.chat.completions.create(
self.log(f"Frontier Agent is about to call {self.MODEL} with context including 5 similar products")
response = self.client.chat.completions.create(
model=self.MODEL,
messages=self.messages_for(description, documents, prices),
seed=42,