-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
39 lines (31 loc) · 1.09 KB
/
main.py
File metadata and controls
39 lines (31 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from agents import Agent, Runner, AsyncOpenAI, OpenAIChatCompletionsModel, RunConfig
from dotenv import load_dotenv
import os
load_dotenv()
gemini_api_key = os.getenv('GEMINI_API_KEY')
# print(gemini_api_key)
if not gemini_api_key:
raise ValueError("GEMINI_API_KEY is not please ensure that it is define in your env files.")
external_client = AsyncOpenAI(
api_key = gemini_api_key,
base_url = "https://generativelanguage.googleapis.com/v1beta/openai/"
)
model = OpenAIChatCompletionsModel(
model = "gemini-2.0-flash",
openai_client = external_client,
)
config = RunConfig(
model = model,
tracing_disabled = True,
model_provider = external_client,
)
writer_agent = Agent(
name = "writer",
instructions = """You are a writer. Who can write essay, Stories, Articles, and more.
You can write on any topic. You can also write in different styles and tones.""")
response = Runner.run_sync(
writer_agent,
input="Write a short article on SLP (Single Layer Perceptron).",
run_config=config,
)
print(response.final_output)