Skip to content

About

Utils for Agentic Deno

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Agentic AI Utilities (Deno)

Utilities for building agentic AI systems with structured outputs in Deno.

Features

  • 🛠️ Schema-Enforced Completions - Ensure LLM responses adhere to JSON schemas
  • 🤖 System Prompt Integration - Easily combine OpenAI-compatible endpoint
  • 📝 Optional Reasoning Capture - Get model reasoning alongside structured responses
  • 🚦 Type Safety - Written in TypeScript with strict type checking

Installation

deno add @deno-agent/utils

Usage

import { completeWithSchema } from "@your-username/ai-utils"

// Example schema
const answerSchema = {
    type: "object",
    properties: {
        answer: { type: "string" },
        confidence: { type: "number" },
    },
    required: ["answer"],
}

// Run completion
const [content, reasoning] = await completeWithSchema(
    "your-api-key",
    "https://api.together.xyz/v1",
    answerSchema,
    "You are a helpful assistant that answers questions precisely.",
    "What is the capital of France?",
    "meta-llama/Llama-3-70b-chat-hf"
)

// Parse and use results
const result = JSON.parse(content)
console.log("Answer:", result.answer)
console.log("Reasoning:", reasoning)

API Reference

completeWithSchema(apiKey, baseURL, schema, systemPrompt, userPrompt, model?)`

Parameters:

apiKey: string - API key for your LLM provider baseURL: string - Base URL of OpenAI-compatible API endpoint schema: object - JSON Schema for response validation systemPrompt: string - Base system prompt userPrompt: string - User instruction/question model: string (optional) - Model name (default: "meta-llama/Llama-3.3-70B-Instruct")

Returns: Promise<[string, string | undefined]>

Tuple containing:

JSON string matching the schema Optional reasoning string (if supported by model)

Error Handling

The function will throw an error if:

No content is generated by the model The response doesn't match the schema (handled by API provider) Network/authentication issues occur Model Compatibility

License

MIT License

About

Utils for Agentic Deno

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages