返回 Skill 列表
extension
分类: 内容与媒体无需 API Key

libllm

libllm - 用于兼容OpenAI端点的LLM API客户端。LlmApi类通过HTTP处理聊天完成和嵌入。支持GitHub模型、Azure OpenAI和标准OpenAI端点。处理流式响应、令牌计数以及多工具并行调用修复。可用于LLM完成、嵌入和AI模型集成。

person作者: jakexiaohubgithub

libllm Skill

When to Use

  • Making chat completion requests to LLM providers
  • Generating text embeddings for vector search
  • Integrating with OpenAI-compatible APIs
  • Handling streaming LLM responses

Key Concepts

LlmApi: HTTP client for OpenAI-compatible endpoints. Handles authentication, streaming, and response parsing.

DEFAULT_MAX_TOKENS: Standard token limit for completions.

Usage Patterns

Pattern 1: Chat completion

import { LlmApi } from "@copilot-ld/libllm";

const api = new LlmApi(config, logger);
const response = await api.completion([{ role: "user", content: "Hello" }], {
  model: "gpt-4",
  maxTokens: 1000,
});

Pattern 2: Generate embeddings

const embeddings = await api.embed(["text to embed"]);
// Returns array of vectors

Integration

Used by LLM service. Configurable via environment for different providers (OpenAI, Azure, GitHub Models).