-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66ca1d9
commit b8d4db4
Showing
9 changed files
with
86 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { generateText } from "ai"; | ||
import { createScorer, evalite } from "evalite"; | ||
import { cacheModel } from "./cache-model"; | ||
import { openai } from "@ai-sdk/openai"; | ||
import { createStorage } from "unstorage"; | ||
import fsDriver from "unstorage/drivers/fs"; | ||
import { Humor } from "autoevals"; | ||
|
||
const storage = createStorage({ | ||
driver: (fsDriver as any)({ | ||
base: "./llm-cache.local", | ||
}), | ||
}); | ||
|
||
evalite("Content generation", { | ||
data: async () => { | ||
return [ | ||
{ | ||
input: "Write a TypeScript tweet", | ||
}, | ||
{ | ||
input: "Write a tweet about TypeScript template literals types.", | ||
}, | ||
]; | ||
}, | ||
task: async (input) => { | ||
const result = await generateText({ | ||
model: cacheModel(openai("gpt-4o-mini"), storage), | ||
prompt: input, | ||
system: ` | ||
You are a helpful social media assistant. | ||
You will be asked to write a tweet on a given topic. | ||
Return only the tweet. | ||
Do not use emojis. | ||
Do not use hashtags. | ||
Use code examples where required. | ||
`, | ||
}); | ||
|
||
return result.text; | ||
}, | ||
scorers: [ | ||
Humor, | ||
createScorer("No Hashtags", ({ output }) => { | ||
return output.includes("#") ? 0 : 1; | ||
}), | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters