adinin commited on
Commit
10e4b89
·
1 Parent(s): 7e96c06

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub import InferenceClient
3
+
4
+ client = InferenceClient(model="https://a17d18bb-c94d-4b50-b78f-14306508c584.job.console.elementai.com",
5
+ headers={"Authorization":"Bearer j1__hysJQB-F6HXCBqJmmQ:r099ldtg2MtRBdHT6hEeAZndDOj3W68fs58yWNMZJ6M"})
6
+
7
+ def inference(message, history):
8
+ partial_message = ""
9
+ for token in client.text_generation(message, max_new_tokens=500, stream=True):
10
+ partial_message += token
11
+ yield partial_message
12
+
13
+ gr.ChatInterface(
14
+ inference,
15
+ chatbot=gr.Chatbot(height=700),
16
+ textbox=gr.Textbox(placeholder="Prompt CodeLlama model", container=False, scale=2),
17
+ description="This is the CodeLLaMA 34b-Instruct-hf model. Note that this \"chat\" does not keep context. Each message is a separate prompt.",
18
+ title="ATG 🤝 TGI",
19
+ examples=["write a Python function to add 2 numbers", "write a Javascript function that logs out the current time"],
20
+ retry_btn="Retry",
21
+ undo_btn="Undo",
22
+ clear_btn="Clear",
23
+ ).queue().launch()