做企业网站找谁,wordpress跳转链接,荣成网站建设,天元建设集团有限公司济南第六建筑工程分公司HuggingFace Inference Endpoints 允许您在云中部署和提供机器学习模型#xff0c;并通过 API 对其进行访问。
开始使用
有关 HuggingFace Inference Endpoints 的更多详细信息#xff0c;请访问此处。
前提条件
添加 spring-ai-huggingface 依赖关系#xff1a;
d…HuggingFace Inference Endpoints 允许您在云中部署和提供机器学习模型并通过 API 对其进行访问。
开始使用
有关 HuggingFace Inference Endpoints 的更多详细信息请访问此处。
前提条件
添加 spring-ai-huggingface 依赖关系
dependencygroupIdorg.springframework.ai/groupIdartifactIdspring-ai-huggingface/artifactId
/dependency 获取 HuggingFace API 密钥并将其设置为环境变量
export HUGGINGFACE_API_KEYyour_api_key_here 请参阅 依赖关系管理 部分将 Spring AI BOM 添加到构建文件中。
请注意该聊天实现还没有 Spring Boot Starter。
获取推理的端点 URL
调用模型
HuggingfaceChatModel chatModel new HuggingfaceChatModel(apiKey, basePath);
Prompt prompt new Prompt(Your text here...);
ChatResponse response chatModel.call(prompt);
System.out.println(response.getGeneration().getText()); 示例
使用此处的示例
String mistral7bInstruct [INST] You are a helpful code assistant. Your task is to generate a valid JSON object based on the given information:name: Johnlastname: Smithaddress: #1 Samuel St.Just generate the JSON object without explanations:[/INST];
Prompt prompt new Prompt(mistral7bInstruct);
ChatResponse aiResponse huggingfaceChatModel.call(prompt);
System.out.println(response.getGeneration().getText()); 将产生以下输出
{name: John,lastname: Smith,address: #1 Samuel St.
}
下节Spring AI 第二讲 之 Chat Model API 第五节Google VertexAI API
代码后期添加