ai01firebird commited on
Commit
c644909
·
verified ·
1 Parent(s): 6f98bcd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
  import os
 
4
 
5
  # Load API key from environment variables
6
  HF_API_TOKEN = os.getenv("HUG_TOKEN_READ")
@@ -10,7 +11,10 @@ client = InferenceClient(model="mistralai/Mistral-7B-Instruct-v0.1", token=HF_AP
10
 
11
  # Function to translate text into emojis
12
  def text_to_emoji(text):
13
- prompt = f"Convert this sentence into an emoji-sequence of the same meaning and return only the emojis, no explanation:\n\n\"{text}\""
 
 
 
14
  response = client.text_generation(prompt, max_new_tokens=50)
15
  return response
16
 
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
  import os
4
+ import re
5
 
6
  # Load API key from environment variables
7
  HF_API_TOKEN = os.getenv("HUG_TOKEN_READ")
 
11
 
12
  # Function to translate text into emojis
13
  def text_to_emoji(text):
14
+ # remove special characters
15
+ text_cleaned = re.sub(r"[.,!?;:]", "", text)
16
+
17
+ prompt = f"Convert this sentence into an emoji-sequence of the same meaning and return only the emojis, no explanation:\n\n\"{text_cleaned}\""
18
  response = client.text_generation(prompt, max_new_tokens=50)
19
  return response
20