VGekko commited on
Commit
0eef5de
·
verified ·
1 Parent(s): 732f860

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -3
app.py CHANGED
@@ -4,20 +4,52 @@ 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"
10
 
 
 
 
11
  # --- Basic Agent Definition ---
12
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
13
  class BasicAgent:
14
  def __init__(self):
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 mistralai import Mistral
8
+
9
  # (Keep Constants as is)
10
  # --- Constants ---
11
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
12
 
13
+
14
+
15
+
16
  # --- Basic Agent Definition ---
17
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
18
  class BasicAgent:
19
  def __init__(self):
20
  print("BasicAgent initialized.")
21
+
22
  def __call__(self, question: str) -> str:
23
  print(f"Agent received question (first 50 chars): {question[:50]}...")
24
+
25
+ api_key = os.environ["MISTRAL_API_KEY"]
26
+ mistral_client = Mistral(api_key=api_key)
27
+ model = "open-mistral-nemo"
28
+
29
+ response = mistral_client.chat.complete(
30
+ model= model,
31
+ messages = [
32
+ {
33
+ "role": "user",
34
+ "content": question,
35
+ },
36
+ ]
37
+ )
38
+
39
+ answer = response.choices[0].message.content
40
+
41
+
42
+
43
+ #answer = "This is a default answer."
44
+ #print(f"Agent returning fixed answer: {answer}")
45
+ return answer
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
 
54
  def run_and_submit_all( profile: gr.OAuthProfile | None):
55
  """