Skip to content

Commit

Permalink
Modified model cache
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpocock committed Dec 3, 2024
1 parent 205c55d commit fc9b092
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/evalite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"scripts": {
"dev": "tsc -w",
"build": "tsc"
"build": "tsc && chmod +x ./dist/bin.js"
},
"exports": {
".": "./dist/index.js",
Expand Down
15 changes: 8 additions & 7 deletions packages/example/src/cache-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ const createResultFromCachedObject = (
return obj as any;
};

export const cacheModel = (
model: LanguageModelV1,
storage: {
get: (key: string) => Promise<object>;
set: (key: string, value: string) => Promise<void>;
}
) => {
export type StorageValue = string | number | null | object;

export type CacheStore = {
get: (key: string) => Promise<StorageValue>;
set: (key: string, value: StorageValue) => Promise<void>;
};

export const cacheModel = (model: LanguageModelV1, storage: CacheStore) => {
return experimental_wrapLanguageModel({
model,
middleware: {
Expand Down

0 comments on commit fc9b092

Please sign in to comment.