mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-04-29 03:00:45 -04:00
* Replace OpenDevin with OpenHands * Update CONTRIBUTING.md * Update README.md * Update README.md * update poetry lock; move opendevin folder to openhands * fix env var * revert image references in docs * revert permissions * revert permissions --------- Co-authored-by: Xingyao Wang <xingyao6@illinois.edu>
31 lines
979 B
Python
31 lines
979 B
Python
import os
|
|
|
|
from openai import OpenAI
|
|
|
|
|
|
# ==================================================================================================
|
|
# OPENAI
|
|
# TODO: Move this to EventStream Actions when EventStreamRuntime is fully implemented
|
|
# NOTE: we need to get env vars inside functions because they will be set in IPython
|
|
# AFTER the agentskills is imported (the case for EventStreamRuntime)
|
|
# ==================================================================================================
|
|
def _get_openai_api_key():
|
|
return os.getenv('OPENAI_API_KEY', os.getenv('SANDBOX_ENV_OPENAI_API_KEY', ''))
|
|
|
|
|
|
def _get_openai_base_url():
|
|
return os.getenv('OPENAI_BASE_URL', 'https://api.openai.com/v1')
|
|
|
|
|
|
def _get_openai_model():
|
|
return os.getenv('OPENAI_MODEL', 'gpt-4o-2024-05-13')
|
|
|
|
|
|
def _get_max_token():
|
|
return os.getenv('MAX_TOKEN', 500)
|
|
|
|
|
|
def _get_openai_client():
|
|
client = OpenAI(api_key=_get_openai_api_key(), base_url=_get_openai_base_url())
|
|
return client
|