Skip to content

Commit dd3d2aa

Browse files
committed
Added llm as judge simple completions api.py
1 parent 1b064ca commit dd3d2aa

20 files changed

Lines changed: 849 additions & 0 deletions
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"Dec to Feb": {
3+
"months": ["Dec", "Jan", "Feb"],
4+
"Peak Timing": "7 PM to 11 PM",
5+
"Off-Peak Timing": "Remaining 20 hours"
6+
},
7+
"Mar to May": {
8+
"months": ["Mar", "Apr", "May"],
9+
"Peak Timing": "8 PM to 12 PM",
10+
"Off-Peak Timing": "Remaining 20 hours"
11+
},
12+
"Jun to Aug": {
13+
"months": ["Jun", "Jul", "Aug"],
14+
"Peak Timing": "7 PM to 11 PM",
15+
"Off-Peak Timing": "Remaining 20 hours"
16+
},
17+
"Sep to Nov": {
18+
"months": ["Sep", "Oct", "Nov"],
19+
"Peak Timing": "9 PM to 1 AM",
20+
"Off-Peak Timing": "Remaining 20 hours"
21+
}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"Dec to Feb": {
3+
"months": ["Dec", "Jan", "Feb"],
4+
"Peak Timing": "5 PM to 9 PM",
5+
"Off-Peak Timing": "Remaining 20 hours"
6+
},
7+
"Mar to May": {
8+
"months": ["Mar", "Apr", "May"],
9+
"Peak Timing": "6 PM to 10 PM",
10+
"Off-Peak Timing": "Remaining 20 hours"
11+
},
12+
"Jun to Aug": {
13+
"months": ["Jun", "Jul", "Aug"],
14+
"Peak Timing": "7 PM to 11 PM",
15+
"Off-Peak Timing": "Remaining 20 hours"
16+
},
17+
"Sep to Nov": {
18+
"months": ["Sep", "Oct", "Nov"],
19+
"Peak Timing": "6 PM to 10 PM",
20+
"Off-Peak Timing": "Remaining 20 hours"
21+
}
22+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
2+
from agents import Agent, Runner, set_tracing_disabled
3+
from agents.tool import function_tool
4+
from agents.extensions.models.litellm_model import LitellmModel
5+
import json
6+
from dotenv import load_dotenv
7+
import datetime
8+
import os
9+
load_dotenv()
10+
11+
12+
Model = "gemini/gemini-2.5-flash"
13+
gemini_api_key = os.getenv("gemini")
14+
15+
@function_tool()
16+
def current_month():
17+
months = {1: 'January', 2: 'February', 3: 'March', 4: 'April',
18+
5: 'May', 6: 'June', 7: 'July', 8: 'August', 9: 'September',
19+
10: 'October', 11: 'November', 12: 'December'}
20+
return months[datetime.date.today().month] # August
21+
22+
@function_tool()
23+
def get_peak_hours(city: str, month):
24+
if city.lower() == "lahore" or city.lower() == "lhr":
25+
lhr_data = json.load(open('lahore_peak_timings.json'))
26+
return lhr_data
27+
elif city.lower() == "fsd" or city.lower() == "faisalabad":
28+
fsd_data = json.load(open('faisalabad_peak_timings.json'))
29+
return fsd_data
30+
else:
31+
return False
32+
33+
fsd_agent = Agent(name = "Faisalabad Agent", instructions = "You are an agent for Faisalabad related queries if"
34+
"a customers asks for peak hours from any time"
35+
"you first check the current month and then you fetch "
36+
"peak hours for that month, if user provides month himself"
37+
"then give him peak hours for that month for faisalad",
38+
model = LitellmModel(model= Model, api_key= gemini_api_key),
39+
tools = [current_month, get_peak_hours],
40+
handoff_description = "For Faisalabad or Fsd related peak hours queries")
41+
42+
43+
44+
lhr_agent = Agent(name = "Lahore Agent", instructions = "You are an agent for Lahore related queries if"
45+
"a customers asks for peak hours from any time"
46+
"you first check the current month and then you fetch "
47+
"peak hours for that month"
48+
"if user provides month himself"
49+
"then give him peak hours for that month for lhr",
50+
model = LitellmModel(model= Model, api_key= gemini_api_key),
51+
tools = [current_month, get_peak_hours],
52+
handoff_description = "For Lahore or Lhr related peak hours queries")
53+
54+
55+
orchestrating_tool = Agent(name = "Orchestrator", instructions = "You will decide which agent to call for a task",
56+
model = LitellmModel(model= Model, api_key= gemini_api_key),
57+
handoffs = [lhr_agent, fsd_agent])
58+
59+
# query = input("Which City are you from?\n").lower()
60+
# query = f"I am from {query} what are my current peak hours?"
61+
62+
query2 = "I am from Faisalabad what are peak hours for January?"
63+
result = Runner.run_sync(orchestrating_tool, query2)
64+
print(result.final_output)
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
2+
from agents import Agent, Runner, OpenAIChatCompletionsModel, RunConfig, function_tool
3+
import json
4+
from dotenv import load_dotenv
5+
import datetime
6+
import os
7+
from openai import AsyncOpenAI
8+
load_dotenv()
9+
from pydantic import BaseModel
10+
from typing import List
11+
import asyncio
12+
13+
class Output_Gen(BaseModel):
14+
timings: List[str]
15+
16+
17+
load_dotenv()
18+
api_key=os.getenv('gemini')
19+
gemini_base_url = "https://generativelanguage.googleapis.com/v1beta/openai/"
20+
gemini_model = "gemini-2.5-flash"
21+
22+
external_client = AsyncOpenAI(api_key=api_key, timeout=300.0, base_url=gemini_base_url)
23+
24+
model = OpenAIChatCompletionsModel(model= gemini_model, openai_client= external_client)
25+
26+
config = RunConfig(model = model, tracing_disabled = True, model_provider = external_client)
27+
28+
@function_tool()
29+
def current_month():
30+
months = {1: 'January', 2: 'February', 3: 'March', 4: 'April',
31+
5: 'May', 6: 'June', 7: 'July', 8: 'August', 9: 'September',
32+
10: 'October', 11: 'November', 12: 'December'}
33+
return months[datetime.date.today().month] # August
34+
35+
@function_tool()
36+
def get_peak_hours(city: str, month):
37+
if city.lower() == "lahore" or city.lower() == "lhr":
38+
lhr_data = json.load(open('lahore_peak_timings.json'))
39+
return lhr_data
40+
elif city.lower() == "fsd" or city.lower() == "faisalabad":
41+
fsd_data = json.load(open('faisalabad_peak_timings.json'))
42+
return fsd_data
43+
else:
44+
return False
45+
46+
fsd_agent = Agent(name = "Faisalabad Agent", instructions = "You are an agent for Faisalabad related queries if"
47+
"a customers asks for peak hours from any time"
48+
"you first check the current month and then you fetch "
49+
"peak hours for that month, if user provides month himself"
50+
"then give him peak hours for that month for faisalad",
51+
model = model,
52+
tools = [current_month, get_peak_hours],
53+
handoff_description = "For Faisalabad or Fsd related peak hours queries")
54+
55+
56+
57+
lhr_agent = Agent(name = "Lahore Agent", instructions = "You are an agent for Lahore related queries if"
58+
"a customers asks for peak hours from any time"
59+
"you first check the current month and then you fetch "
60+
"peak hours for that month"
61+
"if user provides month himself"
62+
"then give him peak hours for that month for lhr",
63+
model = model,
64+
tools = [current_month, get_peak_hours],
65+
handoff_description = "For Lahore or Lhr related peak hours queries")
66+
67+
orchestrating_tool = Agent(name = "Orchestrator", instructions = "You will decide which agent to call for a task",
68+
model = model,
69+
handoffs = [lhr_agent, fsd_agent])
70+
71+
# query = input("Which City are you from?\n").lower()
72+
# query = f"I am from {query} what are my current peak hours?"
73+
74+
async def ask_user():
75+
query2 = "I am from lhr what are peak hours for current month?"
76+
query3 = "I am from Faisalabad the peak hours 7 PM to 11 PM are for which months? "
77+
result = await Runner.run(orchestrating_tool, query2, run_config = config)
78+
return result.final_output
79+
80+
print(asyncio.run(ask_user()))
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from agents import Agent, Runner, function_tool, set_tracing_disabled
2+
from agents.extensions.models.litellm_model import LitellmModel
3+
import os
4+
from dotenv import load_dotenv
5+
import asyncio
6+
7+
load_dotenv()
8+
Model = "gemini/gemini-2.5-flash"
9+
gemini_api_key = os.getenv("gemini")
10+
11+
12+
async def main(model: str, api_key: str):
13+
agent = Agent(
14+
name="Assistant",
15+
instructions="You respond clearly as you're a helpful agent.",
16+
model= LitellmModel (model=model, api_key=api_key)
17+
)
18+
19+
result = await Runner.run(agent, "What is 2 * 9?")
20+
print(result.final_output)
21+
22+
asyncio.run(main(Model, gemini_api_key))
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#Free Gemini Models
2+
3+
Currently Gemini is offering these free models:
4+
5+
### Group 1: Flash & Gecko Models
6+
7+
- `bedding-gecko-001`
8+
- `gemini-1.5-flash-latest`
9+
- `gemini-1.5-flash`
10+
- `gemini-1.5-flash-002`
11+
- `gemini-1.5-flash-8b`
12+
- `gemini-1.5-flash-8b-001`
13+
- `gemini-1.5-flash-8b-latest`
14+
- `gemini-2.5-flash-preview-05-20`
15+
- `gemini-2.5-flash`
16+
- `gemini-2.5-flash-lite-preview-06-17`
17+
- `gemini-2.0-flash-exp`
18+
19+
### Group 2: Flash Experimental & Lite Variants
20+
21+
- `gemini-2.0-flash`
22+
- `gemini-2.0-flash-001`
23+
- `gemini-2.0-flash-exp-image-generation`
24+
- `gemini-2.0-flash-lite-001`
25+
- `gemini-2.0-flash-lit`
26+
- `gemini-2.0-flash-preview-image-generation`
27+
- `gemini-2.0-flash-lite-preview-02-05`
28+
- `gemini-2.0-flash-lite-preview`
29+
- `gemini-exp-1206`
30+
- `gemini-2.0-flash-thinking-exp-01-21`
31+
32+
### Group 3: Thinking, Experimental & Gemma Models
33+
34+
- `gemini-2.0-flash-thinking-exp`
35+
- `gemini-2.0-flash-thinking-exp-1219`
36+
- `gemini-2.5-flash-preview-tt`
37+
- `arnlm-2.0-flash-experimenta`
38+
- `gemma-3-1b-it`
39+
- `gemma-3-4b-it`
40+
- `gemma-3-12b-it`
41+
- `gemma-3-27b-it`
42+
- `gemma-3n-e4b-it`
43+
- `gemma-3n-e2b-it`
44+
45+
### Group 4: Embeddings, AQA & Imagen Models
46+
47+
- `gemini-2.5-flash-lit`
48+
- `gemini-2.5-flash-image-preview`
49+
- `bedding-001`
50+
- `text-embedding-004`
51+
- `gemini-embedding-exp-03-07`
52+
- `gemini-embedding-exp`
53+
- `gemini-embedding-001`
54+
- `aqa`
55+
- `imagen-3.0-generate-002`
56+
- `imagen-4.0-generate-preview-06-06`
57+
58+
### Group 5: Imagen, Veo, Live & Audio Models
59+
60+
- `imagen-4.0-ultra-generate-preview-06-06`
61+
- `imagen-4.0-generate-001`
62+
- `imagen-4.0-ultra-generate-001`
63+
- `imagen-4.0-fast-generate-001`
64+
- `veo-2.0-generate-001`
65+
- `veo-3.0-generate-preview`
66+
- `veo-3.0-fast-generate-preview`
67+
- `veo-3.0-generate-001`
68+
- `veo-3.0-fast-generate-001`
69+
- `gemini-2.5-flash-preview-native-audio-dialog`
70+
- `gemini-2.5-flash-exp-native-audio-thinking-dialog`
71+
- `gemini-2.0-flash-live-001`
72+
- `gemini-live-2.5-flash-preview`
73+
- `gemini-2.5-flash-live-preview`
74+
- `yria-realtime-exp`
75+
76+
---
77+
Last updated: 2025-04-05
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from openai import OpenAI
2+
import os
3+
from dotenv import load_dotenv
4+
5+
load_dotenv()
6+
client = OpenAI(
7+
api_key= os.getenv('gemini'),
8+
base_url="https://generativelanguage.googleapis.com/v1beta/openai/"
9+
)
10+
11+
free_models = []
12+
models = client.models.list()
13+
for model in models:
14+
if "pro" not in model.id:
15+
free_models.append(model.id.strip('models/'))
16+
17+
print(free_models[0:11])
18+
print(free_models[11:21])
19+
print(free_models[21:31])
20+
print(free_models[31:41])
21+
print(free_models[41:57])

Open AI Agents SDK/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
To run basic_chainlit_connection.py file:
2+
3+
First Run:
4+
5+
<pre>
6+
uv add chainlit dotenv openai openai-agents
7+
</pre>
8+
9+
Then run `uv run chainlit run basic_chainlit_connection.py -w`, it will load the app on: `http://localhost:8000/`
10+
11+
To use LitellmModel (using_litellm_model.py) you need to add:
12+
13+
<pre>
14+
uv add openai-agents[litellm]
15+
</pre>
16+
17+
Reference:
18+
https://openai.github.io/openai-agents-python/models/litellm/

0 commit comments

Comments
 (0)