nsarrazin HF staff commited on
Commit
0134fe1
1 Parent(s): 5b07906
src/lib/server/generateFromDefaultEndpoint.ts CHANGED
@@ -14,7 +14,7 @@ interface Parameters {
14
  export async function generateFromDefaultEndpoint(
15
  prompt: string,
16
  parameters?: Partial<Parameters>
17
- ) {
18
  const newParameters = {
19
  ...defaultModel.parameters,
20
  ...parameters,
@@ -64,13 +64,11 @@ export async function generateFromDefaultEndpoint(
64
  }
65
 
66
  if (!resp.ok) {
67
- console.error(await resp.text());
68
- return;
69
  }
70
 
71
  if (!resp.body) {
72
- console.error("Body is empty");
73
- return;
74
  }
75
 
76
  const decoder = new TextDecoder();
 
14
  export async function generateFromDefaultEndpoint(
15
  prompt: string,
16
  parameters?: Partial<Parameters>
17
+ ): Promise<string> {
18
  const newParameters = {
19
  ...defaultModel.parameters,
20
  ...parameters,
 
64
  }
65
 
66
  if (!resp.ok) {
67
+ throw new Error(await resp.text());
 
68
  }
69
 
70
  if (!resp.body) {
71
+ throw new Error("Body is empty");
 
72
  }
73
 
74
  const decoder = new TextDecoder();
src/lib/server/summarize.ts CHANGED
@@ -12,7 +12,10 @@ export async function summarize(prompt: string) {
12
  model: defaultModel,
13
  });
14
 
15
- const generated_text = await generateFromDefaultEndpoint(summaryPrompt);
 
 
 
16
 
17
  if (generated_text) {
18
  return generated_text;
 
12
  model: defaultModel,
13
  });
14
 
15
+ const generated_text = await generateFromDefaultEndpoint(summaryPrompt).catch((e) => {
16
+ console.error(e);
17
+ return null;
18
+ });
19
 
20
  if (generated_text) {
21
  return generated_text;