From 54deaccc6fbcba7b7b86c91ed1a43581f6c3d495 Mon Sep 17 00:00:00 2001 From: Kye Date: Sat, 9 Dec 2023 20:01:33 -0800 Subject: [PATCH] [docs/swarms/utils/phoenix_tracer.md] --- mkdocs.yml | 2 + .../demos/optimize_llm_stack/omni_agent.py | 38 +++++++++++++++++++ swarms/utils/__init__.py | 6 +++ 3 files changed, 46 insertions(+) create mode 100644 playground/demos/optimize_llm_stack/omni_agent.py diff --git a/mkdocs.yml b/mkdocs.yml index 210e6426..69b13d21 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -105,6 +105,8 @@ nav: - Weaviate: "swarms/memory/weaviate.md" - PineconeVectorStoreStore: "swarms/memory/pinecone.md" - PGVectorStore: "swarms/memory/pg.md" + - swarms.utils: + - phoenix_trace_decorator: "swarms/utils/phoenix_tracer.md" - Guides: - Overview: "examples/index.md" - Agents: diff --git a/playground/demos/optimize_llm_stack/omni_agent.py b/playground/demos/optimize_llm_stack/omni_agent.py new file mode 100644 index 00000000..1406c774 --- /dev/null +++ b/playground/demos/optimize_llm_stack/omni_agent.py @@ -0,0 +1,38 @@ +import os +from swarms.structs import Agent +from swarms.memory import WeaviateClient +from swarms.utils.phoenix_handler import phoenix_trace_decorator +from swarms.models.vllm import vLLM +from dotenv import load_dotenv + +load_dotenv() + + +# Model +llm = vLLM() + +# Weaviate +weaviate_client = WeaviateClient( + http_host="localhost", + http_port="8080", + http_secure=False, + grpc_host="localhost", + grpc_port="8081", + grpc_secure=False, + auth_client_secret="YOUR_APIKEY", + additional_headers={"X-OpenAI-Api-Key": "YOUR_OPENAI_APIKEY"}, + additional_config=None, # You can pass additional configuration here +) + + +# Agent +@phoenix_trace_decorator +@ +def agent(task: str): + agent = Agent( + llm = llm, + max_loops=1, + ) + + out = agent.run(task=task) + return out \ No newline at end of file diff --git a/swarms/utils/__init__.py b/swarms/utils/__init__.py index 8c935f26..f1ac4f06 100644 --- a/swarms/utils/__init__.py +++ b/swarms/utils/__init__.py @@ -5,9 +5,15 @@ from swarms.utils.parse_code import ( ) from swarms.utils.pdf_to_text import pdf_to_text +try: + from swarms.utils.phoenix_handler import phoenix_trace_decorator +except ImportError: + pass + __all__ = [ "display_markdown_message", "SubprocessCodeInterpreter", "extract_code_in_backticks_in_string", "pdf_to_text", + "phoenix_trace_decorator" ]