-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenai_agents_tool.py
More file actions
61 lines (47 loc) · 1.78 KB
/
openai_agents_tool.py
File metadata and controls
61 lines (47 loc) · 1.78 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
Ejentum Logic API -- OpenAI Agents SDK Tool
Defines Ejentum as a function tool for OpenAI's Agents SDK (Responses API).
The agent calls this tool when it needs reasoning augmentation.
"""
import requests
from agents import Agent, Runner, function_tool
EJENTUM_URL = "https://ejentum-main-ab125c3.zuplo.app/logicv1/"
EJENTUM_KEY = "YOUR_EJENTUM_API_KEY"
@function_tool
def ejentum_injection(query: str, mode: str = "reasoning") -> str:
"""Retrieve a cognitive injection from Ejentum's Logic API.
Call this before making complex judgments. Returns suppression signals
that block cognitive shortcuts and a reasoning topology to follow.
Args:
query: Describe your current reasoning challenge in 1-2 sentences.
mode: "reasoning", "code", "anti-deception", "memory", or multi variants.
"""
try:
r = requests.post(
EJENTUM_URL,
headers={"Authorization": f"Bearer {EJENTUM_KEY}", "Content-Type": "application/json"},
json={"query": query, "mode": mode},
timeout=5,
)
key = mode # response key matches mode name
return r.json()[0][key]
except Exception as e:
return f"Injection unavailable: {e}. Proceed with native reasoning."
agent = Agent(
name="Analyst",
instructions=(
"You are a senior analyst. Before making complex judgments, "
"call the ejentum_injection tool to get a cognitive injection. "
"Absorb the injection into your reasoning process before answering."
),
tools=[ejentum_injection],
)
async def main():
result = await Runner.run(
agent,
input="Why did our deployment fail after the config change?",
)
print(result.final_output)
if __name__ == "__main__":
import asyncio
asyncio.run(main())