Spaces:
Runtime error
Runtime error
abtsousa commited on
Commit ·
2b9cce2
1
Parent(s): c8325a7
Move API configuration constants to config.py
Browse files- agent/config.py +5 -0
- agent/nodes.py +2 -3
agent/config.py
CHANGED
|
@@ -1,5 +1,10 @@
|
|
| 1 |
from typing import Literal
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
def create_agent_config(app_name: str, thread_id: int) -> dict:
|
| 4 |
"""
|
| 5 |
Create configuration for the agent.
|
|
|
|
| 1 |
from typing import Literal
|
| 2 |
|
| 3 |
+
API_BASE_URL = "https://openrouter.ai/api/v1"
|
| 4 |
+
MODEL_NAME = "qwen/qwen3-235b-a22b-thinking-2507:floor"
|
| 5 |
+
MODEL_TEMPERATURE = 0.7
|
| 6 |
+
API_KEY_ENV_VAR = "OPENROUTER_API_KEY"
|
| 7 |
+
|
| 8 |
def create_agent_config(app_name: str, thread_id: int) -> dict:
|
| 9 |
"""
|
| 10 |
Create configuration for the agent.
|
agent/nodes.py
CHANGED
|
@@ -15,10 +15,8 @@ from langchain_core.messages import SystemMessage, HumanMessage
|
|
| 15 |
from langgraph.prebuilt import ToolNode
|
| 16 |
from langchain_core.rate_limiters import InMemoryRateLimiter
|
| 17 |
|
|
|
|
| 18 |
|
| 19 |
-
API_BASE_URL = "https://openrouter.ai/api/v1"
|
| 20 |
-
MODEL_NAME = "openai/gpt-oss-120b"
|
| 21 |
-
API_KEY_ENV_VAR = "OPENROUTER_API_KEY"
|
| 22 |
if API_KEY_ENV_VAR not in os.environ:
|
| 23 |
print(f"Please set the environment variable {API_KEY_ENV_VAR}.")
|
| 24 |
os.environ[API_KEY_ENV_VAR] = getpass(f"Enter your {API_KEY_ENV_VAR} (will not be echoed): ")
|
|
@@ -46,6 +44,7 @@ def _get_model() -> BaseChatModel:
|
|
| 46 |
api_key=SecretStr(api_key) if api_key else None,
|
| 47 |
base_url=API_BASE_URL,
|
| 48 |
model=MODEL_NAME,
|
|
|
|
| 49 |
rate_limiter=_rate_limiter,
|
| 50 |
metadata={
|
| 51 |
"reasoning": {
|
|
|
|
| 15 |
from langgraph.prebuilt import ToolNode
|
| 16 |
from langchain_core.rate_limiters import InMemoryRateLimiter
|
| 17 |
|
| 18 |
+
from agent.config import API_BASE_URL, MODEL_NAME, API_KEY_ENV_VAR, MODEL_TEMPERATURE
|
| 19 |
|
|
|
|
|
|
|
|
|
|
| 20 |
if API_KEY_ENV_VAR not in os.environ:
|
| 21 |
print(f"Please set the environment variable {API_KEY_ENV_VAR}.")
|
| 22 |
os.environ[API_KEY_ENV_VAR] = getpass(f"Enter your {API_KEY_ENV_VAR} (will not be echoed): ")
|
|
|
|
| 44 |
api_key=SecretStr(api_key) if api_key else None,
|
| 45 |
base_url=API_BASE_URL,
|
| 46 |
model=MODEL_NAME,
|
| 47 |
+
temperature=MODEL_TEMPERATURE if MODEL_TEMPERATURE else 0.0,
|
| 48 |
rate_limiter=_rate_limiter,
|
| 49 |
metadata={
|
| 50 |
"reasoning": {
|