Skip to content

Commit

Permalink
rename to jwt
Browse files Browse the repository at this point in the history
  • Loading branch information
siyangqiu committed May 16, 2024
1 parent e0faa85 commit 87b3acf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions agentops/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, config: Configuration) -> None:
self.thread.daemon = True
self.thread.start()
self._session: Optional[Session] = None
self.jwt_token = None
self.jwt = None

def add_event(self, event: dict) -> None:
with self.lock:
Expand All @@ -41,7 +41,7 @@ def flush_queue(self) -> None:
serialized_payload = safe_serialize(payload).encode("utf-8")
HttpClient.post(f'{self.config.endpoint}/v2/create_events',
serialized_payload,
jwt_token=self.jwt_token)
jwt_token=self.jwt)

logger.debug("\n<AGENTOPS_DEBUG_OUTPUT>")
logger.debug(f"Worker request to {self.config.endpoint}/events")
Expand All @@ -65,8 +65,8 @@ def start_session(self, session: Session) -> bool:
if res.code != 200:
return False

self.jwt_token = res.body.get('token', None)
if self.jwt_token is None:
self.jwt = res.body.get('jwt', None)
if self.jwt is None:
return False

return True
Expand All @@ -85,7 +85,7 @@ def end_session(self, session: Session) -> str:
res = HttpClient.post(f'{self.config.endpoint}/v2/update_session',
json.dumps(filter_unjsonable(
payload)).encode("utf-8"),
jwt_token=self.jwt_token)
jwt_token=self.jwt)
logger.debug(res.body)
return res.body.get('token_cost', "unknown")

Expand All @@ -98,7 +98,7 @@ def update_session(self, session: Session) -> None:
res = HttpClient.post(f'{self.config.endpoint}/v2/update_session',
json.dumps(filter_unjsonable(
payload)).encode("utf-8"),
jwt_token=self.jwt_token)
jwt_token=self.jwt)

def create_agent(self, agent_id, name):
payload = {
Expand All @@ -111,7 +111,7 @@ def create_agent(self, agent_id, name):
safe_serialize(payload).encode("utf-8")
HttpClient.post(f'{self.config.endpoint}/v2/create_agent',
serialized_payload,
jwt_token=self.jwt_token)
jwt_token=self.jwt)

def run(self) -> None:
while not self.stop_flag.is_set():
Expand Down

0 comments on commit 87b3acf

Please sign in to comment.