Skip to content

Commit

Permalink
docs: add required id field to event payloads and update test examples
Browse files Browse the repository at this point in the history
Co-Authored-By: Alex Reibman <[email protected]>
  • Loading branch information
devin-ai-integration[bot] and areibman committed Dec 19, 2024
1 parent b708200 commit ad98c3b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
8 changes: 6 additions & 2 deletions docs/v1/integrations/rest.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ curl -X POST https://api.agentops.ai/v2/create_events \
-d '{
"events": [
{
"id": "550e8400-e29b-41d4-a716-446655440001",
"event_type": "llm",
"init_timestamp": "2024-03-14T12:01:00Z",
"end_timestamp": "2024-03-14T12:01:02Z",
Expand All @@ -314,6 +315,7 @@ curl -X POST https://api.agentops.ai/v2/create_events \
"completion_tokens": 80
},
{
"id": "550e8400-e29b-41d4-a716-446655440002",
"event_type": "tool",
"name": "database_query",
"init_timestamp": "2024-03-14T12:01:03Z",
Expand All @@ -324,6 +326,7 @@ curl -X POST https://api.agentops.ai/v2/create_events \
]
}'
```
</CodeGroup>

```bash Request
POST https://api.agentops.ai/v2/create_events
Expand All @@ -333,6 +336,7 @@ Authorization: Bearer your_jwt_token
{
"events": [
{
"id": "550e8400-e29b-41d4-a716-446655440001",
"event_type": "llm",
"init_timestamp": "2024-03-14T12:01:00Z",
"end_timestamp": "2024-03-14T12:01:02Z",
Expand All @@ -350,6 +354,7 @@ Authorization: Bearer your_jwt_token
"completion_tokens": 80
},
{
"id": "550e8400-e29b-41d4-a716-446655440002",
"event_type": "tool",
"name": "database_query",
"init_timestamp": "2024-03-14T12:01:03Z",
Expand All @@ -359,8 +364,6 @@ Authorization: Bearer your_jwt_token
}
]
}
```
</CodeGroup>

### Update Events

Expand Down Expand Up @@ -499,6 +502,7 @@ event_response = requests.post(
headers=event_headers,
json={
"events": [{
"id": str(uuid.uuid4()), # Required field for actions table
"event_type": "llm",
"init_timestamp": datetime.now(timezone.utc).isoformat(),
"end_timestamp": datetime.now(timezone.utc).isoformat(),
Expand Down
29 changes: 28 additions & 1 deletion tests/test_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,34 @@ def test_create_events(self) -> bool:

payload = {
"events": [
{"event_type": "test", "session_id": self.session_id, "init_timestamp": now, "end_timestamp": now}
{
"id": str(uuid.uuid4()),
"event_type": "llm",
"init_timestamp": now,
"end_timestamp": now,
"session_id": self.session_id,
"model": "gpt-4",
"prompt": [
{"role": "system", "content": "You are a helpful assistant"},
{"role": "user", "content": "Analyze this data..."}
],
"completion": {
"role": "assistant",
"content": "Based on the data..."
},
"prompt_tokens": 150,
"completion_tokens": 80
},
{
"id": str(uuid.uuid4()),
"event_type": "tool",
"name": "database_query",
"init_timestamp": now,
"end_timestamp": now,
"session_id": self.session_id,
"input": "SELECT * FROM users",
"output": "Retrieved 5 users"
}
]
}

Expand Down

0 comments on commit ad98c3b

Please sign in to comment.