Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

activate time travel #351

Merged
merged 8 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions agentops/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
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)

Check warning on line 35 in agentops/cli.py

View check run for this annotation

Codecov / codecov/patch

agentops/cli.py#L35

Added line #L35 was not covered by tests
if args.off:
set_time_travel_active_state("off")


if __name__ == "__main__":
main()
set_time_travel_active_state(False)

Check warning on line 37 in agentops/cli.py

View check run for this annotation

Codecov / codecov/patch

agentops/cli.py#L37

Added line #L37 was not covered by tests
10 changes: 3 additions & 7 deletions agentops/time_travel.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -32,13 +31,10 @@

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")

Check warning on line 34 in agentops/time_travel.py

View check run for this annotation

Codecov / codecov/patch

agentops/time_travel.py#L34

Added line #L34 was not covered by tests
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}")

Check warning on line 37 in agentops/time_travel.py

View check run for this annotation

Codecov / codecov/patch

agentops/time_travel.py#L37

Added line #L37 was not covered by tests

prompt_to_returns_map = {
"completion_overrides": {
Expand Down
9 changes: 5 additions & 4 deletions examples/openai-gpt.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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\"])"
]
},
{
Expand Down Expand Up @@ -282,7 +283,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ Issues = "https://github.com/AgentOps-AI/agentops/issues"

[tool.autopep8]
max_line_length = 120

[project.scripts]
agentops = "agentops.cli:main"
Loading