Skip to content

Commit

Permalink
Merge branch 'main' of github.com:l3vels/L3AGI
Browse files Browse the repository at this point in the history
  • Loading branch information
Chkhikvadze committed Nov 29, 2023
2 parents 04a87a1 + b7cbf8b commit f67d969
Show file tree
Hide file tree
Showing 49 changed files with 491 additions and 279 deletions.
28 changes: 0 additions & 28 deletions .github/workflows/deploy_zep.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
from typing import List

from langchain.agents import AgentType, initialize_agent
from langchain.chat_models import ChatOpenAI
from langchain.memory import ConversationBufferMemory
from langchain.schema import (
AIMessage,
)
from langchain.schema import AIMessage, SystemMessage

from agents.agent_simulations.agent.dialogue_agent import DialogueAgent
from langchain.agents import initialize_agent
from langchain.agents import AgentType
from langchain.schema import (
SystemMessage,
)
from typings.agent import AgentWithConfigsOutput
from memory.zep.zep_memory import ZepMemory
from agents.conversational.output_parser import ConvoOutputParser
from config import Config
from memory.zep.zep_memory import ZepMemory
from typings.agent import AgentWithConfigsOutput


class DialogueAgentWithTools(DialogueAgent):
Expand Down Expand Up @@ -68,6 +65,7 @@ def send(self) -> str:
memory=memory,
agent_kwargs={
"system_message": self.system_message.content,
"output_parser": ConvoOutputParser(),
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,8 @@ def generate_character_header(
return f"""{game_description}
Your name is {character_name}.
Your role is: {role}
You are a speaker.
You are speaking on the topic: {topic}.
Your goal is to be as creative as possible and speak in the style of {character_name}.
Your goal is to accomplish tasks.
Here is task or topic: {topic}.
"""

# def generate_character_system_message(
Expand All @@ -171,14 +170,14 @@ def generate_character_header(
# )
# )

def generate_character_bidding_template(self, header: str):
def generate_character_bidding_template(self, header: str, name: str, role: str):
bidding_template = f"""{header}
```
{{message_history}}
```
On the scale of 1 to 10, where 1 is not contradictory and 10 is extremely contradictory, rate how contradictory the following message is to your ideas.
In the context of {name}, On the scale of 1 to 10, where 1 is not relevant and 10 is extremely relevant, rate how relevant are you to accomplish task.
```
{{recent_message}}
Expand Down Expand Up @@ -234,7 +233,7 @@ def run(
)

bidding_template = self.generate_character_bidding_template(
character_header
character_header, name, agent_with_configs.agent.role
)

# character_system_message = self.generate_character_system_message(
Expand All @@ -257,7 +256,7 @@ def run(
)
)

max_iters = 10
max_iters = 1

n = 0

Expand Down
30 changes: 15 additions & 15 deletions apps/server/controllers/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,21 @@ def get_team_type(auth: UserAccount = Depends(authenticate)) -> List[object]:
"""

return [
{
"is_public": True,
"is_active": True,
"name": "Decentralized Speaker",
"description": "This notebook showcases how to implement a multi-agent simulation where a privileged agent decides who to speak",
"team_type": TeamOfAgentsType.DECENTRALIZED_SPEAKER,
"fields": [],
"agents": [
{"id": 1, "role": "Speaker"},
{"id": 2, "role": "Speaker"},
{"id": 3, "role": "Speaker"},
{"id": 4, "role": "Speaker"},
{"id": 5, "role": "Speaker"},
],
},
{
"is_public": True,
"is_active": True,
Expand Down Expand Up @@ -228,21 +243,6 @@ def get_team_type(auth: UserAccount = Depends(authenticate)) -> List[object]:
"fields": [],
"agents": [{"id": 1, "role": "Planner"}, {"id": 2, "role": "Executor"}],
},
{
"is_public": True,
"is_active": True,
"name": "Decentralized Speaker",
"description": "This notebook showcases how to implement a multi-agent simulation where a privileged agent decides who to speak",
"team_type": TeamOfAgentsType.DECENTRALIZED_SPEAKER,
"fields": [],
"agents": [
{"id": 1, "role": "Speaker"},
{"id": 2, "role": "Speaker"},
{"id": 3, "role": "Speaker"},
{"id": 4, "role": "Speaker"},
{"id": 5, "role": "Speaker"},
],
},
]


Expand Down
2 changes: 1 addition & 1 deletion apps/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def root():
return f"Server is running on {Config.ENV} environment"


print("Server is running on port 4000")
print("Server is running on 4000 port")

if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=4000)
1 change: 1 addition & 0 deletions apps/server/models/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ def get_chats(cls, db, account):
.outerjoin(AccountModel, ChatModel.creator_account_id == AccountModel.id)
.outerjoin(TeamModel, ChatModel.team_id == TeamModel.id)
.outerjoin(AgentModel, ChatModel.agent_id == AgentModel.id)
.order_by(ChatModel.created_on.desc())
.filter(
ChatModel.creator_account_id == account.id,
or_(
Expand Down
8 changes: 5 additions & 3 deletions apps/server/tools/cal/cal_booking_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CalBookingTool(BaseTool):
def _run(
self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None
) -> str:
api = os.environ.get("CALCOM_API")
base_url = "https://api.cal.com/v1"
cal_api_key = self.get_env_key("CALCOM_API_KEY")
cal_username = self.get_env_key("CALCOM_USERNAME")

Expand All @@ -70,7 +70,9 @@ def _run(
duration = action.get("duration")

try:
res = requests.get(f"{api}/event-types", params={"apiKey": cal_api_key})
res = requests.get(
f"{base_url}/event-types", params={"apiKey": cal_api_key}
)
event_types = res.json().get("event_types", [])
if not event_types:
raise ToolException(
Expand All @@ -93,7 +95,7 @@ def _run(

try:
response = requests.post(
f"{api}/bookings",
f"{base_url}/bookings",
params={"apiKey": cal_api_key},
json={
"eventTypeId": duration,
Expand Down
4 changes: 2 additions & 2 deletions apps/server/tools/cal/cal_get_available_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CalGetAvailableDatesTool(BaseTool):
def _run(
self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None
) -> str:
api = os.environ.get("CALCOM_API")
base_url = "https://api.cal.com/v1"
cal_api_key = self.get_env_key("CALCOM_API_KEY")
cal_username = self.get_env_key("CALCOM_USERNAME")

Expand All @@ -69,7 +69,7 @@ def _run(
dateFrom = datetime.strptime(dates["dateFrom"], "%d/%m/%Y").timestamp()
dateTo = datetime.strptime(dates["dateTo"], "%d/%m/%Y").timestamp()
try:
api = f"{api}/availability"
api = f"{base_url}/availability"
response = requests.get(
api,
params={
Expand Down
76 changes: 56 additions & 20 deletions apps/server/tools/zapier/zapier_send.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import json
import os
from typing import Optional, Type

from langchain.agents import AgentType, initialize_agent
from langchain.agents.agent_toolkits import ZapierToolkit
import requests
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.utilities.zapier import ZapierNLAWrapper
from pydantic import BaseModel, Field

from exceptions import ToolEnvKeyException
from exceptions import ToolEnvKeyException, ToolException
from tools.base import BaseTool
from utils.model import get_llm


class ZapierSendSchema(BaseModel):
query: str = Field(
...,
description="use zapier",
description=(
"Your task is to process a JSON string representing an instruction-related query for a specific action.\n"
"Extract the 'instructions' field from the JSON, containing clear, human-readable instructions.\n"
"Retrieve the 'action_id' separately if provided by the user; if not, set it as an empty string.\n"
"Ensure 'action_id' is not included inside the 'instructions' field in the returned JSON.\n"
),
)


Expand All @@ -25,7 +29,12 @@ class ZapierSendTool(BaseTool):

slug = "zapierSend"

description = "use zapier"
description = (
"Your task is to process a JSON string representing an instruction-related query for a specific action.\n"
"Extract the 'instructions' field from the JSON, containing clear, human-readable instructions.\n"
"Retrieve the 'action_id' separately if provided by the user; if not, set it as an empty string.\n"
"Ensure 'action_id' is not included inside the 'instructions' field in the returned JSON.\n"
)

args_schema: Type[ZapierSendSchema] = ZapierSendSchema

Expand All @@ -35,23 +44,50 @@ def _run(
self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None
) -> str:
"""Send Zapier and return the results."""
base_url = "https://actions.zapier.com/api/v1"
zapier_nla_api_key = self.get_env_key("ZAPIER_NLA_API_KEY")

if not zapier_nla_api_key:
raise ToolEnvKeyException(
"Please fill Zapier API Key in the [Zapier Toolkit](/toolkits/zapier)"
)

llm = get_llm(
self.settings,
self.agent_with_configs,
)
zapier = ZapierNLAWrapper(zapier_nla_api_key=zapier_nla_api_key)
toolkit = ZapierToolkit.from_zapier_nla_wrapper(zapier)
agent = initialize_agent(
toolkit.get_tools(),
llm,
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
verbose=True,
)
return agent.run(query)
data = json.loads(query)
try:
response = requests.get(
f"{base_url}/exposed/", params={"api_key": zapier_nla_api_key}
)

result = response.json().get("results")
if not result:
raise ToolException(
"Please set up at least one Zap in the [Zapier Dashboard](https://zapier.com/app/dashboard)"
)

action_id = next(
(
result_item.get("id")
for result_item in result
if result_item.get("id") == data.get("action_id")
),
None,
)
if not action_id:
error = "Action with provided 'id' not found, Here is your available actions that you can use with Zapier Integration:\n"
for result_item in result:
error += f'- {result_item["id"]} | {result_item["description"]}\n'

raise ToolException(error)

executionResponse = requests.post(
f"{base_url}/exposed/{action_id}/execute/",
params={"api_key": zapier_nla_api_key},
json={
"instructions": data.get("instructions"),
"preview_only": False,
},
)

return str(executionResponse.json())
except Exception as e:
raise ToolException(str(e))
2 changes: 1 addition & 1 deletion apps/server/utils/configs/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"naming": {
"home": "Home",
"agent": "Agent",
"team": "Team",
"team": "Multi-Agent",
"datasource": "Knowledge",
"model": "Model",
"discovery": "Discovery",
Expand Down
1 change: 1 addition & 0 deletions apps/ui/.env.develop
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ REACT_APP_TWITTER_LINK=https://twitter.com/l3velshq
REACT_APP_YOUTUBE_LINK=https://www.youtube.com/@L3AGI

REACT_APP_YOUTUBE_VIDEO_ID=i84RodECglM
REACT_APP_YOUTUBE_VIDEO_DATA_SOURCE_ID=Fza4gHP_M3o

REACT_APP_TERMS_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/terms.md
REACT_APP_PRIVACY=https://github.com/l3vels/L3AGI/blob/main/docs/privacy.md
Expand Down
2 changes: 2 additions & 0 deletions apps/ui/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ REACT_APP_TWITTER_LINK=https://twitter.com/l3velshq
REACT_APP_YOUTUBE_LINK=https://www.youtube.com/@L3AGI

REACT_APP_YOUTUBE_VIDEO_ID=i84RodECglM
REACT_APP_YOUTUBE_VIDEO_DATA_SOURCE_ID=Fza4gHP_M3o


REACT_APP_TERMS_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/terms.md
REACT_APP_PRIVACY=https://github.com/l3vels/L3AGI/blob/main/docs/privacy.md
Expand Down
2 changes: 2 additions & 0 deletions apps/ui/.env.production
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ REACT_APP_TWITTER_LINK=https://twitter.com/l3velshq
REACT_APP_YOUTUBE_LINK=https://www.youtube.com/@L3AGI

REACT_APP_YOUTUBE_VIDEO_ID=i84RodECglM
REACT_APP_YOUTUBE_VIDEO_DATA_SOURCE_ID=Fza4gHP_M3o


REACT_APP_TERMS_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/terms.md
REACT_APP_PRIVACY=https://github.com/l3vels/L3AGI/blob/main/docs/privacy.md
Expand Down
1 change: 1 addition & 0 deletions apps/ui/src/@types/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface ImportMetaEnv {
readonly REACT_APP_TWITTER_LINK: string
readonly REACT_APP_YOUTUBE_LINK: string
readonly REACT_APP_YOUTUBE_VIDEO_ID: string
readonly REACT_APP_YOUTUBE_VIDEO_DATA_SOURCE_ID: string
readonly REACT_APP_TERMS_LINK: string
readonly REACT_APP_PRIVACY: string
readonly REACT_APP_BASICS_LINK: string
Expand Down
2 changes: 2 additions & 0 deletions apps/ui/src/Route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import VoiceView from 'plugins/contact/pages/Voice/VoiceView'
import VoiceModal from 'modals/VoiceModal'
import ImportContacts from 'plugins/contact/pages/Contact/ImportContacts'
import CallLogsModal from 'modals/CallLogsModal'
import VideoModal from 'modals/VideoModal'

const Route = () => {
const { loading } = useContext(AuthContext)
Expand Down Expand Up @@ -379,6 +380,7 @@ const Route = () => {
<ScheduleRunModal />
<RunLogsModal />
<CallLogsModal />
<VideoModal />

<CommandMenu
open={cmdkOpen}
Expand Down
Binary file added apps/ui/src/assets/images/fitebase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/ui/src/assets/images/googleAnalytics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f67d969

Please sign in to comment.