File size: 2,046 Bytes
ca75b7d
 
 
 
 
 
d3384fb
678d195
 
6c00176
3c40739
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8199f00
ca75b7d
 
7e85c3c
3f2e164
 
ca75b7d
 
 
 
 
 
d823ae0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import gradio as gr
from gradio_client import Client
import os

HUGGINGFACEHUB_API_TOKEN=os.getenv("HUGGINGFACEHUB_API_TOKEN")

#client = Client("https://AIShare-aichatbot.hf.space/", hf_token=HUGGINGFACEHUB_API_TOKEN)
#client = Client("https://binqiangliu-gr-textbox.hf.space/")

client = Client("https://binqiangliu-aichat.hf.space/", hf_token=HUGGINGFACEHUB_API_TOKEN)
#result_1 = client.predict(fn_index=20)
from gradio_client import Client

client = Client("https://binqiangliu-aichat.hf.space/")
result_1 = client.predict(
				"",	# str (filepath to JSON file)								in 'parameter_4' Json component
				"Howdy!",	# str in '' Textbox component
				"Howdy!",	# str in 'parameter_84' Textbox component
				0,	# int | float (numeric value between 0.0 and 2.0)						in 'temp' Slider component
				20,	# int | float (numeric value between 20 and 1000)								in 'top_k' Slider component
				0,	# int | float (numeric value between 0.0 and 2.0)					in 'rep_penalty' Slider component
				64,	# int | float (numeric value between 64 and 8192)				in 'new_tokens' Slider component
				"true",	# str in 'sample' Radio component
				2,	# int | float (numeric value between 2 and 10)			in 'number of recent talks to keep' Slider component
				"on",	# str in 'internet mode' Radio component
				"05e6a9eace677f93c0e4a93f750c12d03c1f81e043630cb93378da46ce616567",	# str in 'Serper api key' Textbox component
				fn_index=21
)
print(result)
print("fn_index: "+str(result_1))

def chat_with_model(input_text):
#    result = client.predict(input_text, api_name="/user_input_from_st")   #相当于在api调用的程序上执行了相应的动作(例如触发Textbox的submit或者其他事件)
    result = client.predict(input_text, api_name="/accept_value_input")    
    #result = client.predict(input_text, api_name="/value_inp_outp")          
    print(result)
    return result

iface = gr.Interface(fn=chat_with_model, inputs="text", outputs="text")
#使用Interface会自动创建用于输入的Textbox以及用于显示的Textbox

iface.launch()