Mohammad Haghir commited on
Commit
b95d477
·
1 Parent(s): 860a920

simple solution

Browse files
Files changed (1) hide show
  1. app.py +19 -3
app.py CHANGED
@@ -4,20 +4,36 @@ 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. --- 1"
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 langchain_openai import ChatOpenAI
8
+ from langchain_core.messages import HumanMessage
9
+
10
  # (Keep Constants as is)
11
  # --- Constants ---
12
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
13
 
14
+ model = ChatOpenAI(temperature=0)
15
+
16
+
17
+
18
+
19
  # --- Basic Agent Definition ---
20
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
21
  class BasicAgent:
22
  def __init__(self):
23
  print("BasicAgent initialized.")
24
  def __call__(self, question: str) -> str:
25
+
26
  print(f"Agent received question (first 50 chars): {question[:50]}...")
27
+ # fixed_answer = "This is a default answer. --- 1"
28
+ # print(f"Agent returning fixed answer: {fixed_answer}")
29
+ prompt = f"""
30
+ You should answer a question: {question}
31
+ """
32
+
33
+ # Call the LLM
34
+ messages = [HumanMessage(content=prompt)]
35
+ response = model.invoke(messages)
36
+ return response
37
 
38
  def run_and_submit_all( profile: gr.OAuthProfile | None):
39
  """