Skip to content

Commit

Permalink
Adds VisionAgentV2 (#302)
Browse files Browse the repository at this point in the history
* added AgentMessage type for conversations

* added VisionAgentV2

* added VisionAgentV2 to imports

* made timeout 3 minutes

* consolidated types and added AgentMessage to utils

* fixed owl_v2_image name in prompts

* fix flake8

* added abstract classes for coder and planner

* add message to agentmessage functionality

* added documentation

* add make file

* fix chat highlighting

* fix issues with app

* added readme for app

* add matplotlib to deps

* make local app work with conv agent

* update v2 actions, make max_steps argument

* don't add file names to non-user chats

* fix typo

* update action descriptions
  • Loading branch information
dillonalaird authored Nov 21, 2024
1 parent 30684ca commit add011d
Show file tree
Hide file tree
Showing 20 changed files with 1,839 additions and 1,134 deletions.
Binary file added assets/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions examples/chat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Example App
This is an example applicaiton to demonstrate how to run VisionAgent locally.


# Quick Start
To get started install the fastapi library:
```bash
pip install "fastapi[standard]"
```

Then cd into `chat-app` and run `make` to install the node dependencies.

To start the server run:
```bash
fastapi dev app.py
```

And to start the front end, in the chat-app folder run:
```bash
npm run dev
```

Then go to `http://localhost:3000` in your browser to see the app running.

![screenshot](https://github.com/landing-ai/vision-agent/blob/main/assets/screenshot.png?raw=true)
17 changes: 14 additions & 3 deletions examples/chat/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel

from vision_agent.agent import VisionAgentCoderV2
from vision_agent.agent import VisionAgentV2
from vision_agent.agent.types import AgentMessage

app = FastAPI()

Expand Down Expand Up @@ -36,7 +37,7 @@ def update_callback(message: Dict[str, Any]):
loop.close()


agent = VisionAgentCoderV2(
agent = VisionAgentV2(
verbose=True,
update_callback=update_callback,
)
Expand All @@ -46,7 +47,17 @@ def process_messages_background(messages: List[Dict[str, Any]]):
for message in messages:
if "media" in message and message["media"] is None:
del message["media"]
response = agent.generate_code(messages)

response = agent.chat(
[
AgentMessage(
role=message["role"],
content=message["content"],
media=message.get("media", None),
)
for message in messages
]
)
# Here you can handle the response, e.g., send it via WebSocket or store it
# For now, we'll just print it
print("Background task completed:", response)
Expand Down
18 changes: 18 additions & 0 deletions examples/chat/chat-app/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.PHONY: all
all: setup

.PHONY: add-components
add-components:
npx shadcn@latest add button card scroll-area tabs
npx shadcn@latest add collapsible

# Target to install dependencies using package-lock.json
.PHONY: install-dependencies
install-dependencies:
npm install --legacy-peer-deps react-syntax-highlighter
npm config set legacy-peer-deps true
npm ci

# Setup target to run all necessary commands
.PHONY: setup
setup: add-components install-dependencies
218 changes: 109 additions & 109 deletions examples/chat/chat-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/chat/chat-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {
"@radix-ui/react-collapsible": "^1.1.1",
"@radix-ui/react-scroll-area": "^1.2.0",
"@radix-ui/react-scroll-area": "^1.2.1",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-tabs": "^1.1.1",
"class-variance-authority": "^0.7.0",
Expand Down
Loading

0 comments on commit add011d

Please sign in to comment.