feat: direct model selection in Chat tab without pre-configuration
Users can now pick any model from the full catalog directly in the Chat tab using optgroups by provider (OpenAI, Google, Meta, Cohere, xAI), without needing to pre-configure it in GenAI Config. OCI credentials, region, and compartment auto-fill from the selected credential. A collapsible parameters panel (temperature, max_tokens, top_p, top_k, frequency/presence penalty) is available via the gear icon. Saved GenAI configs still appear at the top of the dropdown as presets.
This commit is contained in:
@@ -420,7 +420,15 @@ class ChangePwReq(BaseModel):
|
||||
class UserUpdateReq(BaseModel):
|
||||
email: Optional[str] = None; role: Optional[str] = None; is_active: Optional[bool] = None
|
||||
class ChatMsg(BaseModel):
|
||||
message: str; session_id: Optional[str] = None; genai_config_id: Optional[str] = None
|
||||
message: str; session_id: Optional[str] = None
|
||||
# Option A: saved preset
|
||||
genai_config_id: Optional[str] = None
|
||||
# Option B: direct model selection (inline)
|
||||
model_id: Optional[str] = None; oci_config_id: Optional[str] = None
|
||||
genai_region: Optional[str] = None; compartment_id: Optional[str] = None
|
||||
temperature: Optional[float] = None; max_tokens: Optional[int] = None
|
||||
top_p: Optional[float] = None; top_k: Optional[int] = None
|
||||
frequency_penalty: Optional[float] = None; presence_penalty: Optional[float] = None
|
||||
class RunReportReq(BaseModel):
|
||||
config_id: str; mcp_server_id: Optional[str] = None; regions: Optional[List[str]] = None
|
||||
class GenAIConfigReq(BaseModel):
|
||||
@@ -1570,6 +1578,32 @@ async def chat(msg: ChatMsg, u=Depends(current_user)):
|
||||
if msg.genai_config_id:
|
||||
with db() as c:
|
||||
genai_cfg = c.execute("SELECT * FROM genai_configs WHERE id=?", (msg.genai_config_id,)).fetchone()
|
||||
elif msg.model_id and msg.oci_config_id:
|
||||
# Direct model mode: build synthetic config dict
|
||||
with db() as c:
|
||||
oci_row = c.execute("SELECT * FROM oci_configs WHERE id=?", (msg.oci_config_id,)).fetchone()
|
||||
if not oci_row:
|
||||
raise HTTPException(400, "OCI config not found")
|
||||
region = msg.genai_region or oci_row["region"]
|
||||
compartment = msg.compartment_id or oci_row.get("compartment_id") or ""
|
||||
if not compartment:
|
||||
raise HTTPException(400, "compartment_id required")
|
||||
genai_cfg = {
|
||||
"oci_config_id": msg.oci_config_id,
|
||||
"model_id": msg.model_id,
|
||||
"model_ocid": None,
|
||||
"compartment_id": compartment,
|
||||
"genai_region": region,
|
||||
"endpoint": f"https://inference.generativeai.{region}.oci.oraclecloud.com",
|
||||
"serving_type": "ON_DEMAND",
|
||||
"dedicated_endpoint_id": None,
|
||||
"temperature": msg.temperature if msg.temperature is not None else 1.0,
|
||||
"max_tokens": msg.max_tokens if msg.max_tokens is not None else 6000,
|
||||
"top_p": msg.top_p if msg.top_p is not None else 0.95,
|
||||
"top_k": msg.top_k if msg.top_k is not None else 1,
|
||||
"frequency_penalty": msg.frequency_penalty if msg.frequency_penalty is not None else 0.0,
|
||||
"presence_penalty": msg.presence_penalty if msg.presence_penalty is not None else 0.0,
|
||||
}
|
||||
|
||||
if genai_cfg:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user