diff --git a/agentops/cli.py b/agentops/cli.py index 29b9e90b..562c8053 100644 --- a/agentops/cli.py +++ b/agentops/cli.py @@ -32,10 +32,6 @@ def main(): if args.branch_name: fetch_time_travel_id(args.branch_name) if args.on: - set_time_travel_active_state("on") + set_time_travel_active_state(True) if args.off: - set_time_travel_active_state("off") - - -if __name__ == "__main__": - main() + set_time_travel_active_state(False) diff --git a/agentops/time_travel.py b/agentops/time_travel.py index a6de34b3..5b3b9a6f 100644 --- a/agentops/time_travel.py +++ b/agentops/time_travel.py @@ -1,10 +1,9 @@ import json import yaml +import os from .http_client import HttpClient from .exceptions import ApiServerException -import os from .helpers import singleton -from os import environ @singleton @@ -32,13 +31,10 @@ def __init__(self): def fetch_time_travel_id(ttd_id): try: - endpoint = environ.get("AGENTOPS_API_ENDPOINT", "https://api.agentops.ai") - payload = json.dumps({"ttd_id": ttd_id}).encode("utf-8") + endpoint = os.environ.get("AGENTOPS_API_ENDPOINT", "https://api.agentops.ai") ttd_res = HttpClient.get(f"{endpoint}/v2/ttd/{ttd_id}") if ttd_res.code != 200: - raise Exception( - f"Failed to fetch TTD with status code {ttd_res.status_code}" - ) + raise Exception(f"Failed to fetch TTD with status code {ttd_res.code}") prompt_to_returns_map = { "completion_overrides": { diff --git a/examples/openai-gpt.ipynb b/examples/openai-gpt.ipynb index 613880ab..09cf5ac3 100644 --- a/examples/openai-gpt.ipynb +++ b/examples/openai-gpt.ipynb @@ -130,10 +130,11 @@ }, "outputs": [], "source": [ - "message = ({\"role\": \"user\", \"content\": \"Write a 12 word poem about secret agents.\"},)\n", + "message = [{\"role\": \"user\", \"content\": \"Write a 12 word poem about secret agents.\"}]\n", "res = openai.chat.completions.create(\n", - " model=\"gpt-3.5-turbo\", messages=message, temperature=0.5, stream=True\n", - ")" + " model=\"gpt-3.5-turbo\", messages=message, temperature=0.5, stream=False\n", + ")\n", + "print(res.choices[0].message[\"content\"])" ] }, { @@ -282,7 +283,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.3" + "version": "3.12.4" } }, "nbformat": 4, diff --git a/pyproject.toml b/pyproject.toml index 2680e070..dc3b88d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,3 +41,6 @@ Issues = "https://github.com/AgentOps-AI/agentops/issues" [tool.autopep8] max_line_length = 120 + +[project.scripts] +agentops = "agentops.cli:main"