llamasrock commited on
Commit
3ad04fb
·
verified ·
1 Parent(s): 00536ce

Update app.py

Browse files

Added 10 sec sleep to make the code run within gemini rate limits

Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -30,19 +30,20 @@ class BasicAgent:
30
  # self.agent = CodeAgent(model = self.llm_model, tools = [self.google_search_tool])
31
  # Define Google API client with GoogleSearch tool
32
  self.client = genai.Client(api_key=GEMINI_API_KEY)
33
-
34
 
35
  print("BasicAgent initialized.")
36
- def __call__(self, question: str) -> str:
 
37
  print(f"Agent received question (first 50 chars): {question[:50]}...")
38
  fixed_answer = "This is a default answer."
39
  # print(f"Agent returning fixed answer: {fixed_answer}")
40
  # return fixed_answer
41
  # return self.agent.run(question)
42
  # Use the Google GenAI client to run the question
43
- response = self.client.models.generate_content(
 
44
  model='gemini-2.0-flash',
45
- contents=f'Answer the following question in the format as requested. Do not include any explanation, only provide your answer. {question}',
46
  config=types.GenerateContentConfig(
47
  tools=[types.Tool(
48
  google_search=types.GoogleSearch()
 
30
  # self.agent = CodeAgent(model = self.llm_model, tools = [self.google_search_tool])
31
  # Define Google API client with GoogleSearch tool
32
  self.client = genai.Client(api_key=GEMINI_API_KEY)
 
33
 
34
  print("BasicAgent initialized.")
35
+
36
+ async def __call__(self, question: str) -> str:
37
  print(f"Agent received question (first 50 chars): {question[:50]}...")
38
  fixed_answer = "This is a default answer."
39
  # print(f"Agent returning fixed answer: {fixed_answer}")
40
  # return fixed_answer
41
  # return self.agent.run(question)
42
  # Use the Google GenAI client to run the question
43
+ await asyncio.sleep(10)
44
+ response = asyncio.self.client.models.generate_content(
45
  model='gemini-2.0-flash',
46
+ contents=f'Answer the following question in the format as requested.{question}',
47
  config=types.GenerateContentConfig(
48
  tools=[types.Tool(
49
  google_search=types.GoogleSearch()