Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…lkit into main
  • Loading branch information
ynvygy committed Jan 21, 2025
2 parents 420bc20 + 2fda3b8 commit 4d45071
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 52 deletions.
4 changes: 2 additions & 2 deletions src/agents/react_agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ async def call_model(

# Initialize the model with tool binding. Change the model or add more tools here.
try:
model = load_chat_model("openai/gpt-4-turbo-preview").bind_tools(TOOLS)
model = load_chat_model("openai/gpt-4o").bind_tools(TOOLS)
except ValueError as e:
print(f"Error loading model: {e}")
# Fallback to a default model if the configured one fails
model = load_chat_model("openai/gpt-4").bind_tools(TOOLS)
model = load_chat_model("openai/gpt-4o").bind_tools(TOOLS)

# Format the system prompt. Customize this to change the agent's behavior.
system_message = configuration.system_prompt.format(
Expand Down
14 changes: 8 additions & 6 deletions src/agents/react_agent/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from composio_langgraph import Action, ComposioToolSet, App

from .configuration import Configuration
import pdb

composio_toolset = ComposioToolSet(
auth = {
Expand All @@ -24,11 +25,12 @@
}
)

composio_tools = composio_toolset.get_tools(
apps=[App.GMAIL, App.TRELLO]
)

print(composio_tools)
gmail = composio_toolset.get_tools(apps=[App.GMAIL])
calendar = composio_toolset.get_tools(apps=[App.GOOGLECALENDAR])
linear = composio_toolset.get_tools(apps=[App.LINEAR])
trello = composio_toolset.get_tools(apps=[App.TRELLO])
twitter = composio_toolset.get_tools(apps=[App.TWITTER])
# pdb.set_trace()

async def search(
query: str, *, config: Annotated[RunnableConfig, InjectedToolArg]
Expand All @@ -46,4 +48,4 @@ async def search(


# Combine the search tool with Composio tools using spread operator
TOOLS: List[Callable[..., Any]] = [search, *composio_tools]
TOOLS: List[Callable[..., Any]] = [search, *gmail, *calendar, *linear, *trello, *twitter]
Binary file added src/assets/assista_logo_grey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 51 additions & 44 deletions src/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,23 @@
# The app heavily uses AgentClient to interact with the agent's FastAPI endpoints.


APP_TITLE = "Agent Service Toolkit"
APP_ICON = "🧰"
APP_TITLE = "Assista Ai Agent"

# Define the path to your PNG file (remove this if not needed)
# PNG_PATH = os.path.join("src", "assets", "assista_logo_grey.png")

async def main() -> None:
st.set_page_config(
page_title=APP_TITLE,
page_icon=APP_ICON,
page_icon=None, # Remove the page icon
menu_items={},
)

# Set the page icon in the browser tab (remove this if not needed)
# st.markdown(
# f'<link rel="icon" href="{PNG_PATH}" type="image/png">',
# unsafe_allow_html=True
# )

# Hide the streamlit upper-right chrome
st.html(
Expand Down Expand Up @@ -83,9 +90,9 @@ async def main() -> None:

# Config options
with st.sidebar:
st.header(f"{APP_ICON} {APP_TITLE}")
st.header(APP_TITLE) # Render the title without the image
""
"Full toolkit for running an AI agent service built with LangGraph, FastAPI and Streamlit"
"Empower Your Workflow Like Never Before With Assista Ai"
with st.popover(":material/settings: Settings", use_container_width=True):
model_idx = agent_client.info.models.index(agent_client.info.default_model)
model = st.selectbox("LLM to use", options=agent_client.info.models, index=model_idx)
Expand All @@ -98,50 +105,50 @@ async def main() -> None:
)
use_streaming = st.toggle("Stream results", value=True)

@st.dialog("Architecture")
def architecture_dialog() -> None:
st.image(
"https://github.com/JoshuaC215/agent-service-toolkit/blob/main/media/agent_architecture.png?raw=true"
)
"[View full size on Github](https://github.com/JoshuaC215/agent-service-toolkit/blob/main/media/agent_architecture.png)"
st.caption(
"App hosted on [Streamlit Cloud](https://share.streamlit.io/) with FastAPI service running in [Azure](https://learn.microsoft.com/en-us/azure/app-service/)"
)

if st.button(":material/schema: Architecture", use_container_width=True):
architecture_dialog()

with st.popover(":material/policy: Privacy", use_container_width=True):
st.write(
"Prompts, responses and feedback in this app are anonymously recorded and saved to LangSmith for product evaluation and improvement purposes only."
)

@st.dialog("Share/resume chat")
def share_chat_dialog() -> None:
session = st.runtime.get_instance()._session_mgr.list_active_sessions()[0]
st_base_url = urllib.parse.urlunparse(
[session.client.request.protocol, session.client.request.host, "", "", "", ""]
)
# if it's not localhost, switch to https by default
if not st_base_url.startswith("https") and "localhost" not in st_base_url:
st_base_url = st_base_url.replace("http", "https")
chat_url = f"{st_base_url}?thread_id={st.session_state.thread_id}"
st.markdown(f"**Chat URL:**\n```text\n{chat_url}\n```")
st.info("Copy the above URL to share or revisit this chat")

if st.button(":material/upload: Share/resume chat", use_container_width=True):
share_chat_dialog()

"[View the source code](https://github.com/JoshuaC215/agent-service-toolkit)"
st.caption(
"Made with :material/favorite: by [Joshua](https://www.linkedin.com/in/joshua-k-carroll/) in Oakland"
)
# @st.dialog("Architecture")
# def architecture_dialog() -> None:
# st.image(
# "https://github.com/JoshuaC215/agent-service-toolkit/blob/main/media/agent_architecture.png?raw=true"
# )
# "[View full size on Github](https://github.com/JoshuaC215/agent-service-toolkit/blob/main/media/agent_architecture.png)"
# st.caption(
# "App hosted on [Streamlit Cloud](https://share.streamlit.io/) with FastAPI service running in [Azure](https://learn.microsoft.com/en-us/azure/app-service/)"
# )

# if st.button(":material/schema: Architecture", use_container_width=True):
# architecture_dialog()

# with st.popover(":material/policy: Privacy", use_container_width=True):
# st.write(
# "Prompts, responses and feedback in this app are anonymously recorded and saved to LangSmith for product evaluation and improvement purposes only."
# )

# @st.dialog("Share/resume chat")
# def share_chat_dialog() -> None:
# session = st.runtime.get_instance()._session_mgr.list_active_sessions()[0]
# st_base_url = urllib.parse.urlunparse(
# [session.client.request.protocol, session.client.request.host, "", "", "", ""]
# )
# # if it's not localhost, switch to https by default
# if not st_base_url.startswith("https") and "localhost" not in st_base_url:
# st_base_url = st_base_url.replace("http", "https")
# chat_url = f"{st_base_url}?thread_id={st.session_state.thread_id}"
# st.markdown(f"**Chat URL:**\n```text\n{chat_url}\n```")
# st.info("Copy the above URL to share or revisit this chat")

# if st.button(":material/upload: Share/resume chat", use_container_width=True):
# share_chat_dialog()

# "[View the source code](https://github.com/JoshuaC215/agent-service-toolkit)"
# st.caption(
# "Made with :material/favorite: by [Joshua](https://www.linkedin.com/in/joshua-k-carroll/) in Oakland"
# )

# Draw existing messages
messages: list[ChatMessage] = st.session_state.messages

if len(messages) == 0:
WELCOME = "Hello! I'm an AI-powered research assistant with web search and a calculator. Ask me anything!"
WELCOME = "Hello! I'm an AI-powered assistant with web search and a lot of tools. Ask me anything!"
with st.chat_message("ai"):
st.write(WELCOME)

Expand Down

0 comments on commit 4d45071

Please sign in to comment.