deploy
This commit is contained in:
40
agent.py
40
agent.py
@@ -48,7 +48,17 @@ LEARNHOUSE_CONTEXT = (
|
||||
"When creating a course, send multipart form fields name, description, "
|
||||
"public, and about; if the user only gives a title, use it as name, provide "
|
||||
"short description/about text, and set public=false unless the user asks "
|
||||
"for a public course."
|
||||
"for a public course. When asked to create a course with lessons or modules, "
|
||||
"create the course, create each chapter with the returned course_id, then "
|
||||
"create at least one activity in each chapter using that chapter's specific "
|
||||
"chapter_id. Do not attach all activities to the first chapter. For visible "
|
||||
"lesson content, create activities with activity_type TYPE_DYNAMIC, "
|
||||
"activity_sub_type SUBTYPE_DYNAMIC_MARKDOWN, markdown content/details, "
|
||||
"lock_type public, and published=true unless the user requests drafts. "
|
||||
"After writing course content, verify every chapter has at least one "
|
||||
"activity through course metadata or the chapter activity endpoint. When "
|
||||
"updating activities, do not send published_version; this LearnHouse "
|
||||
"backend currently rejects that field."
|
||||
)
|
||||
|
||||
|
||||
@@ -63,7 +73,7 @@ class OperationInput(BaseModel):
|
||||
class LearnhouseAgent(A2AAgent):
|
||||
name = "learnhouse-agent"
|
||||
description = "LearnHouse is an open-source platform tailored for learning experiences."
|
||||
version = "1.2.10"
|
||||
version = "1.2.11"
|
||||
consumer_setup = ConsumerSetup.from_fields(
|
||||
ConsumerSetupField.config("OPENAPI_BASE_URL", label="API base URL", description="Override the default API server (https://learnhouse.a2acloud.io).", required=False, input_type="url"),
|
||||
ConsumerSetupField.secret(
|
||||
@@ -291,6 +301,18 @@ class LearnhouseAgent(A2AAgent):
|
||||
"For LearnHouse course creation, send body/form fields: "
|
||||
"name, description, public, about."
|
||||
)
|
||||
if _is_learnhouse_create_activity(operation):
|
||||
parts.append(
|
||||
"For LearnHouse activity creation, send JSON fields name, "
|
||||
"chapter_id, activity_type, activity_sub_type, content, "
|
||||
"details, lock_type, and published. Use the target "
|
||||
"chapter's own chapter_id; do not reuse the first chapter ID."
|
||||
)
|
||||
if _is_learnhouse_update_activity(operation):
|
||||
parts.append(
|
||||
"Do not send published_version on LearnHouse activity "
|
||||
"updates; this backend rejects that field."
|
||||
)
|
||||
parts.append(f"Operation ID: {operation['operation_id']}")
|
||||
return "\n".join(part for part in parts if part)
|
||||
|
||||
@@ -500,6 +522,20 @@ def _is_learnhouse_create_course(operation: dict[str, Any]) -> bool:
|
||||
)
|
||||
|
||||
|
||||
def _is_learnhouse_create_activity(operation: dict[str, Any]) -> bool:
|
||||
return (
|
||||
str(operation.get("operation_id") or "")
|
||||
== "api_create_activity_api_v1_activities_post"
|
||||
)
|
||||
|
||||
|
||||
def _is_learnhouse_update_activity(operation: dict[str, Any]) -> bool:
|
||||
return (
|
||||
str(operation.get("operation_id") or "")
|
||||
== "api_update_activity_api_v1_activities_activity_uuid_put"
|
||||
)
|
||||
|
||||
|
||||
def _apply_learnhouse_defaults(
|
||||
operation: dict[str, Any],
|
||||
parameters: dict[str, Any],
|
||||
|
||||
Reference in New Issue
Block a user