hashirlodhi commited on
Commit
10458da
·
verified ·
1 Parent(s): 0d76684

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -16,17 +16,24 @@ except ImportError:
16
  new_openai = False
17
 
18
  def analyze_text(text):
19
- """Advanced forensic analysis with improved prompt and formatted output"""
20
  if len(text.strip()) < 50:
21
  return "⚠️ Please provide at least 50 characters for accurate analysis."
22
 
 
23
  expert_prompt = f"""
24
  [ROLE]
25
- You are Dr. Lexica, a world-renowned forensic linguistics expert specializing in AI/human text differentiation with 25 years of experience.
26
 
27
  [TEXT TO ANALYZE]
28
  {text}
29
 
 
 
 
 
 
 
30
  [REQUIRED OUTPUT FORMAT]
31
  # 🕵️‍♂️ Forensic Text Analysis Report
32
  ## 🔍 Verdict
@@ -44,24 +51,24 @@ def analyze_text(text):
44
  - {{Marker 2}}
45
 
46
  ## 💡 Expert Conclusion
47
- {{3-4 sentence conclusion}}
48
  """
49
 
50
  try:
51
  if new_openai:
52
  response = client.chat.completions.create(
53
- model="gpt-4",
54
  messages=[
55
  {"role": "system", "content": "You are a forensic text analysis AI."},
56
  {"role": "user", "content": expert_prompt}
57
  ],
58
- temperature=0.1,
59
  max_tokens=500
60
  )
61
  return response.choices[0].message.content
62
  else:
63
  response = openai.ChatCompletion.create(
64
- model="gpt-4",
65
  messages=[
66
  {"role": "system", "content": "You are a forensic text analysis AI."},
67
  {"role": "user", "content": expert_prompt}
 
16
  new_openai = False
17
 
18
  def analyze_text(text):
19
+ """Advanced forensic analysis with improved prompt and formatted output using GPT-3.5 Turbo"""
20
  if len(text.strip()) < 50:
21
  return "⚠️ Please provide at least 50 characters for accurate analysis."
22
 
23
+ # Optimized prompt for GPT-3.5 Turbo
24
  expert_prompt = f"""
25
  [ROLE]
26
+ You are Dr. Lexica, a forensic linguistics expert specializing in AI/human text differentiation. Your task is to analyze the provided text and determine if it was written by a human or generated by an AI, providing a clear verdict, confidence level, and specific indicators.
27
 
28
  [TEXT TO ANALYZE]
29
  {text}
30
 
31
+ [INSTRUCTIONS]
32
+ - Analyze linguistic patterns such as word choice, sentence structure, coherence, and stylistic nuances.
33
+ - Look for human markers (e.g., emotional tone, idiosyncratic phrasing, inconsistencies) and AI markers (e.g., formulaic patterns, overly polished language, predictable transitions).
34
+ - Provide a confidence level (0-100%) and a detection score (0-10, where 0 is human, 10 is AI).
35
+ - Format the output exactly as specified below.
36
+
37
  [REQUIRED OUTPUT FORMAT]
38
  # 🕵️‍♂️ Forensic Text Analysis Report
39
  ## 🔍 Verdict
 
51
  - {{Marker 2}}
52
 
53
  ## 💡 Expert Conclusion
54
+ {{3-4 sentence conclusion summarizing the analysis}}
55
  """
56
 
57
  try:
58
  if new_openai:
59
  response = client.chat.completions.create(
60
+ model="gpt-3.5-turbo", # Changed to GPT-3.5 Turbo
61
  messages=[
62
  {"role": "system", "content": "You are a forensic text analysis AI."},
63
  {"role": "user", "content": expert_prompt}
64
  ],
65
+ temperature=0.1, # Low temperature for consistent output
66
  max_tokens=500
67
  )
68
  return response.choices[0].message.content
69
  else:
70
  response = openai.ChatCompletion.create(
71
+ model="gpt-3.5-turbo", # Changed to GPT-3.5 Turbo
72
  messages=[
73
  {"role": "system", "content": "You are a forensic text analysis AI."},
74
  {"role": "user", "content": expert_prompt}