Skip to content

Commit

Permalink
add back logging
Browse files Browse the repository at this point in the history
Signed-off-by: oilbeater <[email protected]>
  • Loading branch information
oilbeater committed Sep 30, 2024
1 parent ccccde7 commit 49b390a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion docs/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@

Malacca can record all the API request and response body for further fine-tune or reinforcement learning.

It is built on the Cloudflare worker logging mechanism you can view streaming log through the
It is built on the Cloudflare worker logging mechanism you can view streaming log through the [Real-time logs](https://developers.cloudflare.com/workers/observability/logs/real-time-logs/) or [Logpuh](https://developers.cloudflare.com/workers/observability/logs/logpush/) to a destination.

The log entry looks like this:

3 changes: 2 additions & 1 deletion src/providers/azureOpenAI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const azureOpenAIProvider: AIProvider = {
const queryParams = new URLSearchParams(c.req.query()).toString();
const urlWithQueryParams = `${azureEndpoint}?${queryParams}`;

console.log({request_body: body})
const apiKey = c.req.header('api-key');
const realKey = await c.env.MALACCA_USER.get(apiKey);
if (!realKey) {
Expand Down Expand Up @@ -86,7 +87,7 @@ export const azureOpenAIProvider: AIProvider = {

const duration = Date.now() - startTime;
recordAnalytics(c, ProviderName, duration, prompt_tokens, completion_tokens);

console.log({response_body: buf})
if (response.status === 200) {
c.executionCtx.waitUntil(c.env.MALACCA_CACHE.put(cacheKeyHex, buf, {expirationTtl: 3600}));
}
Expand Down

0 comments on commit 49b390a

Please sign in to comment.