Sarathrsk03 commited on
Commit
d21bdd3
·
verified ·
1 Parent(s): e5296c3

Upload 8 files

Browse files
Files changed (8) hide show
  1. RAG.py +74 -0
  2. agents.py +79 -0
  3. app.py +23 -0
  4. llmConnect.py +157 -0
  5. metaData.csv +103 -0
  6. notes.txt +104 -0
  7. requirements.txt +129 -0
  8. tools.py +34 -0
RAG.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import chromadb
2
+ from chromadb.utils import embedding_functions
3
+ import csv
4
+ default_ef = embedding_functions.DefaultEmbeddingFunction()
5
+
6
+ def createEmbeddings():
7
+ try:
8
+ client = chromadb.PersistentClient("./chromaDB")
9
+ collection = client.get_or_create_collection("ICC_Rules")
10
+
11
+ # Use with statements for proper file handling
12
+ with open("notes.txt", "r") as f:
13
+ data = [line.strip() for line in f.readlines()] # Strip whitespace/newlines
14
+
15
+ with open("metaData.csv", "r") as f:
16
+ metaData = list(csv.reader(f))
17
+
18
+ # Validate data lengths
19
+ if len(data) != len(metaData):
20
+ print(f"Warning: Mismatch in data lengths. notes.txt has {len(data)} lines but metaData.csv has {len(metaData)} rows.")
21
+
22
+ # Process in batches if possible for better efficiency
23
+ for i in range(len(data)):
24
+ if i < len(metaData):
25
+ collection.add(
26
+ ids=[str(i)],
27
+ embeddings=default_ef([data[i]]),
28
+ metadatas=[{"ruleDescription": metaData[i][2]}],
29
+ documents=[data[i]] # Also store the original text
30
+ )
31
+ else:
32
+ # Handle case where metaData is shorter than data
33
+ collection.add(
34
+ ids=[str(i)],
35
+ embeddings=default_ef([data[i]]),
36
+ metadatas=[{"ruleDescription": "No metadata available"}],
37
+ documents=[data[i]]
38
+ )
39
+
40
+ print(f"Successfully added {len(data)} documents to the collection.")
41
+ except Exception as e:
42
+ print(f"Error creating embeddings: {e}")
43
+
44
+
45
+ def retrieveInfo(query, n_results=3):
46
+ try:
47
+ client = chromadb.PersistentClient("./chromaDB")
48
+ collection = client.get_or_create_collection("ICC_Rules")
49
+ results = collection.query(
50
+ query_embeddings=default_ef([query]), # Pass as a list
51
+ n_results=n_results,
52
+ )
53
+
54
+ if not results or not results['documents'] or len(results['documents'][0]) == 0:
55
+ return "No relevant information found."
56
+
57
+ # Format the results for easier consumption
58
+ formatted_results = []
59
+ for i in range(len(results['documents'][0])):
60
+ formatted_results.append({
61
+ "document": results['documents'][0][i],
62
+ "metadata": results['metadatas'][0][i] if 'metadatas' in results else {},
63
+ "distance": results['distances'][0][i] if 'distances' in results else None
64
+ })
65
+
66
+ print("Retrieved information successfully.")
67
+ return formatted_results
68
+ except Exception as e:
69
+ print(f"Error retrieving information: {e}")
70
+ return f"An error occurred: {e}"
71
+
72
+ if __name__ == "__main__":
73
+ #createEmbeddings()
74
+ print(retrieveInfo("What happens when there are less than 11 players fit?"))
agents.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from llmConnect import managerAgent, vectorDBAgent, searchAgent, sqlAgent, answerAgent
2
+ from json import loads
3
+
4
+
5
+
6
+
7
+ def generateAnswer(question:str) -> str:
8
+ managerResponse: list= managerAgent(question)
9
+ managerResponse.sort(key=lambda x: x['agent'])
10
+ #print(managerResponse)
11
+ context = ""
12
+ agentsResponseCummalative =[{"Question to be answered":question}]
13
+ for i in managerResponse:
14
+ if i['agent'] == 'vectorDBAgent':
15
+ if len(context) == 0:
16
+ context = "No context Required"
17
+ prompt = f"""
18
+ context -> {context}
19
+ question -> {i['question']}
20
+ """
21
+ agentResponse = vectorDBAgent(prompt)
22
+ context += " " + str(agentResponse)
23
+ agentsResponseCummalative.append({"agent":"vectorDBAgent","prompt":prompt,"answer":agentResponse})
24
+ elif i['agent'] == 'searchAgent':
25
+ prompt = f"""
26
+ context -> {context}
27
+ question -> {i['question']}
28
+ """
29
+ agentResponse = searchAgent(prompt)
30
+ context += " " + str(agentResponse)
31
+ agentsResponseCummalative.append({"agent":"searchAgent","prompt":prompt,"answer":agentResponse})
32
+ elif i['agent'] == 'sqlAgent':
33
+ prompt = f"""{i['question']}
34
+ """
35
+ agentResponse: dict = sqlAgent(prompt)
36
+ context += " " + str(agentResponse)
37
+ agentsResponseCummalative.append({"agent":"sqlAgent","prompt":prompt,"answer":agentResponse})
38
+
39
+ else:
40
+ agentsResponseCummalative.append(i)
41
+
42
+ for i in agentsResponseCummalative:
43
+ print(i)
44
+ print("\n")
45
+ print("."*100)
46
+ print("\n")
47
+
48
+ return answerAgent(str(agentsResponseCummalative))
49
+
50
+
51
+ if __name__ == "__main__":
52
+ question = "What is the highest score of MS Dhoni in the IPL"
53
+ print(generateAnswer(question))
54
+
55
+
56
+
57
+ #if "requestingAgent" in agentResponse.keys():
58
+ #if agentResponse["requestingAgent"] == "searchAgent":
59
+ #ans = vectorDBAgent(agentResponse["question"])
60
+ #newPrompt = f"""
61
+ #context -> {agentResponse["question"]} + " " + {ans}
62
+ #question -> {question}
63
+ #"""
64
+
65
+ #agentResponse = loads(sqlAgent(newPrompt))
66
+ #print(agentResponse)
67
+
68
+
69
+ #if "requestingAgent" in agentResponse.keys():
70
+ #if agentResponse["requestingAgent"] == "searchAgent":
71
+ #ans = vectorDBAgent(agentResponse["question"])
72
+ #newPrompt = f"""
73
+ #context -> {agentResponse["question"]} + " " + {ans}
74
+ #question -> {question}
75
+ #"""
76
+
77
+ #agentResponse = loads(sqlAgent(newPrompt))
78
+ #print(agentResponse)
79
+
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from agents import generateAnswer
3
+ from RAG import createEmbeddings
4
+ def test(input):
5
+ return input
6
+
7
+
8
+ with gr.Blocks() as demo:
9
+ input = gr.Textbox(placeholder="Enter your Cricket Related Question")
10
+ output = gr.Textbox(placeholder="Output")
11
+ submit = gr.Button("Submit")
12
+
13
+ submit.click(
14
+ fn = generateAnswer,
15
+ inputs = [input],
16
+ outputs = [output]
17
+ )
18
+
19
+
20
+
21
+ if __name__ == "__main__":
22
+ createEmbeddings()
23
+ demo.launch()
llmConnect.py ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from google import genai
2
+ from google.genai import types
3
+ from os import getenv
4
+ from dotenv import load_dotenv
5
+ from json import loads
6
+ from RAG import retrieveInfo
7
+ from tools import searchTool
8
+ from tools import sqlQuery
9
+ load_dotenv()
10
+
11
+
12
+
13
+ client = genai.Client(api_key=getenv('geminiAPI'))
14
+
15
+ def testConnection():
16
+ response =client.models.generate_content(
17
+ model='gemini-2.0-flash-001',
18
+ contents='Hello, how are you?'
19
+ )
20
+ return response.text
21
+
22
+
23
+
24
+ def readSystemInstruction(fileName: str):
25
+ with open(fileName, 'r') as file:
26
+ return file.read()
27
+
28
+
29
+ def managerAgent(question:str) -> list:
30
+ """
31
+ This Agent is responsible for breaking down the question into smaller questions and then assigns the appropriate agent to answer the question.
32
+ """
33
+ response = client.models.generate_content(
34
+ model='gemini-2.0-flash-001',
35
+ contents=question,
36
+ config = types.GenerateContentConfig(
37
+ system_instruction=readSystemInstruction('systemInstructions/managerAgent.txt'),
38
+ temperature=0.3,
39
+ response_mime_type='application/json'
40
+ )
41
+ )
42
+
43
+ return loads(response.text)
44
+
45
+ def vectorDBAgent(question:str):
46
+ question = "Optimise -> " + question
47
+ response = client.models.generate_content(
48
+ model='gemini-2.0-flash-001',
49
+ contents=question,
50
+ config = types.GenerateContentConfig(
51
+ system_instruction=readSystemInstruction('systemInstructions/vectorDBAgent.txt'),
52
+ temperature=0.3,
53
+ response_mime_type='application/json'
54
+ )
55
+ )
56
+
57
+ query = loads(response.text)[0]['Optimised Question']
58
+
59
+ RAGResponse = retrieveInfo(query)
60
+
61
+ prompt = f"""
62
+ Context -> {RAGResponse}
63
+ Question -> {query}
64
+ """
65
+ #print(prompt)
66
+ response = client.models.generate_content(
67
+ model='gemini-2.0-flash-001',
68
+ contents=prompt,
69
+ config = types.GenerateContentConfig(
70
+ system_instruction=readSystemInstruction('systemInstructions/vectorDBAgent.txt'),
71
+ temperature=0.3,
72
+ response_mime_type='application/json'
73
+ )
74
+ )
75
+
76
+
77
+
78
+ #print(response.text)
79
+ return loads(response.text)
80
+
81
+ def searchAgent(question:str) -> list:
82
+ prompt = f"""
83
+ question -> {question}
84
+ """
85
+
86
+ response = client.models.generate_content(
87
+ model='gemini-2.0-flash-001',
88
+ contents=prompt,
89
+ config = types.GenerateContentConfig(
90
+ system_instruction=readSystemInstruction('systemInstructions/searchAgent.txt'),
91
+ temperature=0.3,
92
+ response_mime_type='application/json'
93
+ )
94
+ )
95
+
96
+ searchQuery = loads(response.text)
97
+ #print(searchQuery)
98
+ searchResponse = searchTool(searchQuery['searchQuery'])
99
+
100
+ prompt = f"""
101
+ Context -> {searchResponse}
102
+ Question -> {question}
103
+ """
104
+ #print(prompt)
105
+ response = client.models.generate_content(
106
+ model='gemini-2.0-flash-001',
107
+ contents=prompt,
108
+ config = types.GenerateContentConfig(
109
+ system_instruction=readSystemInstruction('systemInstructions/searchAgent.txt'),
110
+ temperature=0.1,
111
+ response_mime_type='application/json'
112
+ )
113
+ )
114
+
115
+ #print(response.text)
116
+ return loads(response.text)
117
+
118
+
119
+ def sqlAgent(question:str) -> list:
120
+ response = client.models.generate_content(
121
+ model='gemini-2.0-flash-001',
122
+ contents=question,
123
+ config = types.GenerateContentConfig(
124
+ system_instruction=readSystemInstruction('systemInstructions/SQLAgent.txt'),
125
+ temperature=0.3,
126
+ response_mime_type='application/json'
127
+ )
128
+ )
129
+ ans = loads(response.text)
130
+ #print(ans)
131
+ #print(ans['SQLQuery']+";")
132
+ return sqlQuery(ans["SQLQuery"]+";")
133
+ #print(ans)
134
+
135
+ def answerAgent(context):
136
+ response = client.models.generate_content(
137
+ model='gemini-2.0-flash-001',
138
+ contents=context,
139
+ config = types.GenerateContentConfig(
140
+ system_instruction=readSystemInstruction('systemInstructions/answerAgent.txt'),
141
+ temperature=0.3
142
+ )
143
+ )
144
+ return response.text
145
+
146
+ if __name__ == '__main__':
147
+ #print(testConnection())
148
+ #question = "Who won yesterday match between AUS vs IND? and what are the most important rules of football?"
149
+ question="what is the highest score of the Rohit Sharma in the ODI"
150
+ #print(managerAgent(question))
151
+ #question = "Can a player hit the ball twice in cricket?"
152
+ #print(managerAgent(question))
153
+ #print(vectorDBAgent(question))
154
+ #question = "what was the score between SA and NZ cricket match?"
155
+ #print(searchAgent(question))
156
+ question = "What is the highest score of Ruturaj Gaikwad in the IPL"
157
+ print(sqlAgent(question))
metaData.csv ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Rule Type,Rule Number,Rule Description
2
+ Players,1.1,Number of players
3
+ Players,1.1.1,Exceptional circumstances for playing with less than eleven players
4
+ Players,1.1.2,Abandonment of match with fewer than nine fit and eligible players
5
+ Players,1.1.3,COVID status determination
6
+ Players,1.1.4,Use of traveling reserves as substitutes
7
+ Players,1.1.5,Consequences of refusing to participate
8
+ Players,1.2,Nomination and replacement of players
9
+ Players,1.2.1,Nomination of players
10
+ Players,1.2.2,Confirmation of nominated players
11
+ Players,1.2.3,Entitlement of substitute fielders
12
+ Players,1.2.4,Eligibility of nominated players
13
+ Players,1.2.5,Agreement to abide by ICC Regulations
14
+ Players,1.2.6,Restrictions on suspended players
15
+ Players,1.2.7,Player's dressing room access for suspended player
16
+ Players,1.2.7.1,Concussion Replacement conditions
17
+ Players,1.2.7.1.1,Head or neck injury sustained during play and within the playing area
18
+ Players,1.2.7.1.2,Formal diagnosis of concussion or suspected concussion
19
+ Players,1.2.7.1.3,Submission of Concussion Replacement Request
20
+ Players,1.2.7.1.3.1,Identify the player with the injury
21
+ Players,1.2.7.1.3.2,Specify the incident details
22
+ Players,1.2.7.1.3.3,Confirmation of diagnosis
23
+ Players,1.2.7.1.3.4,Identify requested Concussion Replacement
24
+ Players,1.2.7.2,Submission timing of Concussion Replacement Request
25
+ Players,1.2.7.3,Approval criteria for Concussion Replacement Request
26
+ Players,1.2.7.4,Assessment of like-for-like status for Concussion Replacement
27
+ Players,1.2.7.5,Conditions for excessive advantage in Concussion Replacement
28
+ Players,1.2.7.6,Request for further information in Concussion Replacement
29
+ Players,1.2.7.7,Finality of decision on Concussion Replacement Request
30
+ Players,1.2.7.8,Role of replaced player after Concussion Replacement approval
31
+ Players,1.2.7.9,Records for both Concussion Replacement and replaced player
32
+ Players,1.2.8,COVID-19 Replacement
33
+ Players,1.2.8.1,Conditions for COVID-19 Replacement
34
+ Players,1.2.8.1.1,Confirmation of positive COVID-19 test
35
+ Players,1.2.8.1.2,Submission of COVID-19 Replacement Request
36
+ Players,1.2.8.2,Approval criteria for COVID-19 Replacement Request
37
+ Players,1.2.8.3,Assessment of like-for-like status for COVID-19 Replacement
38
+ Players,1.2.8.4,Conditions for excessive advantage in COVID-19 Replacement
39
+ Players,1.2.8.5,Conditions for COVID-19 Replacement
40
+ Players,1.2.8.6,Finality of decision on COVID-19 Replacement Request
41
+ Players,1.2.8.7,Role of replaced player after COVID-19 Replacement approval
42
+ Players,1.2.8.8,Records for both COVID-19 Replacement and replaced player
43
+ Players,1.3,Captain
44
+ Players,1.3.1,Deputy for unavailable captain
45
+ Players,1.3.2,Deputy for nomination in absence of captain
46
+ Players,1.3.3,Nominated player as deputy after player nomination
47
+ Players,1.4,Responsibility of captains
48
+ Umpires,2.1,Appointment and attendance
49
+ Umpires,2.1.1,Umpires' control and impartiality
50
+ Umpires,2.1.2,ICC appointment of on-field umpires
51
+ Umpires,2.1.3,Umpires' selection and country criteria
52
+ Umpires,2.1.4,Appointment of match referee
53
+ Umpires,2.1.5,Match referee's country criteria
54
+ Umpires,2.1.6,Objection rights on umpire/match referee appointment
55
+ Umpires,2.2,Change of umpire
56
+ Umpires,2.3,Consultation with Ground Authority
57
+ Umpires,2.3.1,Clock or watch selection
58
+ Umpires,2.3.2,Field of play boundary determination
59
+ Umpires,2.3.3,Use of covers
60
+ Umpires,2.3.4,Special conditions of play
61
+ Umpires,2.4,"The wickets, creases, and boundaries"
62
+ Umpires,2.4.1,Correct marking of creases
63
+ Umpires,2.4.2,Proper pitching of wickets
64
+ Umpires,2.4.3,Boundary compliance
65
+ Umpires,2.5,"Conduct of the match, implements and equipment"
66
+ Umpires,2.5.1,Strict adherence to Playing Conditions
67
+ Umpires,2.5.2,Conformity of implements used
68
+ Umpires,2.5.2.1,Conformance to clause 4 (The ball)
69
+ Umpires,2.5.2.2,Conformance to clause 5 (The bat) and paragraph 1 of Appendix B
70
+ Umpires,2.5.2.3,Conformance to clauses 8.2 (Size of stumps) and 8.3 (The bails)
71
+ Umpires,2.5.3,Use of permitted equipment
72
+ Umpires,2.5.4,Wicket-keeper’s gloves compliance
73
+ Umpires,2.6,Fair and unfair play
74
+ Umpires,2.7,Fitness for play
75
+ Umpires,2.7.1,Umpires' decision on play conditions
76
+ Umpires,2.7.2,Conditions considered dangerous
77
+ Umpires,2.7.3,Conditions considered unreasonable
78
+ Umpires,2.7.4,Conditions so bad for play
79
+ Umpires,2.8,Suspension of play in dangerous or unreasonable circumstances
80
+ Umpires,2.8.1,Inclusion of pitch in references to ground
81
+ Umpires,2.8.2,Umpires' decision to suspend play
82
+ Umpires,2.8.3,Ground action to address conditions
83
+ Umpires,2.8.4,Disregard shadows on the pitch
84
+ Umpires,2.8.5,Light Meters
85
+ Umpires,2.8.5.1,Uniform calibration of light meters
86
+ Umpires,2.8.5.2,Entitlement to use light meter readings
87
+ Umpires,2.8.5.3,Use of light meter readings
88
+ Umpires,2.8.6,Use of artificial lights
89
+ Umpires,2.8.7,Umpires' responsibility during suspension of play
90
+ Umpires,2.8.8,Safety of all persons during threatening circumstances
91
+ Umpires,2.8.9,Decision to abandon or resume play
92
+ Umpires,2.9,Position of umpires
93
+ Umpires,2.1,Umpires changing ends
94
+ Umpires,2.11,Disagreement and dispute
95
+ Umpires,2.12,Umpire’s decision
96
+ Umpires,2.13,Signals
97
+ Umpires,2.13.1.1,Signal for No ball
98
+ Umpires,2.13.1.2,Signal for Out
99
+ Umpires,2.13.1.3,Signal for Wide
100
+ Umpires,2.13.1.4,Signal for Dead ball
101
+ Umpires,2.13.2,Acknowledgment of signals
102
+ Umpires,2.14,Informing the umpires
103
+ Umpires,2.15,Correctness of scores
notes.txt ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ A match is played between two sides, each of eleven players, one of whom shall be captain.
2
+ In exceptional circumstances, a team may participate in a match with less than eleven players. However, a minimum of nine players in each team must be eligible to participate, and substitutes must be drawn from the official squad.
3
+ If a team has fewer than nine fit and eligible players or does not wish to play with fewer than eleven players, a match will be abandoned.
4
+ The Event Technical Committee will be the final arbiter as to the COVID status of any player and his consequential availability to participate in a match.
5
+ If a team has traveling reserves within the official squad and they are fit to play, they must be made available if they would enable a team to field 11 players.
6
+ If a team refuses to participate in a match confirmed by the Event Technical Committee, they will be considered a forfeit in accordance with the Playing Conditions.
7
+ Each captain shall nominate 11 players plus a maximum of 4 substitute fielders in writing on the team sheet provided by the ICC. No player (member of the playing eleven) may be changed after the nomination and prior to the start of play without the consent of the opposing captain.
8
+ Each captain shall nominate 11 players plus a maximum of 4 substitute fielders in writing on the team sheet provided by the ICC.
9
+ Immediately prior to the toss, the ICC Match Referee or their nominee shall check with both team captains that the players nominated on the team sheets are correct.
10
+ Only those nominated as substitute fielders shall be entitled to act as substitute fielders during the match, unless the ICC Match Referee allows subsequent additions in exceptional circumstances.
11
+ All nominated players, including substitute fielders and Concussion Replacements, must be official squad members of that particular team.
12
+ Nominees shall be deemed to have agreed to abide by all applicable ICC Regulations pertaining to international cricket.
13
+ "A player or player support personnel who has been suspended from participating in a match shall not, from the toss of the coin and for the remainder of the match thereafter:
14
+ 1.2.6.1 Be nominated as, or carry out any of the duties or responsibilities of a substitute fielder, or
15
+ 1.2.6.2 Enter any part of the playing area (which shall include the field of play and the area between the boundary and the perimeter boards) at any time, including any scheduled or unscheduled breaks in play."
16
+ A player who has been suspended from participating in a match shall be permitted from the toss of the coin and for the remainder of the match thereafter be permitted to enter the players’ dressing room provided that the players’ dressing room (or any part thereof) for the match is not within the playing area described in clause 1.2.6.2 above (for example, the player is not permitted to enter the on-field ‘dug-out’).
17
+ If a player sustains a concussion or suspected concussion as a result of a head or neck injury during the course of the relevant match, a Concussion Replacement may be permitted in the following circumstances:
18
+ The head or neck injury must have been sustained during play and within the playing area described in clause 1.2.5.2 above;
19
+ A concussion or suspected concussion must have been formally diagnosed by the Team Medical Representative;
20
+ The Team Medical Representative or Team Manager shall submit a Concussion Replacement Request to the ICC Match Referee on a standard form, which shall:
21
+ 1. Identify the player who has sustained the concussion or suspected concussion;
22
+ 2. Specify the incident in which the concussion or suspected concussion was sustained, including the time at which it occurred;
23
+ 3. Confirm that, following an examination, the Team Medical Representative believes or suspects that the player has sustained a concussion as a result of the incident specified in clause 1.2.7.1.3.2 above; and
24
+ 4. Identify the requested Concussion Replacement, who shall be a like-for-like replacement for the player who has sustained the concussion or suspected concussion.
25
+ The Concussion Replacement Request must be submitted as soon as possible after the incident specified in clause 1.2.7.1.3.2 if a Concussion Replacement is to be permitted.
26
+ The ICC Match Referee should ordinarily approve a Concussion Replacement Request if the replacement is a like-for-like player whose inclusion will not excessively advantage his team for the remainder of the match.
27
+ In assessing whether the nominated Concussion Replacement should be considered a like-for-like player, the ICC Match Referee should consider the likely role the concussed player would have played during the remainder of the match, and the normal role that would be performed by the nominated Concussion Replacement.
28
+ If the ICC Match Referee believes that the inclusion of the nominated Concussion Replacement, when performing their normal role, would excessively advantage their team, the ICC Match Referee may impose such conditions upon the identity and involvement of the Concussion Replacement as he/she sees fit, in line with the overriding objective of facilitating a like-for-like replacement for the concussed player.
29
+ The ICC Match Referee may, in reviewing a Concussion Replacement Request made in accordance with clause 1.2.7.1.3, request any such further information as may be required in order to make the determination required under clauses 1.2.7.4 and 1.2.7.5.
30
+ The decision of the ICC Match Referee in relation to any Concussion Replacement Request shall be final and neither team shall have any right of appeal.
31
+ Once the Concussion Replacement has been approved by the ICC Match Referee, the replaced player shall play no further part in the match.
32
+ Both the Concussion Replacement and the replaced player shall be considered to have played in the match for records and statistical purposes.
33
+ NA
34
+ If during the course of the relevant match a player tests positive for COVID-19, a COVID-19 Replacement may be permitted in the following circumstances:
35
+ 1. The positive test for COVID-19 must be formally confirmed by the Team Medical Representative and endorsed by the match day doctor.
36
+ 2. The Team Medical Representative or Team Manager shall submit a COVID-19 Replacement Request to the ICC Match Referee on a standard form which shall identify the requested COVID-19 Replacement, who shall be a like-for-like replacement for the player whose replacement is requested.
37
+ Subject to confirmation of the COVID status of the player to be replaced by the Event Technical Committee as outlined in 1.1.3 above, the ICC Match Referee should ordinarily approve a COVID-19 Replacement Request if the replacement is a like-for-like player whose inclusion will not excessively advantage his team for the remainder of the match.
38
+ In assessing whether the nominated COVID-19 Replacement should be considered a like-for-like player, the ICC Match Referee should consider the likely role the relevant player would have played during the remainder of the match, and the normal role that would be performed by the nominated COVID-19 Replacement.
39
+ If the ICC Match Referee believes that the inclusion of the nominated COVID-19 Replacement, when performing their normal role, would excessively advantage their team, the ICC Match Referee may impose such conditions upon the identity and involvement of the COVID-19 Replacement as he/she sees fit, in line with the overriding objective of facilitating a like-for-like replacement for the relevant player.
40
+ The ICC Match Referee may, in reviewing a COVID-19 Replacement Request made in accordance with clause 1.2.8.1, request any such further information as may be required to make the determination required under clauses 1.2.8.3 and 1.2.8.4.
41
+ The decision of the ICC Match Referee in relation to any COVID-19 Replacement Request shall be final and neither team shall have any right of appeal.
42
+ Once the COVID-19 Replacement has been approved by the ICC Match Referee, the replaced player shall play no further part in the match.
43
+ Both the COVID-19 Replacement and the replaced player shall be considered to have played in the match for records and statistical purposes.
44
+ NA
45
+ If at any time the captain is not available, a deputy shall act for him.
46
+ If a captain is not available to nominate the players, then any person associated with that team may act as his deputy to do so.
47
+ At any time after the nomination of the players, only a nominated player can act as deputy in discharging the duties and responsibilities of the captain as stated in these Playing Conditions, including at the toss.
48
+ The captains are responsible at all times for ensuring that play is conducted within The Spirit of Cricket as well as within these Playing Conditions.
49
+ NA
50
+ The umpires shall control the game as required by these Playing Conditions, with absolute impartiality and shall be present at the ground at least 1.5 hours before the scheduled start of play.
51
+ ICC shall appoint the on-field umpires, third umpire and fourth umpire for all matches. The fourth umpire shall act as the emergency on-field umpire.
52
+ The umpires shall not be from the same country as the participating teams and shall be selected from the ICC ‘Elite Panel’ or the ICC ‘International Panel’. In exceptional circumstances, the third or fourth umpire may be from the same country as one of the participating teams.
53
+ The ICC shall appoint the match referee for all matches (ICC Match Referee).
54
+ Unless exceptional circumstances arise, the match referee shall not be from the same country as the participating teams.
55
+ Neither team shall have a right of objection to the appointment of any umpire or match referee.
56
+ An umpire shall not be changed during the match, other than in exceptional circumstances unless he/she is injured or ill.
57
+ Before the match, the umpires shall consult with the Home Board to determine;
58
+ which clock or watch and back-up timepiece is to be used during the match.
59
+ the boundary of the field of play. See clause 19 (Boundaries).
60
+ the use of covers. See clause 10 (Covering the pitch).
61
+ any special conditions of play affecting the conduct of the match. inform the scorers of agreements in 2.3.1 and 2.3.2.
62
+ Before the toss and during the match, the umpires shall satisfy themselves that
63
+ the creases are correctly marked. See clause 7 (The creases).
64
+ the wickets are properly pitched. See clause 8 (The wickets)
65
+ the boundary of the field of play complies with the requirements of clauses 19.1 (Determining the boundary of the field of play), 19.2 (Identifying and marking the boundary) and 19.3 (Restoring the boundary).
66
+ NA
67
+ Before the toss and during the match, the umpires shall satisfy themselves that the conduct of the match is strictly in accordance with these Playing Conditions.
68
+ Before the toss and during the match, the umpires shall satisfy themselves that the implements used in the match conform to the following
69
+ NA
70
+ NA
71
+ NA
72
+ No player uses equipment other than that permitted. See paragraph 2 of Appendix A. Note particularly therein the interpretation of ‘protective helmet’.
73
+ The wicket-keeper’s gloves comply with the requirements of clause 27.2 (Gloves).
74
+ The umpires shall be the sole judges of fair and unfair play.
75
+ NA
76
+ It is solely for the umpires together to decide whether either conditions of ground, weather or light or exceptional circumstances mean that it would be dangerous or unreasonable for play to take place. Conditions shall not be regarded as either dangerous or unreasonable merely because they are not ideal. The fact that the grass and the ball are wet does not warrant the ground conditions being regarded as unreasonable or dangerous.
77
+ Conditions shall be regarded as dangerous if there is actual and foreseeable risk to the safety of any player or umpire.
78
+ Conditions shall be regarded as unreasonable if, although posing no risk to safety, it would not be sensible for play to proceed.
79
+ If the umpires consider the ground is so wet or slippery as to deprive the bowler of a reasonable foothold, the fielders of the power of free movement, or the batters of the ability to play their strokes or to run between the wickets, then these conditions shall be regarded as so bad that it would be dangerous and unreasonable for play to take place.
80
+ NA
81
+ All references to ground include the pitch. See clause 6.1 (Area of pitch).
82
+ If at any time the umpires together agree that the conditions of ground, weather or light, or any other circumstances are dangerous or unreasonable, they shall immediately suspend play, or not allow play to start or to recommence. The decision as to whether conditions are so bad as to warrant such action is one for the umpires alone to make, following consultation with the ICC Match Referee.
83
+ If circumstances are warranted, the umpires shall stop play and instruct the Ground Authority to take whatever action they can and use whatever equipment is necessary to remove as much dew as possible from the outfield when conditions become unreasonable or dangerous. The umpires may also instruct the ground staff to take such action during scheduled and unscheduled breaks in play.
84
+ The umpires shall disregard any shadow on the pitch from the stadium or from any permanent object on the ground.
85
+ It is the responsibility of the ICC to supply light meters to the match officials.
86
+ All light meters shall be uniformly calibrated.
87
+ The umpires shall be entitled to use light meter readings as a guideline for determining whether the light is fit for play.
88
+ Light meter readings may be used to determine deterioration or improvement in light and as benchmarks for the remainder of a match.
89
+ If natural light is deteriorating, the umpires may authorize the use of artificial lighting to ensure acceptable conditions.
90
+ During a suspension of play, umpires shall monitor conditions, make inspections, and call upon players to resume play when conditions are no longer dangerous or unreasonable.
91
+ In the event of any threatening circumstance, umpires, on the advice of the ICC Match Referee, may suspend play, and all players and officials should leave the field and relocate to a secure area. The decision to abandon or resume play is the responsibility of the ICC Match Referee after consultation with relevant authorities.
92
+ When play is suspended under clause 2.8.8, the decision to abandon or resume play is the responsibility of the ICC Match Referee, who shall act after consultation with relevant authorities.
93
+ Umpires stand where they can best see any act requiring their decision. Bowler’s end umpire avoids interference with the bowler’s run-up or striker’s view. Striker’s end umpire may stand on the off side with prior notification.
94
+ Shall not apply.
95
+ In case of disagreement or dispute, umpires make the final decision.
96
+ Umpire may alter any decision promptly, provided it doesn't contradict clause 20.6. Umpire’s decision, once made, is final.
97
+ Umpires use specified signals during play and when the ball is dead. Signals include No ball, Out, Wide, Dead ball, Boundary 4, Boundary 6, Bye, Five Penalty runs (to batting or fielding side), Leg bye, Revoke last signal, Short run, Free Hit, Powerplay Over, Level 4 player conduct offences (two-part signal). The bowler’s end umpire repeats signals to the scorers when the ball is dead.
98
+ By extending one arm horizontally.
99
+ By raising an index finger above the head (if not out, the umpire calls Not out).
100
+ By extending both arms horizontally.
101
+ By crossing and re-crossing the wrists below the waist.
102
+ Umpire waits until each signal to the scorers is separately acknowledged before allowing play to proceed.
103
+ When umpires receive information, it's sufficient for one umpire to be informed, and he/she informs the other umpire.
104
+ Consultation between umpires and scorers on doubtful points is essential. Umpires ensure correctness of runs scored, wickets fallen, and overs bowled throughout the match.
requirements.txt ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.2.1
2
+ aiohappyeyeballs==2.5.0
3
+ aiohttp==3.11.13
4
+ aiosignal==1.3.2
5
+ annotated-types==0.7.0
6
+ anyio==4.8.0
7
+ asgiref==3.8.1
8
+ attrs==25.1.0
9
+ backoff==2.2.1
10
+ bcrypt==4.3.0
11
+ build==1.2.2.post1
12
+ cachetools==5.5.2
13
+ certifi==2025.1.31
14
+ charset-normalizer==3.4.1
15
+ chroma-hnswlib==0.7.6
16
+ chromadb==0.6.3
17
+ click==8.1.8
18
+ coloredlogs==15.0.1
19
+ Deprecated==1.2.18
20
+ deprecation==2.1.0
21
+ distro==1.9.0
22
+ durationpy==0.9
23
+ fastapi==0.115.11
24
+ ffmpy==0.5.0
25
+ filelock==3.17.0
26
+ flatbuffers==25.2.10
27
+ frozenlist==1.5.0
28
+ fsspec==2025.2.0
29
+ google-auth==2.38.0
30
+ google-genai==1.5.0
31
+ googleapis-common-protos==1.69.1
32
+ gotrue==2.11.4
33
+ gradio==5.21.0
34
+ gradio_client==1.7.2
35
+ groovy==0.1.2
36
+ grpcio==1.70.0
37
+ h11==0.14.0
38
+ h2==4.2.0
39
+ hpack==4.1.0
40
+ httpcore==1.0.7
41
+ httptools==0.6.4
42
+ httpx==0.28.1
43
+ huggingface-hub==0.29.2
44
+ humanfriendly==10.0
45
+ hyperframe==6.1.0
46
+ idna==3.10
47
+ importlib_metadata==8.5.0
48
+ importlib_resources==6.5.2
49
+ Jinja2==3.1.6
50
+ kubernetes==32.0.1
51
+ markdown-it-py==3.0.0
52
+ MarkupSafe==2.1.5
53
+ mdurl==0.1.2
54
+ mmh3==5.1.0
55
+ monotonic==1.6
56
+ mpmath==1.3.0
57
+ multidict==6.1.0
58
+ mysql-connector-python==9.2.0
59
+ numpy==2.2.3
60
+ oauthlib==3.2.2
61
+ onnxruntime==1.20.1
62
+ opentelemetry-api==1.30.0
63
+ opentelemetry-exporter-otlp-proto-common==1.30.0
64
+ opentelemetry-exporter-otlp-proto-grpc==1.30.0
65
+ opentelemetry-instrumentation==0.51b0
66
+ opentelemetry-instrumentation-asgi==0.51b0
67
+ opentelemetry-instrumentation-fastapi==0.51b0
68
+ opentelemetry-proto==1.30.0
69
+ opentelemetry-sdk==1.30.0
70
+ opentelemetry-semantic-conventions==0.51b0
71
+ opentelemetry-util-http==0.51b0
72
+ orjson==3.10.15
73
+ overrides==7.7.0
74
+ packaging==24.2
75
+ pandas==2.2.3
76
+ pillow==11.1.0
77
+ postgrest==0.19.3
78
+ posthog==3.19.0
79
+ propcache==0.3.0
80
+ protobuf==5.29.3
81
+ pyasn1==0.6.1
82
+ pyasn1_modules==0.4.1
83
+ pydantic==2.10.6
84
+ pydantic_core==2.27.2
85
+ pydub==0.25.1
86
+ Pygments==2.19.1
87
+ PyPika==0.48.9
88
+ pyproject_hooks==1.2.0
89
+ python-dateutil==2.9.0.post0
90
+ python-dotenv==1.0.1
91
+ python-multipart==0.0.20
92
+ pytz==2025.1
93
+ PyYAML==6.0.2
94
+ realtime==2.4.1
95
+ regex==2024.11.6
96
+ requests==2.32.3
97
+ requests-oauthlib==2.0.0
98
+ rich==13.9.4
99
+ rsa==4.9
100
+ ruff==0.10.0
101
+ safehttpx==0.1.6
102
+ semantic-version==2.10.0
103
+ shellingham==1.5.4
104
+ six==1.17.0
105
+ sniffio==1.3.1
106
+ starlette==0.46.0
107
+ storage3==0.11.3
108
+ StrEnum==0.4.15
109
+ supabase==2.13.0
110
+ supafunc==0.9.3
111
+ sympy==1.13.3
112
+ tavily-python==0.5.1
113
+ tenacity==9.0.0
114
+ tiktoken==0.9.0
115
+ tokenizers==0.21.0
116
+ tomlkit==0.13.2
117
+ tqdm==4.67.1
118
+ typer==0.15.2
119
+ typing_extensions==4.12.2
120
+ tzdata==2025.1
121
+ urllib3==2.3.0
122
+ uvicorn==0.34.0
123
+ uvloop==0.21.0
124
+ watchfiles==1.0.4
125
+ websocket-client==1.8.0
126
+ websockets==14.2
127
+ wrapt==1.17.2
128
+ yarl==1.18.3
129
+ zipp==3.21.0
tools.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from tavily import TavilyClient
2
+ from os import getenv
3
+ from dotenv import load_dotenv
4
+ import mysql.connector
5
+
6
+ load_dotenv()
7
+
8
+
9
+ conn = mysql.connector.connect(
10
+ host=getenv('MYSQL_HOST'),
11
+ user=getenv('MYSQL_USER'),
12
+ password=getenv('MYSQL_PASSWORD'),
13
+ database=getenv('MYSQL_DATABASE')
14
+ )
15
+ load_dotenv()
16
+
17
+
18
+
19
+ tavily_client = TavilyClient(api_key=getenv('TAVILY_API'))
20
+
21
+ def searchTool(question:str) -> dict:
22
+ response = tavily_client.search(question)
23
+ return response
24
+
25
+
26
+ def sqlQuery(query:str):
27
+ cursor = conn.cursor()
28
+ cursor.execute(query)
29
+ result = cursor.fetchall()
30
+ return result
31
+
32
+
33
+ if __name__ == "__main__":
34
+ print(searchTool("How to create a new branch in git?"))