forked from openai/openai-cua-sample-app
-
Notifications
You must be signed in to change notification settings - Fork 1
Pr embedding UI #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ashish-sarvam
wants to merge
15
commits into
morph-labs:main
Choose a base branch
from
sarvamai:pr-embedding-ui
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b126b20
computer use agent
rachittibrewal-sarvam cce4bfd
API keys
rachittibrewal-sarvam 1676743
Update to use autonomous agent
rachittibrewal-sarvam f631007
Try multiple approaches in one go
rachittibrewal-sarvam 808f05c
Update system prompt
rachittibrewal-sarvam 483872c
conda environment
rachittibrewal-sarvam ef65780
Sample streamlit app from anthropic
rachittibrewal-sarvam 0ace963
Update ttl_seconds in all instance starts.
rachittibrewal-sarvam 99bed66
Update ai agents
rachittibrewal-sarvam 76e5249
branching agent
rachittibrewal-sarvam 9f18ed4
Update readme and gitignore
rachittibrewal-sarvam 429ed5e
Update with trajectory storage
rachittibrewal-sarvam 9815faa
modifying git ignore
ashish-sarvam 8f1d9c4
created new ui and moved system prompt to version control
ashish-sarvam 760233c
adding embeddings for computer screens
ashish-sarvam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import streamlit as st | ||
| import streamlit.components.v1 as components | ||
| from computers import MorphComputer # assuming MorphComputer is in computers.py | ||
|
|
||
|
|
||
| def load_system_prompt(path: str = "prompts/system_prompt_v0.txt") -> str: | ||
| """Read the system prompt from an external file.""" | ||
| try: | ||
| with open(path, "r", encoding="utf-8") as f: | ||
| return f.read() | ||
| except FileNotFoundError: | ||
| st.error(f"❌ Could not find system prompt at '{path}'") | ||
| st.stop() | ||
|
|
||
|
|
||
| SYSTEM_PROMPT = load_system_prompt() | ||
|
|
||
| # Initialize session state | ||
| if "messages" not in st.session_state: | ||
| st.session_state.messages = [] | ||
| if "desktop_url" not in st.session_state: | ||
| st.session_state.desktop_url = "" | ||
| if "morph_instance" not in st.session_state: | ||
| st.session_state.morph_instance = None | ||
| if "initialized" not in st.session_state: | ||
| st.session_state.initialized = False | ||
| if "num_branches" not in st.session_state: | ||
| st.session_state.num_branches = 1 | ||
|
|
||
|
|
||
| def initialize_morph_desktop(task: str): | ||
| try: | ||
| with MorphComputer(auto_open_browser=False) as computer: | ||
| # Grab the URL of the full remote desktop | ||
| desktop_url = computer.get_desktop_url() | ||
| st.session_state.desktop_url = desktop_url | ||
| st.session_state.morph_instance = computer | ||
| st.session_state.messages.append( | ||
| { | ||
| "role": "assistant", | ||
| "content": f"✅ Initialized Morph virtual desktop for task: **{task}**", | ||
| } | ||
| ) | ||
| st.session_state.initialized = True | ||
| except Exception as e: | ||
| st.error(f"❌ Failed to initialize Morph desktop: {e}") | ||
| st.stop() | ||
|
|
||
|
|
||
| def process_user_input(user_input: str): | ||
| st.session_state.messages.append({"role": "user", "content": user_input}) | ||
| st.session_state.messages.append( | ||
| { | ||
| "role": "assistant", | ||
| "content": f"💡 (Pretend agent is working on this...)\n\n**Command received**: `{user_input}`", | ||
| } | ||
| ) | ||
| # In reality, you'd trigger agent + MorphComputer commands here. | ||
|
|
||
|
|
||
| # Page layout | ||
| st.set_page_config(page_title="Morph Desktop Viewer", layout="wide") | ||
| st.title("🖥️ Morph Virtual Desktop Agent") | ||
|
|
||
| # Task input form | ||
| with st.form("task_input_form", clear_on_submit=True): | ||
| user_input = st.text_input("Enter your task:") | ||
| submitted = st.form_submit_button("Submit") | ||
|
|
||
| if submitted and user_input: | ||
| if not st.session_state.initialized: | ||
| initialize_morph_desktop(user_input) | ||
| else: | ||
| process_user_input(user_input) | ||
|
|
||
| # Show chat log | ||
| for msg in st.session_state.messages: | ||
| role = "You" if msg["role"] == "user" else "Agent" | ||
| st.markdown(f"**{role}:** {msg['content']}") | ||
|
|
||
| # --- Virtual desktop UI embed --- | ||
| st.markdown("---") | ||
| st.header("🧩 Live Virtual Desktop") | ||
|
|
||
| if st.session_state.desktop_url: | ||
| components.iframe(st.session_state.desktop_url, height=600) | ||
| st.write(f"[Open in new tab]({st.session_state.desktop_url})") | ||
| else: | ||
| st.info("Morph desktop not initialized yet.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to fix the issue of system prompt not being used in the branching agent. will be good to fix in this pr itself