lachine commited on
Commit
2af52d7
·
1 Parent(s): 8507acf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -15
app.py CHANGED
@@ -1,17 +1,13 @@
1
- from gradio_client import Client
 
 
 
2
 
3
- # Initialize the client and set the API endpoint URL
4
- client = Client("https://stabilityai-stablelm-tuned-alpha-chat.hf.space/")
5
- client.predict(
6
- fn_index=5
7
- )
8
- file1 = client.predict(fn_index=6)
9
- # Send a "start" message to begin the conversation
10
- result = client.predict("start", file1, fn_index=0)
11
- conversation_id = result[1]
12
 
13
- # Send a chat message and get the response
14
- while True:
15
- message = input("You: ")
16
- result = client.predict(message, conversation_id, fn_index=2)
17
- print("Bot:", open(result[1],'r').read())
 
1
+ from transformers import GPT2Tokenizer, GPT2Model
2
+ tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
3
+ model = GPT2Model.from_pretrained('gpt2')
4
+ import gradio as gr
5
 
6
+ def gpt2(string):
7
+ text = string
8
+ encoded_input = tokenizer(text, return_tensors='pt')
9
+ output = model(**encoded_input)
10
+ return output
 
 
 
 
11
 
12
+ iface = gr.Interface(fn=gpt2, inputs="text", outputs="text")
13
+ iface.launch()