Overview#
This is an extension that uses AI-powered LangChain agents to answer questions, provide code samples, and guide users in the development of the Omniverse UI Framework. The key deliverable of the extension is to assist and guide users in writing and debugging omni.ui and omni.ui.scene code, as well as answer related questions. This extension does so via a conversational chat interface with a LangChain AI agent.
Implementation details#
Here’s an overview of the structure and key components of the omni.ai.langchain.agent.omni_ui extension:
The omni.ai.langchain.agent.omni_ui extension consists of several key components and submodules:
modifierssubmodule:Contains modifier classes that can be applied to various aspects of the agent’s behavior.
Key components:
AsyncOmniUIClassAppender: Based on the questions, find related classes in codeAtlas and Appends dynamic input messages to agent.NetworkLengthModifier: Calculate the network length.OmniUICodeInterpreterModifier: Interprets AI generated code snippets.OmniUICodeRagModifier: Based on the question, find the closest related code sample for AI.RemoteCodeInterpreter: Interprets code snippets remotely to isolate possible crashes in code.
nodessubmodule:Contains node classes that define the behavior of the extension.
Key components:
systemssubmodule: Contains system prompts for the AI agent.agent_system: The general system prompt for the agent that contains the high level extension overview exposed to the agent (e.g., omni.ui, omni.ui.scene, omni.kit.widget.filter).classes: This is used for AsyncOmniUIClassAppender as a selective system prompt inputs for agent to avoid token access issue.omni_ui_scene_system: The system prompt for the agent to view examples of specific classes in theomni.ui.sceneextension.omni_ui_system: The system prompt for the agent to view examples of specific classes in theomni.uiextension.
OmniUIAgent: The UI agent to answer questions and provide code samples related to the Omniverse UI Framework.OmniUICodeNetworkNode: The UI agent network which uses modifiers and tools to iteratively generate correct code.
toolssubmodule:Contains tools used by the agent for various tasks.
Key components:
create_ui_atlas: Creates the UI CodeAtlas for the extension. See Data section for more detailsomni_ui_code_atlas_tool: A tool for managing the UI CodeAtlas.omni_ui_rag_collection: Manages the RAG collection for omni.ui code. See Data section for more detailsremote_code_interpreter_server: Spawn a remote kit instance for interpreting code snippets.
Data & Tool#
The agent has access to various tools and data to provide as accurate and relevant responses to user queries. Here’s an overview of the resources available to the agent:
The agent use the system prompt to chooses the most relevant extensions prompts. It then uses the CodeAtlas and RAG to generate responses:
UI CodeAtlas: A collection of code snippets, examples, and documentation related to the
omni.uiextension. The UI CodeAtlas is created and managed by thecreate_ui_atlastool.RAG Collection: A collection of code snippets and relationships for the
omni.uiextension. The RAG collection is managed by theomni_ui_rag_collectiontool.Update the collection json with the collection tool.
Update the RAG database with
python -m lc_agent_faiss_rag_gen --input_json <collection_json> --output_db <faiss_database_directory> --text_field file_name --metadata_fields file_path method_name source_code --embedding_model ai-embed-qa-4 (--update_existing)
Adding an Extension#
To add a new extension to the existing agent’s knowledge base, follow these steps:
Create a new system prompt in the
systemssubmodule for the new extension.Add relevant classes and code examples to the new extension’s system prompt.
Update the agent’s knowledge base with the new extension’s data sources
Update a UI CodeAtlas for the extension using the
create_ui_atlastool.Update the RAG collection for the extension using the
omni_ui_rag_collectiontool.
Include relevant dependencies and imports in the extension’s codebase.