Skip to content

Commit

Permalink
Add tracing capabilities to OpenAIEndpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Oct 19, 2024
1 parent 8fb6ff7 commit 8702309
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ OpenAI APIs for XP ChangeLog

## ?.?.? / ????-??-??

* Added tracing capabilities to `com.openai.rest.OpenAIEndpoint` class
(@thekid)
* Merged PR #2: Implement REST API - including support for streaming
(@thekid)
* Merged PR #1: Add integration tests for `cl100k_base` and `o200k_base`
(@thekid)
* First public release - (@thekid)
(@thekid)
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"keywords": ["module", "xp"],
"require" : {
"xp-framework/core": "^12.0 | ^11.0 | ^10.0",
"xp-framework/logging": "^11.2",
"xp-forge/rest-client": "^5.6",
"php" : ">=7.4.0"
},
Expand Down
12 changes: 11 additions & 1 deletion src/main/php/com/openai/rest/OpenAIEndpoint.class.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php namespace com\openai\rest;

use util\log\Traceable;
use webservices\rest\Endpoint;

class OpenAIEndpoint {
class OpenAIEndpoint implements Traceable {
private $endpoint;

/**
Expand All @@ -14,6 +15,15 @@ public function __construct($arg) {
$this->endpoint= $arg instanceof Endpoint ? $arg : new Endpoint($arg);
}

/**
* Provides a log category for tracing requests
*
* @param ?util.log.LogCategory $cat
*/
public function setTrace($cat) {
$this->endpoint->setTrace($cat);
}

/** Returns an API */
public function api(string $path, array $segments= []): Api {
return new Api($this->endpoint->resource(ltrim($path, '/'), $segments));
Expand Down

0 comments on commit 8702309

Please sign in to comment.