Skip to content

Commit

Permalink
ui updates - automode logic
Browse files Browse the repository at this point in the history
  • Loading branch information
bigsk1 committed Jul 9, 2024
1 parent 9598fec commit 3cb3b0c
Show file tree
Hide file tree
Showing 10 changed files with 4,877 additions and 7,634 deletions.
6 changes: 5 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
ANTHROPIC_API_KEY=sk-

SEARCH_PROVIDER=SEARXNG # or TAVILY
# TAVILY or SEARXNG
SEARCH_PROVIDER=SEARXNG

# Number of search results in ui back at a time
SEARXNG_RESULTS=5

SEARXNG_URL=http://192.168.1.10:4000

Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Claude Plus is an advanced AI-powered development assistant that combines the capabilities of Anthropic's Claude AI with a suite of development tools. It's designed to help developers with various tasks, from coding to project management, all through an interactive chat interface.


![Claude-plus](https://imagedelivery.net/WfhVb8dSNAAvdXUdMfBuPQ/88df81c1-27b7-4713-1715-228915742600/public)
![Claude-plus](https://imagedelivery.net/WfhVb8dSNAAvdXUdMfBuPQ/a74c4783-5e39-498a-6c43-d53d7dd96c00/public)


## Features
Expand Down Expand Up @@ -100,12 +100,16 @@ Claude Plus offers a powerful suite of features to enhance your development work
- **Code Generation**: Describe the functionality you need, and Claude will generate code snippets or entire files.
- **Debugging Assistance**: Paste error messages or problematic code for Claude to analyze and suggest fixes.

![claude](https://imagedelivery.net/WfhVb8dSNAAvdXUdMfBuPQ/f3e51de7-5b42-4634-6afa-3fda6f5eb500/public)

### 2. File and Image Management

- **File Upload**: Easily upload files for Claude to analyze or work with. All uploaded files are stored in the `projects/uploads` folder.
- **Image Analysis**: Upload images for Claude to describe and analyze, useful for UI/UX discussions or diagram interpretations.
- **Code Review**: Upload your code files for Claude to review, suggest improvements, or explain complex sections. It will not only read your files you add but can modify and even delete if requested.

![claude1](https://imagedelivery.net/WfhVb8dSNAAvdXUdMfBuPQ/ba7d095c-35cb-4a88-7fd0-ed63219e6a00/public)

### 3. Project Structure Management

- **File Explorer**: Use the intuitive file explorer interface to manage your project structure directly in the UI.
Expand All @@ -114,6 +118,9 @@ Claude Plus offers a powerful suite of features to enhance your development work
- **Delete**: Remove unnecessary files or folders to keep your project clean.
- **Real-time Updates**: All changes in the file explorer are immediately reflected in the `projects` folder.


![claude2](https://imagedelivery.net/WfhVb8dSNAAvdXUdMfBuPQ/22834b27-1446-4585-099d-22271bef4c00/public)

### 4. Automode for Autonomous Development

- **Activate Automode**: Enable Claude to work autonomously on complex tasks or entire project setups.
Expand All @@ -122,13 +129,19 @@ Claude Plus offers a powerful suite of features to enhance your development work
- **Progress Tracking**: Monitor Claude's progress as it works through tasks in automode.
- **Sandbox Environment**: All automode operations are confined to the `projects` folder, ensuring safe experimentation.


![claude3](https://imagedelivery.net/WfhVb8dSNAAvdXUdMfBuPQ/3ba31af9-647a-4811-a81c-455179dbda00/public)

### 5. Web Search Integration

- **Integrated Search**: Perform web searches without leaving the chat interface.
- **Multiple Providers**: Choose between SEARXNG (for privacy-focused searches) or Tavily (for AI-enhanced results).
- **Rich Markdown Display**: Search results are presented in a readable, formatted markdown style.
- **Context-Aware Queries**: Claude can perform searches based on your conversation context for more relevant results.

![claude5](https://imagedelivery.net/WfhVb8dSNAAvdXUdMfBuPQ/88df81c1-27b7-4713-1715-228915742600/public)


### 6. Code Execution and Testing (Coming Soon)

- **Secure Sandbox**: Run Python scripts directly within the chat interface.
Expand Down
26 changes: 20 additions & 6 deletions automode_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from anthropic import Anthropic
from pydantic import BaseModel
from fastapi import HTTPException
from config import PROJECTS_DIR, CLAUDE_MODEL


# Set up logging
Expand All @@ -28,18 +29,18 @@
# Initialize Anthropic client
anthropic_client = Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))

CLAUDE_MODEL = os.getenv("CLAUDE_MODEL", "claude-3-5-sonnet-20240620")
PROJECTS_DIR = "projects"
#CLAUDE_MODEL = os.getenv("CLAUDE_MODEL", "claude-3-5-sonnet-20240620")
#PROJECTS_DIR = "projects"

SEARCH_PROVIDER = os.getenv("SEARCH_PROVIDER", "SEARXNG")

class AutomodeRequest(BaseModel):
message: str

class SSEMessage(BaseModel):
event: str
data: str

class AutomodeRequest(BaseModel):
message: str

def create_folder(path):
try:
if not os.path.exists(path):
Expand Down Expand Up @@ -241,7 +242,11 @@ def execute_tool(tool_name, tool_input):
]

async def start_automode_logic(request: AutomodeRequest) -> AsyncGenerator[str, None]:
global automode_progress, automode_messages
try:
automode_progress = 0
automode_messages = []

system_message = """
You are an AI assistant capable of performing software development tasks.
You have access to tools that can create folders and files.
Expand Down Expand Up @@ -301,17 +306,26 @@ async def start_automode_logic(request: AutomodeRequest) -> AsyncGenerator[str,
tool_result = execute_tool(tool_name, tool_input)
assistant_response += f"Used tool: {tool_name}\nResult: {tool_result}\n\n"

automode_messages.append({"role": "assistant", "content": assistant_response})
automode_progress = (i + 1) / max_iterations * 100

logger.debug(f"Progress: {automode_progress}, Messages: {automode_messages}")

yield f"data: {json.dumps({'event': 'message', 'content': assistant_response})}\n\n"
conversation_history.append({"role": "assistant", "content": assistant_response})

if "AUTOMODE_COMPLETE" in assistant_response:
break

conversation_history.append({"role": "assistant", "content": assistant_response})
conversation_history.append({"role": "user", "content": "Continue with the next step if necessary."})

automode_progress = 100
yield f"data: {json.dumps({'event': 'end'})}\n\n"
logger.debug(f"Final Progress: {automode_progress}, Messages: {automode_messages}")

except Exception as e:
logger.error(f"Error in automode: {str(e)}", exc_info=True)
automode_messages.append({"role": "system", "content": f"Error: {str(e)}"})
automode_progress = 100
yield f"data: {json.dumps({'event': 'error', 'content': str(e)})}\n\n"
raise HTTPException(status_code=500, detail=str(e))
Loading

0 comments on commit 3cb3b0c

Please sign in to comment.