diff --git a/functions/assembly/index.ts b/functions/assembly/index.ts index 0cdebf6..a8cbe95 100644 --- a/functions/assembly/index.ts +++ b/functions/assembly/index.ts @@ -1,18 +1,22 @@ import { models } from "@hypermode/functions-as"; -import { ClassificationModel } from "@hypermode/models-as/models/experimental/classification"; +import { + OpenAIChatModel, + SystemMessage, + UserMessage, +} from "@hypermode/models-as/models/openai/chat"; +const modelName = "text-generator"; -const modelName = "sentiment-classifier"; -const threshold: f32 = 0.5; +export function generateText(text: string): string { + const model = models.getModel(modelName); -export function testClassifier(text: string): string { - const model = models.getModel(modelName); - const input = model.createInput([text]); - const output = model.invoke(input); + const input = model.createInput([ + new SystemMessage("You are a helpful assistant."), + new UserMessage(text), + ]); + + input.temperature = 0.7; - const prediction = output.predictions[0]; - if (prediction.confidence >= threshold) { - return prediction.label; - } + const output = model.invoke(input); - return ""; + return output.choices[0].message.content.trim(); } diff --git a/hypermode.json b/hypermode.json index 4ea4c2f..dcc4d91 100644 --- a/hypermode.json +++ b/hypermode.json @@ -2,11 +2,11 @@ "$schema": "https://manifest.hypermode.com/hypermode.json", "models": { // Models used by your Hypermode project are defined here. - // As an example, the particular model below is a sentiment classifier from Hugging Face, + // As an example, the particular model below is Meta's Llama 3.1 8B LLM from Hugging Face, // which is hosted on Hypermode and used in the starter function in this repository. // You can update or remove this model as needed. - "sentiment-classifier": { - "sourceModel": "distilbert/distilbert-base-uncased-finetuned-sst-2-english", + "text-generator": { + "sourceModel": "meta-llama/Meta-Llama-3.1-8B-Instruct", "provider": "hugging-face", "host": "hypermode" }