- Python
- NodeJS
Synchronous Usage
from openai import OpenAI
import dokumetry
client = OpenAI(
api_key = "YOUR_OPENAI_API_KEY"
)
# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_DOKU_INGESTER_URL", api_key="YOUR_DOKU_TOKEN")
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a expert at monitoring LLM Applications"},
{"role": "user", "content": "Hello! How do I monitor my OpenAI based LLM Applications?"}
]
)
print(completion.choices[0].message)
from openai import OpenAI
import dokumetry
client = OpenAI(
api_key = "YOUR_OPENAI_API_KEY"
)
# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_DOKU_INGESTER_URL", api_key="YOUR_DOKU_TOKEN")
response = client.chat.completions.create(
model="gpt-4-vision-preview",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What’s in this image?"},
{
"type": "image_url",
"image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
},
],
}
],
max_tokens=300,
)
print(response.choices[0])
from openai import OpenAI
import dokumetry
client = OpenAI(
api_key = "YOUR_OPENAI_API_KEY"
)
# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_DOKU_INGESTER_URL", api_key="YOUR_DOKU_TOKEN")
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a expert at monitoring LLM Applications"},
{"role": "user", "content": "Hello! How do I monitor my OpenAI based LLM Applications?"}
],
stream=True
)
for chunk in completion:
print(chunk.choices[0].delta)
from openai import OpenAI
import dokumetry
client = OpenAI(
api_key = "YOUR_OPENAI_API_KEY"
)
# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_DOKU_INGESTER_URL", api_key="YOUR_DOKU_TOKEN")
tools = [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
},
"required": ["location"],
},
}
}
]
messages = [{"role": "user", "content": "What's the weather like in Boston today?"}]
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=messages,
tools=tools,
tool_choice="auto"
)
print(completion)
from openai import OpenAI
import dokumetry
client = OpenAI(
api_key = "YOUR_OPENAI_API_KEY"
)
# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_DOKU_INGESTER_URL", api_key="YOUR_DOKU_TOKEN")
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a expert at monitoring LLM Applications"},
{"role": "user", "content": "Hello! How do I monitor my OpenAI based LLM Applications?"}
],
logprobs=True,
top_logprobs=2
)
print(completion.choices[0].message)
print(completion.choices[0].logprobs)
Asynchronous Usage
import asyncio
from openai import AsyncOpenAI
import dokumetry
client = AsyncOpenAI(
api_key = "YOUR_OPENAI_API_KEY"
)
# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_DOKU_INGESTER_URL", api_key="YOUR_DOKU_TOKEN")
async def main() -> None:
chat_completion = await client.chat.completions.create(
messages=[
{"role": "system", "content": "You are a expert at monitoring LLM Applications"},
{"role": "user", "content": "Hello! How do I monitor my OpenAI based LLM Applications?"}
],
model="gpt-3.5-turbo",
)
asyncio.run(main())
import asyncio
from openai import AsyncOpenAI
import dokumetry
client = AsyncOpenAI(
api_key = "YOUR_OPENAI_API_KEY"
)
# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_DOKU_INGESTER_URL", api_key="YOUR_DOKU_TOKEN")
async def main() -> None:
response = await client.chat.completions.create(
model="gpt-4-vision-preview",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What’s in this image?"},
{
"type": "image_url",
"image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
},
],
}
],
max_tokens=300,
)
asyncio.run(main())
import asyncio
from openai import AsyncOpenAI
import dokumetry
client = AsyncOpenAI(
api_key = "YOUR_OPENAI_API_KEY"
)
# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_DOKU_INGESTER_URL", api_key="YOUR_DOKU_TOKEN")
async def main():
stream = await client.chat.completions.create(
model="gpt-4",
messages=[
{"role": "system", "content": "You are a expert at monitoring LLM Applications"},
{"role": "user", "content": "Hello! How do I monitor my OpenAI based LLM Applications?"}
],
stream=True,
)
async for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")
asyncio.run(main())
import asyncio
from openai import AsyncOpenAI
import dokumetry
client = AsyncOpenAI(
api_key = "YOUR_OPENAI_API_KEY"
)
# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_DOKU_INGESTER_URL", api_key="YOUR_DOKU_TOKEN")
tools = [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
},
"required": ["location"],
},
}
}
]
messages = [{"role": "user", "content": "What's the weather like in Boston today?"}]
async def main() -> None:
completion = await client.chat.completions.create(
model="gpt-3.5-turbo",
messages=messages,
tools=tools,
tool_choice="auto"
)
asyncio.run(main())
import asyncio
from openai import AsyncOpenAI
import dokumetry
client = AsyncOpenAI(
api_key = "YOUR_OPENAI_API_KEY"
)
# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_DOKU_INGESTER_URL", api_key="YOUR_DOKU_TOKEN")
async def main() -> None:
completion = await client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a expert at monitoring LLM Applications"},
{"role": "user", "content": "Hello! How do I monitor my OpenAI based LLM Applications?"}
],
logprobs=True,
top_logprobs=2
)
asyncio.run(main())
import OpenAI from "openai";
import DokuMetry from 'dokumetry';
const openai = new OpenAI();
// Pass the above `openai` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
DokuMetry.init({llm: openai, dokuUrl: "YOUR_DOKU_INGESTER_URL", apiKey: "YOUR_DOKU_TOKEN"})
async function main() {
const completion = await openai.chat.completions.create({
messages: [
{"role": "system", "content": "You are a expert at monitoring LLM Applications"},
{"role": "user", "content": "Hello! How do I monitor my OpenAI based LLM Applications?"}
],
model: "gpt-3.5-turbo",
});
console.log(completion.choices[0]);
}
main();
import OpenAI from "openai";
import DokuMetry from 'dokumetry';
const openai = new OpenAI();
// Pass the above `openai` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
DokuMetry.init({llm: openai, dokuUrl: "YOUR_DOKU_INGESTER_URL", apiKey: "YOUR_DOKU_TOKEN"})
async function main() {
const response = await openai.chat.completions.create({
model: "gpt-4-vision-preview",
messages: [
{
role: "user",
content: [
{ type: "text", text: "What’s in this image?" },
{
type: "image_url",
image_url:
"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
},
],
},
],
});
console.log(response.choices[0]);
}
main();
import OpenAI from "openai";
import DokuMetry from 'dokumetry';
const openai = new OpenAI();
// Pass the above `openai` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
DokuMetry.init({llm: openai, dokuUrl: "YOUR_DOKU_INGESTER_URL", apiKey: "YOUR_DOKU_TOKEN"})
async function main() {
const completion = await openai.chat.completions.create({
model: "gpt-3.5-turbo",
messages: [
{"role": "system", "content": "You are a expert at monitoring LLM Applications"},
{"role": "user", "content": "Hello! How do I monitor my OpenAI based LLM Applications?"}
],
stream: true,
});
for await (const chunk of completion) {
console.log(chunk.choices[0].delta.content);
}
}
main();
import OpenAI from "openai";
import DokuMetry from 'dokumetry';
const openai = new OpenAI();
// Pass the above `openai` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
DokuMetry.init({llm: openai, dokuUrl: "YOUR_DOKU_INGESTER_URL", apiKey: "YOUR_DOKU_TOKEN"})
async function main() {
const messages = [{"role": "user", "content": "What's the weather like in Boston today?"}];
const tools = [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
},
"required": ["location"],
},
}
}
];
const response = await openai.chat.completions.create({
model: "gpt-3.5-turbo",
messages: messages,
tools: tools,
tool_choice: "auto",
});
console.log(response);
}
main();
import OpenAI from "openai";
import DokuMetry from 'dokumetry';
const openai = new OpenAI();
// Pass the above `openai` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
DokuMetry.init({llm: openai, dokuUrl: "YOUR_DOKU_INGESTER_URL", apiKey: "YOUR_DOKU_TOKEN"})
async function main() {
const completion = await openai.chat.completions.create({
messages: [
{"role": "system", "content": "You are a expert at monitoring LLM Applications"},
{"role": "user", "content": "Hello! How do I monitor my OpenAI based LLM Applications?"}
],
model: "gpt-3.5-turbo",
logprobs: true,
top_logprobs: 2,
});
console.log(completion.choices[0]);
}
main();

