1.46.0 • Published 7 days ago

parea-ai v1.46.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
7 days ago

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}}
}
1.46.0

7 days ago

1.45.0

11 days ago

1.44.0

12 days ago

1.42.0

14 days ago

1.41.0

14 days ago

1.43.0

14 days ago

1.40.1

18 days ago

1.40.0

23 days ago

1.39.0

25 days ago

1.38.4

26 days ago

1.38.2

1 month ago

1.38.3

1 month ago

1.38.1

1 month ago

1.38.0

1 month ago

1.37.0

1 month ago

1.35.0

1 month ago

1.36.0

1 month ago

1.34.0

1 month ago

1.33.0

2 months ago

1.32.3

2 months ago

1.32.0

2 months ago

1.32.1

2 months ago

1.32.2

2 months ago

1.31.0

2 months ago

1.30.0

2 months ago

1.29.0

2 months ago

1.27.0

2 months ago

1.26.1

2 months ago

1.28.0

2 months ago

1.26.0

2 months ago

1.25.0

2 months ago

1.24.1

3 months ago

1.24.0

3 months ago

1.23.0

3 months ago

1.21.0

3 months ago

1.22.0

3 months ago

1.19.0

3 months ago

1.18.1

3 months ago

1.20.0

3 months ago

1.18.0

3 months ago

1.17.0

3 months ago

1.16.1

3 months ago

1.16.0

3 months ago

1.15.0

3 months ago

1.13.2

3 months ago

1.14.0

3 months ago

1.13.1

3 months ago

1.13.0

3 months ago

1.13.5

3 months ago

1.13.4

3 months ago

1.13.3

3 months ago

1.12.0

3 months ago

1.11.1

3 months ago

1.9.1

3 months ago

1.9.0

3 months ago

1.11.0

3 months ago

1.10.0

3 months ago

1.8.2

3 months ago

1.8.1

3 months ago

1.8.0

7 months ago

1.7.0

7 months ago

1.6.0

8 months ago

1.5.0

8 months ago

1.4.0

8 months ago

1.3.0

8 months ago

1.2.0

8 months ago

1.1.2

8 months ago

1.1.1

8 months ago

1.1.0

8 months ago