MCPcopy Index your code
hub / github.com/ModelEngine-Group/nexent / create_agent

Function create_agent

backend/database/agent_db.py:191–248  ·  view source on GitHub ↗

Create a new agent in the database (draft version, version_no=0). :param agent_info: Dictionary containing agent information :param tenant_id: :param user_id: :return: Created agent object

(agent_info, tenant_id: str, user_id: str)

Source from the content-addressed store, hash-verified

189
190
191def create_agent(agent_info, tenant_id: str, user_id: str):
192 """
193 Create a new agent in the database (draft version, version_no=0).
194 :param agent_info: Dictionary containing agent information
195 :param tenant_id:
196 :param user_id:
197 :return: Created agent object
198 """
199 info_with_metadata = dict(agent_info)
200 info_with_metadata.setdefault("max_steps", 15)
201 info_with_metadata.setdefault("verification_config", None)
202 info_with_metadata.update({
203 "tenant_id": tenant_id,
204 "version_no": 0, # Default to draft version
205 "created_by": user_id,
206 "updated_by": user_id,
207 "is_new": True, # Mark new agents as new
208 })
209 with get_db_session() as session:
210 new_agent = AgentInfo(**filter_property(info_with_metadata, AgentInfo))
211 new_agent.delete_flag = 'N'
212 session.add(new_agent)
213 session.flush()
214
215 # Directly extract agent_id and return as dict
216 result = {
217 "agent_id": new_agent.agent_id,
218 "tenant_id": new_agent.tenant_id,
219 "name": new_agent.name,
220 "display_name": new_agent.display_name,
221 "description": new_agent.description,
222 "author": new_agent.author,
223 "max_steps": new_agent.max_steps,
224 "duty_prompt": new_agent.duty_prompt,
225 "constraint_prompt": new_agent.constraint_prompt,
226 "few_shots_prompt": new_agent.few_shots_prompt,
227 "parent_agent_id": new_agent.parent_agent_id,
228 "enabled": new_agent.enabled,
229 "provide_run_summary": new_agent.provide_run_summary,
230 "business_description": new_agent.business_description,
231 "business_logic_model_id": new_agent.business_logic_model_id,
232 "business_logic_model_name": new_agent.business_logic_model_name,
233 "prompt_template_id": new_agent.prompt_template_id,
234 "prompt_template_name": new_agent.prompt_template_name,
235 "group_ids": new_agent.group_ids,
236 "is_new": new_agent.is_new,
237 "enable_context_manager": new_agent.enable_context_manager,
238 "requested_output_tokens": new_agent.requested_output_tokens,
239 "verification_config": new_agent.verification_config,
240 "greeting_message": new_agent.greeting_message,
241 "example_questions": new_agent.example_questions,
242 "current_version_no": new_agent.current_version_no,
243 "version_no": new_agent.version_no,
244 "created_by": new_agent.created_by,
245 "updated_by": new_agent.updated_by,
246 "delete_flag": new_agent.delete_flag,
247 }
248 return result

Callers 4

update_agent_info_implFunction · 0.90
import_agent_by_agent_idFunction · 0.90

Calls 5

get_db_sessionFunction · 0.90
AgentInfoClass · 0.90
filter_propertyFunction · 0.90
addMethod · 0.45
flushMethod · 0.45

Tested by 1