File size: 1,314 Bytes
9dae05b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import gradio as gr
import requests
import json


with open('config.json', 'r', encoding='utf-8') as file:
    data = json.load(file)

print(data)

type = data['prompt']
introId = data['introId']
faceId = data['faceId']
voiceId = data['voiceId']

def chat(message, history):

  txt = ""

  print(message)
  #r = requests.post('https://oe-napi.circul.us/v1/txt2chat', json = { "body" : {'prompt ': message, 'history' : [''], 'lang' : 'ko','type':'assist', 'rag' : '','temp' : 1}, 'prompt ': message, 'history' : [''], 'lang' : 'ko','type':'assist', 'rag' : '','temp' : 1}, stream=True)
  r = requests.post('http://222.112.0.215:59522/v1/chat', json={ 'prompt': message, 'history' : [''], 'lang' : 'ko','type': type, 'rag' : '','temp' : 1 }, stream=True)

  print(r)
  for line in r.iter_lines():
    line = line.decode('utf-8')
    print(line)
    txt = txt + "\n" + line
    yield txt

desc = f"""
  <video width="512" height="512" controls poster="https://canvers.net/v1/v/media/{faceId}" preload autoplay>
    <source src="https://canvers.net/v1/v/media/{introId}?type=mp4" type="video/mp4">
  </video>
"""

# http://222.112.0.215:59522/v1/v/media/658aaf340833518cf6140dd8?type=mp4&length=158033

demo = gr.ChatInterface(fn=chat, description=desc, fill_height=True)

if __name__ == "__main__":
    demo.launch()