|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
generator = pipeline('text-generation', model='EleutherAI/gpt-neo-2.7B') |
|
|
|
|
|
def chat_with_llm(user_input): |
|
prompt = f"请从以下问题中提取出预测所需的参数(年份、期号、中奖号码等):'{user_input}'" |
|
|
|
|
|
response = generator(prompt, max_length=100, num_return_sequences=1) |
|
extracted_text = response[0]['generated_text'] |
|
|
|
return extracted_text |
|
|
|
|
|
iface = gr.Interface( |
|
fn=chat_with_llm, |
|
inputs=gr.Textbox(label="请输入问题或期号信息"), |
|
outputs="text", |
|
title="大语言模型 API", |
|
description="解析用户输入,提取预测所需的特征" |
|
) |
|
|
|
|
|
iface.launch(share=True) |
|
|