Jahadu commited on
Commit
33e70fc
·
verified ·
1 Parent(s): 54a5949

Delete humanize.py

Browse files
Files changed (1) hide show
  1. humanize.py +0 -47
humanize.py DELETED
@@ -1,47 +0,0 @@
1
- from transformers import pipeline
2
- from translatepy import Translator
3
- import random
4
- import re
5
-
6
- # Cache common translations to reduce costs
7
- translation_cache = {}
8
-
9
- def add_human_quirks(text):
10
- """Add imperfections to bypass AI detection"""
11
- # Randomly add colloquial phrases
12
- colloquial = ["you know", "like", "kinda", "TBH", "tbh", "imo"]
13
- words = text.split()
14
- if len(words) > 10:
15
- insert_pos = random.randint(1, len(words)-1)
16
- words.insert(insert_pos, random.choice(colloquial))
17
-
18
- # Introduce minor typos (0.5% chance per word)
19
- modified = []
20
- for word in words:
21
- if random.random() < 0.005:
22
- word = word[:-1] + random.choice(['z', 'x', '!', ''])
23
- modified.append(word)
24
-
25
- return " ".join(modified)
26
-
27
- def humanize_text(text, tone):
28
- """Use larger model via Replicate API"""
29
- # See next section for model choice
30
- client = replicate.Client(api_key="YOUR_REPLICATE_KEY")
31
- prompt = f"{TONE_PROMPTS[tone]}: {text}"
32
-
33
- output = client.run(
34
- "nousresearch/nous-hermes-2-yi-34b:...", # Replace with latest version
35
- input={"prompt": prompt, "temperature": 0.7}
36
- )
37
- return add_human_quirks(output)
38
-
39
- def translate_text(text, target_lang):
40
- """Use Google Cloud Translation for reliability"""
41
- translator = Translator()
42
- if target_lang in translation_cache:
43
- return translation_cache[target_lang]
44
-
45
- result = translator.translate(text, destination_language=target_lang).result
46
- translation_cache[target_lang] = result
47
- return result