Skip to content

Commit

Permalink
beta-v1
Browse files Browse the repository at this point in the history
beta release
  • Loading branch information
mabry1985 authored Nov 5, 2023
2 parents cb60085 + 7612f62 commit dbb4ef6
Show file tree
Hide file tree
Showing 210 changed files with 5,040 additions and 4,414 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ dist-ssr
*.njsproj
*.sln
*.sw?
.env
.env
OAI_CONFIG_LIST.json
cache.db
dev-dist
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ We welcome your contributions. To make the process as seamless as possible, we a

- When you’re ready to create a pull request, be sure to:

- Have test cases for the new code. If you have questions about how to do it, please ask in your pull request.
- Have test cases for new code. If you have questions about how to do it, please ask in your pull request.

- Run all the tests to ensure nothing else was accidentally broken.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pnpm install
pnpm run dev
```

Open [http://localhost:5173](http://localhost:5173) to view it in the browser.
Open [http://localhost:5173](http://localhost:5173) to view in the browser.

## Contributing

Expand Down
33 changes: 32 additions & 1 deletion db.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// db.ts
import Dexie, { Table } from 'dexie';
import { ACDoc, Workspace, AgentWorkspace } from './src/state';

export interface AcaiMemoryVector {
content: string;
Expand All @@ -9,7 +10,8 @@ export interface AcaiMemoryVector {
export interface Knowledge {
id: string;
workspaceId: string;
file: File;
fileId: string;
fileName: string;
fileType: 'pdf' | 'md' | 'txt';
fullText: string;
createdAt: string;
Expand All @@ -20,17 +22,46 @@ export interface Knowledge {
tags?: string[];
}

export interface ACFile {
id: string;
workspaceId: string;
file: File;
fileType: 'pdf' | 'md' | 'txt' | 'html';
fileName: string;
createdAt: string;
lastModified: string;
}

export class AcaiDexie extends Dexie {
// 'embeddings' is added by dexie when declaring the stores()
// We just tell the typing system this is the case
knowledge!: Table<Knowledge>;
workspaces!: Table<Workspace>;
docs!: Table<ACDoc>;
agents!: Table<AgentWorkspace>;
files!: Table<ACFile>;

constructor() {
super('acaiDb');
this.version(1).stores({
knowledge:
'++id, workspaceId, file, fileType, fullText, createdAt, lastModified, memoryVectors, summary, title, tags',
});
this.version(2).stores({
workspaces: '++id, name, createdAt, lastUpdated, private',
docs: '++id, workspaceId, title, filetype, content, isContext, systemNote, createdAt, lastUpdated, autoSave, canEdit',
});
this.version(3).stores({
agents:
'++id, loading, agentMode, agentName, workspaceId, customPrompt, recentChatHistory, openAIChatModel, returnRagResults, customAgentVectorSearch, agentLogs, memory, agentTools',
files: '++id, workspaceId, file, createdAt, lastModified',
});

this.knowledge = this.table('knowledge');
this.workspaces = this.table('workspaces');
this.agents = this.table('agents');
this.docs = this.table('docs');
this.files = this.table('files');
}
}

Expand Down
102 changes: 102 additions & 0 deletions examples/python_agent_server/autogen-example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import requests
from flask import Flask, request, jsonify
from flask_socketio import SocketIO, emit
from flask_cors import CORS

from autogen import AssistantAgent, UserProxyAgent, config_list_from_json, Agent

# existing code...
app = Flask(__name__)
CORS(app)
app.config["SECRET_KEY"] = "your_secret_key"
CORS(
app,
origins=["http://192.168.4.74:5173", "http://localhost:5173", "http://www.acai.so"],
)
socketio = SocketIO(
app,
cors_allowed_origins=[
"http://192.168.4.74:5173",
"http://localhost:5173",
"http://www.acai.so",
],
)


import json


def print_messages(recipient, messages, sender, config):
if "callback" in config and config["callback"] is not None:
callback = config["callback"]
callback(sender, recipient, messages[-1])

last_message = messages[-1]
content = last_message.get("content", "No content")
role = last_message.get("role", "No role")

if "TERMINATE" in content:
socketio.emit("info-toast", {"info": f"{content} | {role} | {sender.name}"})

# Format messages to match OpenAI chat endpoint
formatted_messages = [
{
"role": msg.get("role", "No role"),
"content": msg.get("content", "No content"),
}
for msg in messages
]
messages_json_str = json.dumps(formatted_messages)
socketio.emit(
"create-tab", {"title": "Autogen Logs", "content": messages_json_str}
)

print(
f"Messages sent to: {recipient.name} | num messages: {len(messages)} | {content} | {role} | {sender.name}"
)
return False, None # required to ensure the agent communication flow continues


# Load LLM inference endpoints from an env variable or a file
# See https://microsoft.github.io/autogen/docs/FAQ#set-your-api-endpoints
# and OAI_CONFIG_LIST_sample.json
config_list = config_list_from_json(
env_or_file="./OAI_CONFIG_LIST.json", file_location="."
)
assistant = AssistantAgent(
"assistant", human_input_mode="NEVER", llm_config={"config_list": config_list}
)
user_proxy = UserProxyAgent(
"user_proxy",
human_input_mode="NEVER",
max_consecutive_auto_reply=1,
code_execution_config={"work_dir": "coding"},
)
user_proxy.register_reply(
[Agent, None],
reply_func=print_messages,
config={"callback": None},
)

assistant.register_reply(
[Agent, None],
reply_func=print_messages,
config={"callback": None},
)


@app.route("/test", methods=["GET"])
def test():
return "Hello world"


@app.route("/autogen", methods=["GET"])
def autogen():
agent_payload = request.get_json()
user_message = agent_payload.get("userMessage")
user_proxy.initiate_chat(assistant, message=user_message)
return f"Finished autogen process"


if __name__ == "__main__":
socketio.run(app, host="0.0.0.0", port=7050)
3 changes: 3 additions & 0 deletions examples/python_agent_server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ def agent():
socketio.emit(
"create-tab", {"title": "Hello Tab!", "content": formatted_payload}
)
socketio.emit(
"info-toast", {"info": "We are sending a toast from the server side!"}
)

return jsonify({"response": "Hello from the server side..."}), 200

Expand Down
5 changes: 4 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/png" href="/favicon.ico" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
/>
<title>acai.so</title>
</head>
<body>
Expand Down
25 changes: 6 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
"dependencies": {
"@chatscope/chat-ui-kit-react": "^1.10.1",
"@chatscope/chat-ui-kit-styles": "^1.4.0",
"@google-cloud/text-to-speech": "^4.2.2",
"@pinecone-database/pinecone": "^0.1.5",
"@storybook/theming": "^7.0.10",
"@supabase/supabase-js": "^2.31.0",
"@tiptap/core": "^2.0.3",
"@tiptap/extension-color": "^2.0.3",
Expand All @@ -48,35 +46,29 @@
"bottleneck": "^2.19.5",
"cheerio": "1.0.0-rc.12",
"classnames": "^2.3.2",
"clsx": "^1.2.1",
"d3": "^7.8.5",
"dexie": "^3.2.4",
"dexie-react-hooks": "^1.1.6",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"flowbite": "^1.8.1",
"flowbite-react": "^0.5.0",
"js-yaml": "^4.1.0",
"jszip": "^3.10.1",
"langchain": "^0.0.150",
"linkify-react": "^4.1.1",
"linkifyjs": "^4.1.1",
"lodash.isequal": "^4.5.0",
"lucide-react": "^0.257.0",
"openai": "^3.3.0",
"pdf-parse": "^1.1.1",
"qs": "^6.11.2",
"react": "^18.2.0",
"react-audio-voice-recorder": "^1.2.1",
"react-dom": "^18.2.0",
"react-draggable": "^4.4.5",
"react-hotkeys": "^2.0.0",
"react-markdown": "^8.0.5",
"react-modal": "^3.16.1",
"react-moveable": "^0.55.0",
"react-pdf": "^7.3.3",
"react-router-dom": "^6.14.1",
"react-simple-pull-to-refresh": "^1.3.3",
"react-tabs": "^6.0.1",
"react-toastify": "^9.1.3",
"remark-footnotes": "^4.0.1",
"socket.io": "^4.6.2",
"socket.io-client": "^4.6.2",
"tippy.js": "^6.3.7",
"tiptap-markdown": "^0.8.1",
Expand All @@ -85,21 +77,16 @@
"use-debounce": "^9.0.3",
"uuid": "^9.0.0",
"xstate": "^4.37.2",
"youtube-transcript": "^1.0.6",
"zod": "^3.21.4"
"youtube-transcript": "^1.0.6"
},
"devDependencies": {
"@types/d3": "^7.4.0",
"@types/express": "^4.17.17",
"@types/js-yaml": "^4.0.5",
"@types/lodash.isequal": "^4.5.6",
"@types/marked": "^5.0.0",
"@types/node": "^20.1.4",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@types/react-linkify": "^1.0.1",
"@types/react-modal": "^3.16.2",
"@types/react-test-renderer": "^18.0.0",
"@types/regenerator-runtime": "^0.13.1",
"@typescript-eslint/eslint-plugin": "^5.57.1",
"@typescript-eslint/parser": "^5.57.1",
"@vitejs/plugin-react": "^4.0.0",
Expand Down
Loading

0 comments on commit dbb4ef6

Please sign in to comment.