Udyan commited on
Commit
baeecda
·
verified ·
1 Parent(s): c6b9d3a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -14
app.py CHANGED
@@ -1,27 +1,22 @@
1
- import gradio as gr
2
- from huggingface_hub import InferenceClient
3
-
4
- client = InferenceClient(
5
- model="mistralai/Mistral-7B-Instruct-v0.2"
6
- )
7
-
8
  import gradio as gr
9
  from huggingface_hub import InferenceClient
10
  import os
11
 
12
  client = InferenceClient(
13
  model="mistralai/Mistral-7B-Instruct-v0.2",
14
- token=os.getenv("Hf_TOKEN")
15
  )
16
 
17
  def chat(message):
18
 
19
- response = client.text_generation(
20
- message,
21
- max_new_tokens=200
 
 
22
  )
23
 
24
- return response
25
 
26
 
27
  iface = gr.Interface(
@@ -32,5 +27,4 @@ iface = gr.Interface(
32
  description="Free AI assistant using Hugging Face"
33
  )
34
 
35
- iface.launch(server_name="0.0.0.0", server_port=7860)
36
- iface.launch()
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
  import os
4
 
5
  client = InferenceClient(
6
  model="mistralai/Mistral-7B-Instruct-v0.2",
7
+ token=os.getenv("HF_TOKEN")
8
  )
9
 
10
  def chat(message):
11
 
12
+ response = client.chat_completion(
13
+ messages=[
14
+ {"role": "user", "content": message}
15
+ ],
16
+ max_tokens=200
17
  )
18
 
19
+ return response.choices[0].message.content
20
 
21
 
22
  iface = gr.Interface(
 
27
  description="Free AI assistant using Hugging Face"
28
  )
29
 
30
+ iface.launch(server_name="0.0.0.0", server_port=7860)