goodfire
v0.1.12
Published
A TypeScript SDK for for the Goodfire API.
Downloads
601
Readme
Typescript SDK for Goodfire
import { useGoodfireSDK } from "goodfire";
const sdk = useGoodfireSDK("YOUR_API_KEY");
// # Search for features
sdk.features.search("pirate", "meta-llama/Meta-Llama-3-8B-Instruct", 5).then((res) => {
console.log(res);
});
// List variants
sdk.variants.list().then((res) => {
console.log(res);
});
// // Get variant
sdk.variants.get("VARIANT_ID").then((res) => {
console.log(res);
});
// Stream chat
sdk.chat.completions.create({
messages: [
{ "content": "who am I talking to?", "role": "user" }
],
model: "meta-llama/Meta-Llama-3-8B-Instruct",
stream: true,
}).then(async (stream) => {
for await (const chunk of stream) {
console.log(chunk.choices[0].delta.content);
}
});
// Create a new variant and then chat
sdk.features.search("pirate", "meta-llama/Meta-Llama-3-8B-Instruct", 5).then((res) => {
const pirateFeatureToUse = res.features[1];
const variant = new sdk.Variant("meta-llama/Meta-Llama-3-8B-Instruct");
variant.set(pirateFeatureToUse, 0.8);
sdk.chat.completions.create({
messages: [
{ "content": "who am I talking to?", "role": "user" }
],
model: variant,
stream: false,
}).then(async (response) => {
console.log(response.choices[0].message.content);
});
});