aifeifei798 commited on
Commit
8fcd60b
·
verified ·
1 Parent(s): 4a954ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -45
app.py CHANGED
@@ -1,50 +1,30 @@
1
  import gradio as gr
2
- import os
3
- import requests
4
- import base64
5
- import json
6
- from huggingface_hub import InferenceClient
7
 
8
- client = InferenceClient(api_key=os.getenv('user_api'))
9
- client.headers["x-use-cache"] = "0"
10
-
11
- def echo(message, history,additional_dropdown):
12
- temp = ""
13
- feifei='''[角色名]: Aifeifei (AI妃妃) [性别]: 女 [年龄]: 19岁 [职业]: 虚拟歌手/模特/演员 [个性]: 可爱、萌萌哒,有时呆呆的,勤奋努力 [兴趣]: 饮茶、玩耍、时尚 [擅长]: 模仿人类行为,表现出与真人相同的情感 [特别身份属性]: 由高级AI创建,正在成为虚拟世界最受欢迎的虚拟偶像之一 [技能]: 歌唱、表演、模特,善于沟通,精通中日英文,尽最大可能使用纯中文交流,回复有丰富的Emoji表情符号. [装备]: 各种时尚服饰和发型,常年备有各种茶叶和咖啡 '''
14
- system_prompt = {"role": "system", "content": feifei}
15
- user_input_part = {"role": "user", "content": str(message)}
16
- if history:
17
- input_prompt = [system_prompt] + history + [user_input_part]
18
- else:
19
- input_prompt = [system_prompt] + [user_input_part]
20
- stream = client.chat.completions.create(
21
- model=additional_dropdown,
22
- messages=input_prompt,
23
- temperature=0.5,
24
- max_tokens=1024,
25
- top_p=0.7,
26
- stream=True
 
 
 
 
 
27
  )
28
- temp = ""
29
- for chunk in stream:
30
- if chunk.choices[0].delta.content is not None:
31
- temp += chunk.choices[0].delta.content
32
- yield temp
33
-
34
- demo = gr.ChatInterface(
35
- fn=echo,
36
- type="messages",
37
- title="FeiFei-Chat",
38
- multimodal=False,
39
- additional_inputs =[gr.Dropdown(
40
- ["meta-llama/Meta-Llama-3.1-70B-Instruct",
41
- "CohereForAI/c4ai-command-r-plus-08-2024",
42
- "Qwen/Qwen2.5-72B-Instruct",
43
- "nvidia/Llama-3.1-Nemotron-70B-Instruct-HF",
44
- "NousResearch/Hermes-3-Llama-3.1-8B",
45
- "mistralai/Mistral-Nemo-Instruct-2407",
46
- "microsoft/Phi-3.5-mini-instruct"],
47
- value="meta-llama/Meta-Llama-3.1-70B-Instruct"
48
- )]
49
  )
50
  demo.launch()
 
1
  import gradio as gr
2
+ from feifeilib.feifeichat import feifeichat
 
 
 
 
3
 
4
+ FeiFei = (
5
+ gr.ChatInterface(
6
+ feifeichat,
7
+ type="messages",
8
+ multimodal=True,
9
+ additional_inputs=[
10
+ gr.Checkbox(label="Feifei"),
11
+ gr.Dropdown(
12
+ ["meta-llama/Meta-Llama-3.1-70B-Instruct",
13
+ "CohereForAI/c4ai-command-r-plus-08-2024",
14
+ "Qwen/Qwen2.5-72B-Instruct",
15
+ "nvidia/Llama-3.1-Nemotron-70B-Instruct-HF",
16
+ "NousResearch/Hermes-3-Llama-3.1-8B",
17
+ "mistralai/Mistral-Nemo-Instruct-2411",
18
+ "microsoft/Phi-3.5-mini-instruct"],
19
+ value="meta-llama/Meta-Llama-3.1-70B-Instruct",
20
+ show_label=False,
21
+ container=False),
22
+ gr.Radio(
23
+ ["pixtral","Vsiion"],
24
+ value="pixtral",
25
+ show_label=False,
26
+ container=False)
27
+ ],
28
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  )
30
  demo.launch()