pulkitme commited on
Commit
1452216
·
1 Parent(s): 81917a3

deepseek API as first agent

Browse files
Files changed (2) hide show
  1. app.py +17 -3
  2. requirements.txt +2 -1
app.py CHANGED
@@ -4,6 +4,9 @@ import requests
4
  import inspect
5
  import pandas as pd
6
 
 
 
 
7
  # (Keep Constants as is)
8
  # --- Constants ---
9
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
@@ -15,9 +18,20 @@ class BasicAgent:
15
  print("BasicAgent initialized.")
16
  def __call__(self, question: str) -> str:
17
  print(f"Agent received question (first 50 chars): {question[:50]}...")
18
- fixed_answer = "This is a default answer."
19
- print(f"Agent returning fixed answer: {fixed_answer}")
20
- return fixed_answer
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  def run_and_submit_all( profile: gr.OAuthProfile | None):
23
  """
 
4
  import inspect
5
  import pandas as pd
6
 
7
+ from openai import OpenAI
8
+
9
+ client = OpenAI(api_key=os.getenv("API_KEY"), base_url="https://api.deepseek.com")
10
  # (Keep Constants as is)
11
  # --- Constants ---
12
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
 
18
  print("BasicAgent initialized.")
19
  def __call__(self, question: str) -> str:
20
  print(f"Agent received question (first 50 chars): {question[:50]}...")
21
+
22
+
23
+ response = client.chat.completions.create(
24
+ model="deepseek-chat",
25
+ messages=[
26
+ {"role": "system", "content": "You are a helpful assistant"},
27
+ {"role": "user", "content": question},
28
+ ],
29
+ stream=False
30
+ )
31
+ deepseek_answer = response.choices[0].message.content
32
+ #fixed_answer = "This is a default answer."
33
+ print(f"Agent returning fixed answer: {deepseek_answer}")
34
+ return deepseek_answer
35
 
36
  def run_and_submit_all( profile: gr.OAuthProfile | None):
37
  """
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  gradio
2
- requests
 
 
1
  gradio
2
+ requests
3
+ openai