Giter Site home page Giter Site logo

parea-ai / parea-sdk-ts Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 1.0 3.21 MB

TypeScript SDK for experimenting, testing, evaluating & monitoring LLM-powered applications - Parea AI (YC S23)

Home Page: https://docs.parea.ai/sdk/typescript

License: Apache License 2.0

JavaScript 0.50% TypeScript 99.41% Shell 0.09%
llm llm-evaluation llm-evaluation-framework llm-evaluation-toolkit llm-tools llms llms-benchmarking llm-eval prompt-engineering

parea-sdk-ts's Introduction

parea-sdk-ts

License

Parea typescript sdk

Installation

npm install parea-ai

TypeScript SDK Docs

Getting Started

import {Completion, CompletionResponse, Parea} from "parea-ai";

const p = new Parea('PAREA_API_KEY');

const deployedPromptCall = async (query: string): Promise<string> => {
  const completion: Completion = {
    deployment_id: 'Deployment_ID',
    llm_inputs: { query: query },
  };
  const response = await p.completion(completion);
  return response.content;
};

async function main() {
  return await deployedPromptCall('Write a hello world program using Typescript and the React framework.');
}

main().then((result) => console.log(result));

Logging results from LLM providers & recording user feedback

import OpenAI from 'openai';
import {patchOpenAI, Parea, getCurrentTraceId} from "parea-ai";

const openai = new OpenAI({ apiKey: 'OPENAI_API_KEY' });

// Patch OpenAI to add trace logs
patchOpenAI(openai);
const p = new Parea('PAREA_API_KEY');

async function callOpenAI(
  messages: any[],
  model: string = 'gpt-3.5-turbo-0125',
  temperature: number = 0.0,
): Promise<string> {
  const response = await openai.chat.completions.create({ model, messages, temperature });
  return response.choices[0].message.content ?? '';
}

async function main() {
   const result = await callOpenAI([{ role: 'user', content: 'Write a hello world program using Typescript and the React framework.'}]);
   // record feedback on result
   const traceId = getCurrentTraceId();
   await p.recordFeedback({
      trace_id: traceId,
      score: 0.21, // 0.0 (bad) to 1.0 (good)
   });
   return result;
}

main().then((result) => console.log(result));

๐Ÿ›ก License

License

This project is licensed under the terms of the Apache Software License 2.0 license. See LICENSE for more details.

๐Ÿ“ƒ Citation

@misc{parea-sdk-ts,
  author = {parea-ai},
  title = {Parea typescript sdk},
  year = {2023},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/parea-ai/parea-sdk-ts}}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.