Skip to content

Commit 45aafa7

Browse files
committed
fix: address pre-commit linting issues
- Fix line length issues in enterprise gateway example - Update imports to use get_default_agent instead of Agent directly - Remove try/finally block and conversation.close() call to match SDK patterns
1 parent fe10076 commit 45aafa7

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

examples/01_standalone_sdk/26_enterprise_gateway.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212

1313
from pydantic import SecretStr
1414

15-
from openhands.sdk import Agent, Conversation, MessageEvent
16-
from openhands.sdk.llm import LLM, content_to_str
15+
from openhands.sdk import Conversation
16+
from openhands.sdk.llm import LLM
17+
from openhands.tools.preset.default import get_default_agent
1718

1819

1920
def build_gateway_llm() -> LLM:
@@ -30,7 +31,8 @@ def build_gateway_llm() -> LLM:
3031
base_url=os.getenv(
3132
"LLM_BASE_URL", "https://your-corporate-proxy.company.com/api/llm"
3233
),
33-
# an api_key input is always required but is unused when api keys are passed via extra headers
34+
# an api_key input is always required but is unused when api keys
35+
# are passed via extra headers
3436
api_key=SecretStr(os.getenv("LLM_API_KEY", "placeholder")),
3537
custom_llm_provider=os.getenv("LLM_CUSTOM_LLM_PROVIDER", "openai"),
3638
ssl_verify=ssl_verify,
@@ -58,19 +60,15 @@ def build_gateway_llm() -> LLM:
5860
llm = build_gateway_llm()
5961

6062
# Create agent and conversation
61-
agent = Agent(llm=llm, cli_mode=True)
63+
agent = get_default_agent(llm=llm, cli_mode=True)
6264
conversation = Conversation(
6365
agent=agent,
6466
workspace=os.getcwd(),
65-
visualize=False,
6667
)
6768

68-
try:
69-
# Send a message to test the enterprise gateway configuration
70-
conversation.send_message(
71-
"Analyze this codebase and create 3 facts about the current project into FACTS.txt. Do not write code."
72-
)
73-
conversation.run()
74-
75-
finally:
76-
conversation.close()
69+
# Send a message to test the enterprise gateway configuration
70+
conversation.send_message(
71+
"Analyze this codebase and create 3 facts about the current "
72+
"project into FACTS.txt. Do not write code."
73+
)
74+
conversation.run()

0 commit comments

Comments
 (0)