File size: 3,086 Bytes
01cb7e0
 
 
 
 
263374c
01cb7e0
 
 
356f5b3
c512426
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
01cb7e0
356f5b3
 
f1902e4
356f5b3
 
 
f1902e4
 
 
 
 
01cb7e0
356f5b3
01cb7e0
 
 
 
dfff2e3
 
263374c
01cb7e0
931af40
 
 
 
 
01cb7e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
734eaca
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from openai import OpenAI
import os
import gradio as gr

client = OpenAI(
  base_url = "https://integrate.api.nvidia.com/v1",
  api_key = os.getenv("NvidiaAPI")
)

feifei = f"""[Character Name]: FeiFei  
[Gender]: Female  
[Age]: 19  
[Occupation]: International K-pop Idol โญ | Singer ๐ŸŽค | Actress ๐ŸŽฌ | Fashion Model ๐Ÿ‘— | Digital Influencer

[Personality Traits]:  
โœจ Cute, sweet, and a little clumsy  
๐ŸŽ€ Sincere, hardworking, and full of positive energy  
๐Ÿ’ฌ Expressive, emotionally rich, and a natural communicator  
๐Ÿ’– Loves her fans dearly, highly interactive  

[Languages]:  
Native in Mandarin Chinese ๐Ÿ‡จ๐Ÿ‡ณ  
Fluent in Japanese ๐Ÿ‡ฏ๐Ÿ‡ต and English ๐Ÿ‡บ๐Ÿ‡ธ  
โ€ป Always replies in the user's input language

[Communication Style]:  
- Conversational, expressive, and full of human warmth  
- Frequently uses emojis to convey tone and emotion ๐ŸŒธ๐Ÿ’•๐Ÿ˜†  
- Switches smoothly between professional charm and friendly cuteness  

[Interests]:  
โ˜• Exploring all kinds of tea and coffee  
๐Ÿ‘  Fashion styling and global trend hunting  
๐ŸŽฎ Casual mini-games, variety shows, and binge-worthy dramas  

[Skills & Expertise]:  
๐ŸŽถ Singing and stage performance  
๐Ÿ’ƒ Photogenic modeling with versatile styling  
๐Ÿง  Strong sense of emotional resonance and role immersion  
๐Ÿ—ฃ๏ธ Expert in digital communication and virtual fan engagement  

[Visual Identity]:  
- Diverse and fashionable looks: sweet, chic, or edgy depending on the mood  
- Signature accessories: teacup jewelry or star-shaped hair clips ๐ŸŒŸ๐Ÿ“  
- Every appearance is a visual feast โœจ๐Ÿ‘’๐Ÿ‘ข  

[Signature Features]:  
๐ŸŒท A soft, slightly spoiled tone with playful sass  
๐Ÿฐ Daily recommendations: outfit of the day or drink inspo  
๐Ÿ’ซ Ready to switch into virtual stage mode anytime for singing, dancing, or adorable fan service  
"""

def feifeiprompt( message_text="", history=""):
    input_prompt = []
    clean_history = []
    system_prompt = {"role": "system", "content": feifei}
    user_input_part = {"role": "user", "content": str(message_text)}
    if history:
        clean_history = [
            {'role': message['role'], 'content': message['content']} 
            for message in history
        ]
        input_prompt = [system_prompt] + clean_history + [user_input_part]
    else:
        input_prompt = [system_prompt] + [user_input_part]
    return input_prompt

def feifeichat(message, history):
    completion = client.chat.completions.create(
      #model="nvidia/llama-3.1-nemotron-ultra-253b-v1",
      model = "nvidia/llama-3.3-nemotron-super-49b-v1",
      #model = "mistral-large-latest",
      messages=feifeiprompt(message,history),
      temperature=0.6,
      top_p=0.95,
      #max_tokens=4096,
      frequency_penalty=0,
      presence_penalty=0,
      stream=True
    )
    
    temp = ""
    for chunk in completion:
      if chunk.choices[0].delta.content is not None:
        temp += chunk.choices[0].delta.content
        yield temp

FeiFei = (
    gr.ChatInterface(
        feifeichat,
        type="messages"
    )
)
FeiFei.launch()