Skip to content

Commit

Permalink
fix ts issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aantipov committed Dec 9, 2023
1 parent 2d65b46 commit b3919a1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions functions-helpers/fetchPackageAIAlternatives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface AlternativesObjectT {
version: number;
model: string;
data: AlternativesDataT;
usage: OpenAI.ChatCompletion.Usage;
usage: OpenAI.CompletionUsage | undefined;
createdAt: string;
}

Expand Down Expand Up @@ -78,7 +78,7 @@ export async function fetchPkgAIAlternatives(
alternativesResponse = response.choices[0];
} catch (error) {
throw new Error(
`${ERR_PREFIX} openai.chat.completions.create failed - ${error?.message}`,
`${ERR_PREFIX} openai.chat.completions.create failed - ${String(error)}`,
{ cause: error },
);
}
Expand Down
4 changes: 2 additions & 2 deletions functions-helpers/setPackageAiInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export async function setPkgAIInfo(
await KV.put(pkgName, JSON.stringify({ ...content, alternatives }), {
expirationTtl: 60 * 60 * 24 * 90,
});
} catch (error: any) {
throw new Error(`[setPkgAIInfo] KV.put failed - ${error?.message}`);
} catch (error) {
throw new Error(`[setPkgAIInfo] KV.put failed - ${String(error)}`);
}
console.log(`[setPkgAIInfo] KV.put success - ${pkgName}`);
}
7 changes: 5 additions & 2 deletions src/AiContentApp/AiContentApp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ const props = defineProps<{
}>();
const libs = useStore($trimmedLibraries);
const firstLoadingFinished = ref(false);
const items = computed(() =>
firstLoadingFinished.value ? libs.value : props.data,
const items = computed(
() =>
(firstLoadingFinished.value
? libs.value
: props.data) as unknown as NpmInfoApiResponseT[],
);
const aliases = computed(() =>
items.value.map(
Expand Down
2 changes: 1 addition & 1 deletion src/AiContentApp/NpmContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
</p>

<p
v-else-if="alternatives && alternatives.data"
v-else-if="alternatives && 'data' in alternatives"
class="mb-2 flex flex-wrap gap-2"
>
<span class="self-center font-bold">Alternatives:</span>
Expand Down

0 comments on commit b3919a1

Please sign in to comment.