Skip to content

Commit

Permalink
activate time travel (#351)
Browse files Browse the repository at this point in the history
* activate time travel

* fix output

* update openai-gpt notebook

* organization

* undo organization

* reformatting to please the CI/CD gods

* clear outputs

* imports
  • Loading branch information
siyangqiu authored Aug 14, 2024
1 parent aa79056 commit f142093
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
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 @@ 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)
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 __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": {
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"

0 comments on commit f142093

Please sign in to comment.