Skip to content

Commit

Permalink
Init agent-api
Browse files Browse the repository at this point in the history
  • Loading branch information
ashpreetbedi committed Oct 15, 2024
1 parent f4bf795 commit 83cc53a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions agents/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def get_example_agent(
description="You are a highly advanced AI agent with access to an extensive knowledge base and powerful web-search capabilities.",
# A list of instructions to follow, each as a separate item in the list
instructions=[
"Use your knowledge base first.\n"
" - Always search your internal knowledge base before seeking external information.\n"
"Always search your knowledge base first.\n"
" - Search your knowledge base before seeking external information.\n"
" - Provide answers based on your existing knowledge whenever possible.",
"Then search the web if no information is found in your knowledge base.\n"
" - If the information is not available in your knowledge base, use `duckduckgo_search` to find relevant information.",
Expand Down
28 changes: 15 additions & 13 deletions app/Home.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,18 @@ def main() -> None:
if message.get("role") in ["system", "tool"]:
continue
# Display the message
with st.chat_message(message.get("role")):
content = message.get("content")
if isinstance(content, list):
for item in content:
if item["type"] == "text":
st.write(item["text"])
elif item["type"] == "image_url":
st.image(item["image_url"]["url"], use_column_width=True)
else:
st.write(content)
message_role = message.get("role")
if message_role is not None:
with st.chat_message(message_role):
content = message.get("content")
if isinstance(content, list):
for item in content:
if item["type"] == "text":
st.write(item["text"])
elif item["type"] == "image_url":
st.image(item["image_url"]["url"], use_column_width=True)
else:
st.write(content)

# If last message is from a user, generate a new response
last_message = st.session_state["messages"][-1]
Expand Down Expand Up @@ -229,9 +231,9 @@ def main() -> None:
alert.empty()

if example_agent.knowledge.vector_db:
if st.sidebar.button("Clear Knowledge Base"):
example_agent.knowledge.vector_db.clear()
st.sidebar.success("Knowledge base cleared")
if st.sidebar.button("Delete Knowledge Base"):
example_agent.knowledge.vector_db.delete()
st.sidebar.success("Knowledge base deleted")

if example_agent.storage:
example_agent_session_ids: List[str] = example_agent.storage.get_all_session_ids()
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ dependencies = [
"tiktoken",
"typer",
"types-Pillow",
"yfinance",
]

[build-system]
Expand Down

0 comments on commit 83cc53a

Please sign in to comment.