nsarrazin HF staff commited on
Commit
030bd38
1 Parent(s): 39b5447

add static adapter & get rid of file upload for now

Browse files
package-lock.json CHANGED
@@ -18,6 +18,7 @@
18
  "devDependencies": {
19
  "@magidoc/plugin-svelte-prismjs": "^4.0.0",
20
  "@sveltejs/adapter-auto": "^2.0.0",
 
21
  "@sveltejs/kit": "^1.5.0",
22
  "@types/prismjs": "^1.26.0",
23
  "@typescript-eslint/eslint-plugin": "^5.45.0",
@@ -621,6 +622,15 @@
621
  "@sveltejs/kit": "^1.0.0"
622
  }
623
  },
 
 
 
 
 
 
 
 
 
624
  "node_modules/@sveltejs/kit": {
625
  "version": "1.20.5",
626
  "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-1.20.5.tgz",
 
18
  "devDependencies": {
19
  "@magidoc/plugin-svelte-prismjs": "^4.0.0",
20
  "@sveltejs/adapter-auto": "^2.0.0",
21
+ "@sveltejs/adapter-static": "^2.0.2",
22
  "@sveltejs/kit": "^1.5.0",
23
  "@types/prismjs": "^1.26.0",
24
  "@typescript-eslint/eslint-plugin": "^5.45.0",
 
622
  "@sveltejs/kit": "^1.0.0"
623
  }
624
  },
625
+ "node_modules/@sveltejs/adapter-static": {
626
+ "version": "2.0.2",
627
+ "resolved": "https://registry.npmjs.org/@sveltejs/adapter-static/-/adapter-static-2.0.2.tgz",
628
+ "integrity": "sha512-9wYtf6s6ew7DHUHMrt55YpD1FgV7oWql2IGsW5BXquLxqcY9vjrqCFo0TzzDpo+ZPZkW/v77k0eOP6tsAb8HmQ==",
629
+ "dev": true,
630
+ "peerDependencies": {
631
+ "@sveltejs/kit": "^1.5.0"
632
+ }
633
+ },
634
  "node_modules/@sveltejs/kit": {
635
  "version": "1.20.5",
636
  "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-1.20.5.tgz",
package.json CHANGED
@@ -15,6 +15,7 @@
15
  "devDependencies": {
16
  "@magidoc/plugin-svelte-prismjs": "^4.0.0",
17
  "@sveltejs/adapter-auto": "^2.0.0",
 
18
  "@sveltejs/kit": "^1.5.0",
19
  "@types/prismjs": "^1.26.0",
20
  "@typescript-eslint/eslint-plugin": "^5.45.0",
 
15
  "devDependencies": {
16
  "@magidoc/plugin-svelte-prismjs": "^4.0.0",
17
  "@sveltejs/adapter-auto": "^2.0.0",
18
+ "@sveltejs/adapter-static": "^2.0.2",
19
  "@sveltejs/kit": "^1.5.0",
20
  "@types/prismjs": "^1.26.0",
21
  "@typescript-eslint/eslint-plugin": "^5.45.0",
src/lib/agents/evalBuilder.ts CHANGED
@@ -15,7 +15,6 @@ export async function evalBuilder(
15
  filetype = "audio";
16
  }
17
 
18
- console.log(filetype);
19
  async function wrapperEval() {
20
  if (filetype !== "") {
21
  // @ts-ignore
 
15
  filetype = "audio";
16
  }
17
 
 
18
  async function wrapperEval() {
19
  if (filetype !== "") {
20
  // @ts-ignore
src/lib/agents/llm.ts CHANGED
@@ -23,19 +23,19 @@ async function OpenAILLMCall(prompt: string) {
23
  async function HFLLMCall(prompt: string) {
24
  const hf = getInference();
25
 
26
- const formattedPrompt = "<|user|>" + prompt + "<end|><|assistant|>";
27
 
28
- const textAnswer = await hf.textGeneration({
29
  inputs: formattedPrompt,
30
- model: "HuggingFaceH4/starchat-beta",
31
  parameters: {
32
- max_new_tokens: 1024,
33
  },
34
  });
35
 
36
- console.log(textAnswer.generated_text);
37
 
38
- return textAnswer.generated_text;
39
  }
40
 
41
  export const OpenAILLM: LLM = {
 
23
  async function HFLLMCall(prompt: string) {
24
  const hf = getInference();
25
 
26
+ const formattedPrompt = "<|user|>" + prompt + "<|end|>";
27
 
28
+ const generatedOutput = await hf.textGeneration({
29
  inputs: formattedPrompt,
30
+ model: "OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5",
31
  parameters: {
32
+ max_new_tokens: 512,
33
  },
34
  });
35
 
36
+ const text = generatedOutput.generated_text.slice(formattedPrompt.length);
37
 
38
+ return text;
39
  }
40
 
41
  export const OpenAILLM: LLM = {
src/lib/agents/promptGeneration.ts CHANGED
@@ -1,10 +1,10 @@
1
  import type { Tool } from "$lib/types";
2
 
3
  function toolDescription(tool: Tool<any, any>) {
4
- let prompt = ` name: ${tool.name} \n description: ${tool.description}`;
5
 
6
  const examples = tool.examples.slice(0, 1).map((example) => {
7
- return ` prompt: ${example.prompt} \n command generated: \`${example.command}\``;
8
  });
9
 
10
  prompt += `\n` + examples.join("\n");
@@ -34,9 +34,15 @@ export function generatePrompt(
34
 
35
  // describe all the tools
36
  const fullPrompt = `
37
- Create a function that does the following: ${prompt}.
 
 
 
 
 
38
 
39
  Examples:
 
40
  For the prompt: "Caption the image and give me the caption read out loud."
41
  \`\`\`js
42
  async function generate(image) {
@@ -67,11 +73,6 @@ async function generate(audio) {
67
  }
68
  \`\`\`
69
 
70
- If you need to send information use \`message("message", data)\` and NOT \`console.log\`.
71
-
72
- In order to help in answering the above prompt, the function has access to the following methods to generate outputs.
73
- ${tools.map((tool) => toolDescription(tool)).join("\n\n ")}
74
-
75
  Use the above methods and only the above methods to answer the prompt: ${prompt}.
76
 
77
  It must match the following signature:
 
1
  import type { Tool } from "$lib/types";
2
 
3
  function toolDescription(tool: Tool<any, any>) {
4
+ let prompt = `name: ${tool.name} \ndescription: ${tool.description}`;
5
 
6
  const examples = tool.examples.slice(0, 1).map((example) => {
7
+ return `prompt: ${example.prompt} \ncommand generated: \`${example.command}\``;
8
  });
9
 
10
  prompt += `\n` + examples.join("\n");
 
34
 
35
  // describe all the tools
36
  const fullPrompt = `
37
+ Create a javascript function that does the following: "${prompt}"
38
+
39
+ If you need to send information use \`message("message", data)\` and NOT \`console.log\`.
40
+
41
+ In order to help in answering the above prompt, the function has access to the following methods to generate outputs.
42
+ ${tools.map((tool) => toolDescription(tool)).join("\n-------\n")}
43
 
44
  Examples:
45
+
46
  For the prompt: "Caption the image and give me the caption read out loud."
47
  \`\`\`js
48
  async function generate(image) {
 
73
  }
74
  \`\`\`
75
 
 
 
 
 
 
76
  Use the above methods and only the above methods to answer the prompt: ${prompt}.
77
 
78
  It must match the following signature:
src/routes/+layout.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export const prerender = true;
src/routes/+page.svelte CHANGED
@@ -87,7 +87,7 @@
87
  bind:value={prompt}
88
  />
89
 
90
- <FileUpload bind:files />
91
 
92
  <button
93
  class="btn btn-primary mt-auto w-fit mx-auto"
 
87
  bind:value={prompt}
88
  />
89
 
90
+ <!-- <FileUpload bind:files /> -->
91
 
92
  <button
93
  class="btn btn-primary mt-auto w-fit mx-auto"
svelte.config.js CHANGED
@@ -1,4 +1,4 @@
1
- import adapter from '@sveltejs/adapter-auto';
2
  import { vitePreprocess } from '@sveltejs/kit/vite';
3
 
4
  /** @type {import('@sveltejs/kit').Config} */
@@ -11,8 +11,15 @@ const config = {
11
  // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
12
  // If your environment is not supported or you settled on a specific environment, switch out the adapter.
13
  // See https://kit.svelte.dev/docs/adapters for more information about adapters.
14
- adapter: adapter()
15
- }
 
 
 
 
 
 
 
16
  };
17
 
18
  export default config;
 
1
+ import adapter from '@sveltejs/adapter-static';
2
  import { vitePreprocess } from '@sveltejs/kit/vite';
3
 
4
  /** @type {import('@sveltejs/kit').Config} */
 
11
  // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
12
  // If your environment is not supported or you settled on a specific environment, switch out the adapter.
13
  // See https://kit.svelte.dev/docs/adapters for more information about adapters.
14
+ adapter: adapter({
15
+ // default options are shown. On some platforms
16
+ // these options are set automatically — see below
17
+ pages: 'build',
18
+ assets: 'build',
19
+ fallback: undefined,
20
+ precompress: false,
21
+ strict: true
22
+ }) }
23
  };
24
 
25
  export default config;