xarical commited on
Commit
20e5c62
·
1 Parent(s): 318feab
Files changed (2) hide show
  1. CustomAgent.py +9 -4
  2. app.py +2 -1
CustomAgent.py CHANGED
@@ -43,11 +43,16 @@ Question: {question}
43
  """
44
  ...
45
  result = _magic(question)
 
46
  return result
47
 
48
- def _banana(query: str) -> str:
49
  """
50
- banana
 
 
 
 
51
  """
52
  try:
53
  r = requests.post(
@@ -55,8 +60,8 @@ Question: {question}
55
  json={"query": query}
56
  )
57
  r.raise_for_status()
58
- response = r.json()
59
  except Exception as e:
60
  print(e)
61
- response = f'{{"error": "An error has occurred while using websearch, please inform the user of this"}}'
62
  print(f"Agent searched for {query}. Response: {response}")
 
43
  """
44
  ...
45
  result = _magic(question)
46
+ print("Agent returning actual answer:", result)
47
  return result
48
 
49
+ def websearch(query: str) -> str:
50
  """
51
+ Performs a web search using an external web search API.
52
+ Args:
53
+ query (str): The search query string.
54
+ Returns:
55
+ str: The response from the web search API as a string.
56
  """
57
  try:
58
  r = requests.post(
 
60
  json={"query": query}
61
  )
62
  r.raise_for_status()
63
+ response = r.text
64
  except Exception as e:
65
  print(e)
66
+ response = "An error has occurred while using websearch, please inform the user of this"
67
  print(f"Agent searched for {query}. Response: {response}")
app.py CHANGED
@@ -20,7 +20,8 @@ Note: Once clicking on the "submit button, it can take quite some time (this is
20
 
21
  ---
22
  **Implementation:**
23
- wip
 
24
  """
25
  )
26
  gr.LoginButton()
 
20
 
21
  ---
22
  **Implementation:**
23
+
24
+ CustomAgent is a subclass of BasicAgent that uses a custom system prompt and integrates with an OpenAI-compatible model (llama-3.3-70b-versatile via Groq API). It leverages the magentic library for prompt chaining and function calling, allowing the agent to use external tools such as web search.
25
  """
26
  )
27
  gr.LoginButton()