focusit commited on
Commit
7d39aad
·
1 Parent(s): 62cbf4d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py CHANGED
@@ -2,11 +2,31 @@ import gradio
2
  import requests
3
  import os
4
  import json
 
5
 
6
  auth = os.environ.get('Authorization')
7
  API_URL = "https://api-inference.huggingface.co/models/google/flan-t5-xl"
8
  headers = {"Authorization": auth}
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  def query(payload):
11
  response = requests.post(API_URL, headers=headers, json=payload)
12
 
@@ -15,6 +35,7 @@ def query(payload):
15
 
16
 
17
  def responsenew(uinput):
 
18
  return query({
19
  "inputs": "Can you please let us know more details about your ",
20
  })
 
2
  import requests
3
  import os
4
  import json
5
+ from hugchat import hugchat
6
 
7
  auth = os.environ.get('Authorization')
8
  API_URL = "https://api-inference.huggingface.co/models/google/flan-t5-xl"
9
  headers = {"Authorization": auth}
10
 
11
+
12
+
13
+ def huggChat(data):
14
+ # start a new huggingchat connection
15
+ chatbot = hugchat.ChatBot()
16
+
17
+ # start a new conversation
18
+ id = chatbot.new_conversation()
19
+ chatbot.change_conversation(id)
20
+
21
+ # enter your message here
22
+
23
+
24
+ # print the response
25
+
26
+ result = chatbot.chat(data)
27
+ print(result)
28
+ return result
29
+
30
  def query(payload):
31
  response = requests.post(API_URL, headers=headers, json=payload)
32
 
 
35
 
36
 
37
  def responsenew(uinput):
38
+ huggChat(uinput)
39
  return query({
40
  "inputs": "Can you please let us know more details about your ",
41
  })