indecision commited on
Commit
3692b8b
·
verified ·
1 Parent(s): d519dfb

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub import InferenceApi
3
+
4
+ # point to the base model with no instruction tuning or filters
5
+ api = InferenceApi(
6
+ repo_id="EleutherAI/gpt-neo-1.3B",
7
+ task="text-generation"
8
+ )
9
+
10
+ def respond(prompt):
11
+ try:
12
+ outputs = api(inputs=prompt, parameters={"max_new_tokens":200, "temperature":0.7})
13
+ return outputs[0].get("generated_text", "[error] no text returned")
14
+ except Exception as e:
15
+ return f"[exception] {e}"
16
+
17
+ gr.Interface(
18
+ fn=respond,
19
+ inputs=gr.Textbox(lines=3, placeholder="type anything…"),
20
+ outputs="text",
21
+ title="uncensored gpt-neo-1.3B chat"
22
+ ).launch(server_name="0.0.0.0", server_port=7860)