dawid-lorek commited on
Commit
569952a
·
verified ·
1 Parent(s): 03d27ad

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +5 -37
agent.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import os
2
  import re
3
  import requests
@@ -6,15 +7,6 @@ import io
6
  import pandas as pd
7
  from openai import OpenAI
8
  from word2number import w2n
9
- from difflib import get_close_matches
10
-
11
- KNOWN_INGREDIENTS = {
12
- 'salt', 'sugar', 'water', 'vanilla extract', 'lemon juice', 'cornstarch', 'granulated sugar', 'ripe strawberries'
13
- }
14
-
15
- KNOWN_VEGETABLES = {
16
- 'acorns', 'broccoli', 'celery', 'green beans', 'lettuce', 'sweet potatoes', 'peanuts'
17
- }
18
 
19
  class GaiaAgent:
20
  def __init__(self):
@@ -35,23 +27,12 @@ class GaiaAgent:
35
  return match.group(1) if match else text
36
 
37
  if "algebraic notation" in question.lower():
38
- match = re.search(r"\b(Qd1\+?|Nf3\+?|[KQBNR]?[a-h]?[1-8]?x?[a-h][1-8][+#]?)\b", text)
39
  return match.group(1) if match else text
40
 
41
- if "commutative" in question.lower():
42
- return "a, b, d, e"
43
-
44
- if "vegetables" in question.lower():
45
- return ", ".join(sorted(KNOWN_VEGETABLES))
46
-
47
- if "ingredients" in question.lower():
48
- found = set()
49
- for word in text.lower().split(','):
50
- word = word.strip()
51
- match = get_close_matches(word, KNOWN_INGREDIENTS, n=1, cutoff=0.6)
52
- if match:
53
- found.add(match[0])
54
- return ", ".join(sorted(found))
55
 
56
  if "USD with two decimal places" in question:
57
  match = re.search(r"\$?([0-9]+(?:\.[0-9]{1,2})?)", text)
@@ -66,8 +47,6 @@ class GaiaAgent:
66
  return ", ".join(str(n) for n in nums)
67
 
68
  if "at bats" in question.lower():
69
- if "Mickey Rivers" in text:
70
- return "565"
71
  match = re.search(r"(\d{3,4})", text)
72
  return match.group(1) if match else text
73
 
@@ -76,23 +55,12 @@ class GaiaAgent:
76
  return match.group(1) if match else text
77
 
78
  if "first name" in question.lower():
79
- if "Malko" in question:
80
- return "Uroš"
81
  return text.split()[0]
82
 
83
  if "NASA award number" in question:
84
  match = re.search(r"(80NSSC[0-9A-Z]{6,7})", text)
85
  return match.group(1) if match else text
86
 
87
- if "who did the actor" in question.lower():
88
- return "Cezary"
89
-
90
- if "equine veterinarian" in question.lower():
91
- return "Strasinger"
92
-
93
- if "youtube.com" in question.lower():
94
- return "3"
95
-
96
  return text
97
 
98
  def fetch_file(self, task_id):
 
1
+ # agent_v24.py
2
  import os
3
  import re
4
  import requests
 
7
  import pandas as pd
8
  from openai import OpenAI
9
  from word2number import w2n
 
 
 
 
 
 
 
 
 
10
 
11
  class GaiaAgent:
12
  def __init__(self):
 
27
  return match.group(1) if match else text
28
 
29
  if "algebraic notation" in question.lower():
30
+ match = re.search(r"\b([KQBNR]?[a-h]?[1-8]?x?[a-h][1-8][+#]?)\b", text)
31
  return match.group(1) if match else text
32
 
33
+ if "comma separated list" in question.lower():
34
+ words = re.findall(r"[a-zA-Z][a-zA-Z ]+[a-zA-Z]", text)
35
+ return ", ".join(sorted(set(w.strip().lower() for w in words)))
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  if "USD with two decimal places" in question:
38
  match = re.search(r"\$?([0-9]+(?:\.[0-9]{1,2})?)", text)
 
47
  return ", ".join(str(n) for n in nums)
48
 
49
  if "at bats" in question.lower():
 
 
50
  match = re.search(r"(\d{3,4})", text)
51
  return match.group(1) if match else text
52
 
 
55
  return match.group(1) if match else text
56
 
57
  if "first name" in question.lower():
 
 
58
  return text.split()[0]
59
 
60
  if "NASA award number" in question:
61
  match = re.search(r"(80NSSC[0-9A-Z]{6,7})", text)
62
  return match.group(1) if match else text
63
 
 
 
 
 
 
 
 
 
 
64
  return text
65
 
66
  def fetch_file(self, task_id):